The following issues were found

src/test/java/com/alibaba/json/bvt/bug/Issue998_private.java
20 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 14

               * Created by wenshao on 16/01/2017.
 */
public class Issue998_private extends TestCase {
    public void test_for_issue() throws Exception {
        Model model = JSON.parseObject("{\"items\":[{\"id\":123}]}", Model.class);
        assertNotNull(model);
        assertNotNull(model.items);
        assertEquals(1, model.items.size());
        assertEquals(123, model.items.get(0).getId());

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 14

               * Created by wenshao on 16/01/2017.
 */
public class Issue998_private extends TestCase {
    public void test_for_issue() throws Exception {
        Model model = JSON.parseObject("{\"items\":[{\"id\":123}]}", Model.class);
        assertNotNull(model);
        assertNotNull(model.items);
        assertEquals(1, model.items.size());
        assertEquals(123, model.items.get(0).getId());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

              public class Issue998_private extends TestCase {
    public void test_for_issue() throws Exception {
        Model model = JSON.parseObject("{\"items\":[{\"id\":123}]}", Model.class);
        assertNotNull(model);
        assertNotNull(model.items);
        assertEquals(1, model.items.size());
        assertEquals(123, model.items.get(0).getId());

        String json = JSON.toJSONString(model, SerializerFeature.NotWriteRootClassName, SerializerFeature.WriteClassName);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                  public void test_for_issue() throws Exception {
        Model model = JSON.parseObject("{\"items\":[{\"id\":123}]}", Model.class);
        assertNotNull(model);
        assertNotNull(model.items);
        assertEquals(1, model.items.size());
        assertEquals(123, model.items.get(0).getId());

        String json = JSON.toJSONString(model, SerializerFeature.NotWriteRootClassName, SerializerFeature.WriteClassName);
        assertEquals("{\"items\":[{\"id\":123}]}", json);

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 18

                      Model model = JSON.parseObject("{\"items\":[{\"id\":123}]}", Model.class);
        assertNotNull(model);
        assertNotNull(model.items);
        assertEquals(1, model.items.size());
        assertEquals(123, model.items.get(0).getId());

        String json = JSON.toJSONString(model, SerializerFeature.NotWriteRootClassName, SerializerFeature.WriteClassName);
        assertEquals("{\"items\":[{\"id\":123}]}", json);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      Model model = JSON.parseObject("{\"items\":[{\"id\":123}]}", Model.class);
        assertNotNull(model);
        assertNotNull(model.items);
        assertEquals(1, model.items.size());
        assertEquals(123, model.items.get(0).getId());

        String json = JSON.toJSONString(model, SerializerFeature.NotWriteRootClassName, SerializerFeature.WriteClassName);
        assertEquals("{\"items\":[{\"id\":123}]}", json);
    }

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 19

                      assertNotNull(model);
        assertNotNull(model.items);
        assertEquals(1, model.items.size());
        assertEquals(123, model.items.get(0).getId());

        String json = JSON.toJSONString(model, SerializerFeature.NotWriteRootClassName, SerializerFeature.WriteClassName);
        assertEquals("{\"items\":[{\"id\":123}]}", json);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                      assertNotNull(model);
        assertNotNull(model.items);
        assertEquals(1, model.items.size());
        assertEquals(123, model.items.get(0).getId());

        String json = JSON.toJSONString(model, SerializerFeature.NotWriteRootClassName, SerializerFeature.WriteClassName);
        assertEquals("{\"items\":[{\"id\":123}]}", json);
    }


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 19

                      assertNotNull(model);
        assertNotNull(model.items);
        assertEquals(1, model.items.size());
        assertEquals(123, model.items.get(0).getId());

        String json = JSON.toJSONString(model, SerializerFeature.NotWriteRootClassName, SerializerFeature.WriteClassName);
        assertEquals("{\"items\":[{\"id\":123}]}", json);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

                      assertEquals(123, model.items.get(0).getId());

        String json = JSON.toJSONString(model, SerializerFeature.NotWriteRootClassName, SerializerFeature.WriteClassName);
        assertEquals("{\"items\":[{\"id\":123}]}", json);
    }

    public void test_for_issue_1() throws Exception {
        Field field = Model.class.getField("items");
        List<Item> items = (List<Item> ) JSON.parseObject("[{\"id\":123}]", field.getGenericType());

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/JSONReaderTest_object_int_unquote.java
20 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 15

              
public class JSONReaderTest_object_int_unquote extends TestCase {

    String text = "{f0:0,f1:1,f2:2,f3:3,f4:4, " + //
                  "f5:5,f6:6,f7:7,f8:8,f9:9}";

    public void test_read() throws Exception {

        JSONReader reader = new JSONReader(new StringReader(text));

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 18

                  String text = "{f0:0,f1:1,f2:2,f3:3,f4:4, " + //
                  "f5:5,f6:6,f7:7,f8:8,f9:9}";

    public void test_read() throws Exception {

        JSONReader reader = new JSONReader(new StringReader(text));
        reader.startObject();

        int count = 0;

            

Reported by PMD.

Avoid unused local variables such as 'key'.
Design

Line: 25

              
        int count = 0;
        while (reader.hasNext()) {
            String key = (String) reader.readObject();
            Integer value = reader.readInteger();
            count++;
        }
        Assert.assertEquals(10, count);


            

Reported by PMD.

Avoid unused local variables such as 'value'.
Design

Line: 26

                      int count = 0;
        while (reader.hasNext()) {
            String key = (String) reader.readObject();
            Integer value = reader.readInteger();
            count++;
        }
        Assert.assertEquals(10, count);

        reader.endObject();

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 35

                      reader.close();
    }

    public void test_read_1() throws Exception {
        JSONReader reader = new JSONReader(new JSONScanner(text));
        reader.startObject();

        int count = 0;
        while (reader.hasNext()) {

            

Reported by PMD.

Avoid unused local variables such as 'key'.
Design

Line: 41

              
        int count = 0;
        while (reader.hasNext()) {
            String key = (String) reader.readObject();
            Integer value = reader.readInteger();
            count++;
        }
        Assert.assertEquals(10, count);


            

Reported by PMD.

Avoid unused local variables such as 'value'.
Design

Line: 42

                      int count = 0;
        while (reader.hasNext()) {
            String key = (String) reader.readObject();
            Integer value = reader.readInteger();
            count++;
        }
        Assert.assertEquals(10, count);

        reader.endObject();

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.parser.Feature'
Design

Line: 10

              import org.junit.Assert;

import com.alibaba.fastjson.JSONReader;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.parser.JSONScanner;

public class JSONReaderTest_object_int_unquote extends TestCase {

    String text = "{f0:0,f1:1,f2:2,f3:3,f4:4, " + //

            

Reported by PMD.

Found 'DD'-anomaly for variable 'count' (lines '23'-'27').
Error

Line: 23

                      JSONReader reader = new JSONReader(new StringReader(text));
        reader.startObject();

        int count = 0;
        while (reader.hasNext()) {
            String key = (String) reader.readObject();
            Integer value = reader.readInteger();
            count++;
        }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'key' (lines '25'-'33').
Error

Line: 25

              
        int count = 0;
        while (reader.hasNext()) {
            String key = (String) reader.readObject();
            Integer value = reader.readInteger();
            count++;
        }
        Assert.assertEquals(10, count);


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/DefaultJSONParserTest2.java
20 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 15

              
public class DefaultJSONParserTest2 extends TestCase {

    public void test_empty() throws Exception {
        String text = "";
        assertNull(JSON.parse(text));
        assertNull(JSON.parseObject(text));
        assertNull(JSON.parseObject(text, Object.class));
        assertNull(JSON.parseObject(text, Map.class));

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 15

              
public class DefaultJSONParserTest2 extends TestCase {

    public void test_empty() throws Exception {
        String text = "";
        assertNull(JSON.parse(text));
        assertNull(JSON.parseObject(text));
        assertNull(JSON.parseObject(text, Object.class));
        assertNull(JSON.parseObject(text, Map.class));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

              
    public void test_empty() throws Exception {
        String text = "";
        assertNull(JSON.parse(text));
        assertNull(JSON.parseObject(text));
        assertNull(JSON.parseObject(text, Object.class));
        assertNull(JSON.parseObject(text, Map.class));
        assertNull(JSON.parseObject(text, Entity.class));
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                  public void test_empty() throws Exception {
        String text = "";
        assertNull(JSON.parse(text));
        assertNull(JSON.parseObject(text));
        assertNull(JSON.parseObject(text, Object.class));
        assertNull(JSON.parseObject(text, Map.class));
        assertNull(JSON.parseObject(text, Entity.class));
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                      String text = "";
        assertNull(JSON.parse(text));
        assertNull(JSON.parseObject(text));
        assertNull(JSON.parseObject(text, Object.class));
        assertNull(JSON.parseObject(text, Map.class));
        assertNull(JSON.parseObject(text, Entity.class));
    }

    public static class Entity {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

                      assertNull(JSON.parse(text));
        assertNull(JSON.parseObject(text));
        assertNull(JSON.parseObject(text, Object.class));
        assertNull(JSON.parseObject(text, Map.class));
        assertNull(JSON.parseObject(text, Entity.class));
    }

    public static class Entity {


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 21

                      assertNull(JSON.parseObject(text));
        assertNull(JSON.parseObject(text, Object.class));
        assertNull(JSON.parseObject(text, Map.class));
        assertNull(JSON.parseObject(text, Entity.class));
    }

    public static class Entity {

    }

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 28

              
    }

    public void test_0() throws Exception {
        String text = "{}";
        Map map = (Map) JSON.parse(text);
        Assert.assertEquals(0, map.size());
    }


            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 31

                  public void test_0() throws Exception {
        String text = "{}";
        Map map = (Map) JSON.parse(text);
        Assert.assertEquals(0, map.size());
    }

    public void test_1() throws Exception {
        JSONException error = null;
        try {

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 34

                      Assert.assertEquals(0, map.size());
    }

    public void test_1() throws Exception {
        JSONException error = null;
        try {
            String text = "{}a";
            Map map = (Map) JSON.parse(text);
            Assert.assertEquals(0, map.size());

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/SerializeWriterTest_8.java
20 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 15

              
public class SerializeWriterTest_8 extends TestCase {

    public void test_BrowserCompatible() throws Exception {
        StringBuilder buf = new StringBuilder();
        for (int i = 0; i < 1024; ++i) {
            buf.append('a');
        }
        buf.append("中国");

            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 15

              
public class SerializeWriterTest_8 extends TestCase {

    public void test_BrowserCompatible() throws Exception {
        StringBuilder buf = new StringBuilder();
        for (int i = 0; i < 1024; ++i) {
            buf.append('a');
        }
        buf.append("中国");

            

Reported by PMD.

StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
Performance

Line: 20

                      for (int i = 0; i < 1024; ++i) {
            buf.append('a');
        }
        buf.append("中国");
        buf.append("\0");
        JSON.toJSONString(buf.toString(), SerializerFeature.BrowserCompatible);
    }

    public void test_writer() throws Exception {

            

Reported by PMD.

StringBuffer (or StringBuilder).append is called 2 consecutive times with literals. Use a single append with a single combined String.
Performance

Line: 20

                      for (int i = 0; i < 1024; ++i) {
            buf.append('a');
        }
        buf.append("中国");
        buf.append("\0");
        JSON.toJSONString(buf.toString(), SerializerFeature.BrowserCompatible);
    }

    public void test_writer() throws Exception {

            

Reported by PMD.

Avoid appending characters as strings in StringBuffer.append.
Performance

Line: 21

                          buf.append('a');
        }
        buf.append("中国");
        buf.append("\0");
        JSON.toJSONString(buf.toString(), SerializerFeature.BrowserCompatible);
    }

    public void test_writer() throws Exception {
        StringBuilder buf = new StringBuilder();

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 25

                      JSON.toJSONString(buf.toString(), SerializerFeature.BrowserCompatible);
    }

    public void test_writer() throws Exception {
        StringBuilder buf = new StringBuilder();
        for (int i = 0; i < 1024; ++i) {
            buf.append('a');
        }
        buf.append("中国");

            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 25

                      JSON.toJSONString(buf.toString(), SerializerFeature.BrowserCompatible);
    }

    public void test_writer() throws Exception {
        StringBuilder buf = new StringBuilder();
        for (int i = 0; i < 1024; ++i) {
            buf.append('a');
        }
        buf.append("中国");

            

Reported by PMD.

StringBuffer (or StringBuilder).append is called 2 consecutive times with literals. Use a single append with a single combined String.
Performance

Line: 30

                      for (int i = 0; i < 1024; ++i) {
            buf.append('a');
        }
        buf.append("中国");
        buf.append("\0");

        StringWriter out = new StringWriter();
        JSON.writeJSONStringTo(buf.toString(), out, SerializerFeature.BrowserCompatible);
    }

            

Reported by PMD.

StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
Performance

Line: 30

                      for (int i = 0; i < 1024; ++i) {
            buf.append('a');
        }
        buf.append("中国");
        buf.append("\0");

        StringWriter out = new StringWriter();
        JSON.writeJSONStringTo(buf.toString(), out, SerializerFeature.BrowserCompatible);
    }

            

Reported by PMD.

Avoid appending characters as strings in StringBuffer.append.
Performance

Line: 31

                          buf.append('a');
        }
        buf.append("中国");
        buf.append("\0");

        StringWriter out = new StringWriter();
        JSON.writeJSONStringTo(buf.toString(), out, SerializerFeature.BrowserCompatible);
    }


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/NotWriteDefaultValueTest_NoneASM.java
20 issues
Do not use the short type
Performance

Line: 80

              
    private static class VO_Short {

        private short f0;
        private short f1;

        public short getF0() {
            return f0;
        }

            

Reported by PMD.

Do not use the short type
Performance

Line: 81

                  private static class VO_Short {

        private short f0;
        private short f1;

        public short getF0() {
            return f0;
        }


            

Reported by PMD.

Do not use the short type
Performance

Line: 83

                      private short f0;
        private short f1;

        public short getF0() {
            return f0;
        }

        public void setF0(short f0) {
            this.f0 = f0;

            

Reported by PMD.

Do not use the short type
Performance

Line: 87

                          return f0;
        }

        public void setF0(short f0) {
            this.f0 = f0;
        }

        public short getF1() {
            return f1;

            

Reported by PMD.

Do not use the short type
Performance

Line: 91

                          this.f0 = f0;
        }

        public short getF1() {
            return f1;
        }

        public void setF1(short f1) {
            this.f1 = f1;

            

Reported by PMD.

Do not use the short type
Performance

Line: 95

                          return f1;
        }

        public void setF1(short f1) {
            this.f1 = f1;
        }

    }


            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 12

              
public class NotWriteDefaultValueTest_NoneASM extends TestCase {

    public void test_for_byte() throws Exception {
        VO_Byte vo = new VO_Byte();
        String text = JSON.toJSONString(vo, SerializerFeature.NotWriteDefaultValue);
        Assert.assertEquals("{}", text);
    }


            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 18

                      Assert.assertEquals("{}", text);
    }

    public void test_for_short() throws Exception {
        VO_Short vo = new VO_Short();
        String text = JSON.toJSONString(vo, SerializerFeature.NotWriteDefaultValue);
        Assert.assertEquals("{}", text);
    }


            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 24

                      Assert.assertEquals("{}", text);
    }

    public void test_for_int() throws Exception {
        VO_Int vo = new VO_Int();
        String text = JSON.toJSONString(vo, SerializerFeature.NotWriteDefaultValue);
        Assert.assertEquals("{}", text);
    }


            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 30

                      Assert.assertEquals("{}", text);
    }

    public void test_for_long() throws Exception {
        VO_Long vo = new VO_Long();
        String text = JSON.toJSONString(vo, SerializerFeature.NotWriteDefaultValue);
        Assert.assertEquals("{}", text);
    }


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/NotWriteDefaultValueTest.java
20 issues
Do not use the short type
Performance

Line: 80

              
    public static class VO_Short {

        private short f0;
        private short f1;

        public short getF0() {
            return f0;
        }

            

Reported by PMD.

Do not use the short type
Performance

Line: 81

                  public static class VO_Short {

        private short f0;
        private short f1;

        public short getF0() {
            return f0;
        }


            

Reported by PMD.

Do not use the short type
Performance

Line: 83

                      private short f0;
        private short f1;

        public short getF0() {
            return f0;
        }

        public void setF0(short f0) {
            this.f0 = f0;

            

Reported by PMD.

Do not use the short type
Performance

Line: 87

                          return f0;
        }

        public void setF0(short f0) {
            this.f0 = f0;
        }

        public short getF1() {
            return f1;

            

Reported by PMD.

Do not use the short type
Performance

Line: 91

                          this.f0 = f0;
        }

        public short getF1() {
            return f1;
        }

        public void setF1(short f1) {
            this.f1 = f1;

            

Reported by PMD.

Do not use the short type
Performance

Line: 95

                          return f1;
        }

        public void setF1(short f1) {
            this.f1 = f1;
        }

    }


            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 12

              
public class NotWriteDefaultValueTest extends TestCase {

    public void test_for_byte() throws Exception {
        VO_Byte vo = new VO_Byte();
        String text = JSON.toJSONString(vo, SerializerFeature.NotWriteDefaultValue);
        Assert.assertEquals("{}", text);
    }


            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 18

                      Assert.assertEquals("{}", text);
    }

    public void test_for_short() throws Exception {
        VO_Short vo = new VO_Short();
        String text = JSON.toJSONString(vo, SerializerFeature.NotWriteDefaultValue);
        Assert.assertEquals("{}", text);
    }


            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 24

                      Assert.assertEquals("{}", text);
    }

    public void test_for_int() throws Exception {
        VO_Int vo = new VO_Int();
        String text = JSON.toJSONString(vo, SerializerFeature.NotWriteDefaultValue);
        Assert.assertEquals("{}", text);
    }


            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 30

                      Assert.assertEquals("{}", text);
    }

    public void test_for_long() throws Exception {
        VO_Long vo = new VO_Long();
        String text = JSON.toJSONString(vo, SerializerFeature.NotWriteDefaultValue);
        Assert.assertEquals("{}", text);
    }


            

Reported by PMD.

src/test/java/com/alibaba/fastjson/deserializer/issues569/TestIssues569.java
20 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 26

               */
public class TestIssues569 {

    private int featureValues = JSON.DEFAULT_PARSER_FEATURE;
    private Feature[] features;

    private static final Feature[] EMPTY_SERIALIZER_FEATURES = new Feature[0];

    private String jsonData = "{\"result\":[{\"id\":0,\"startDate\":1420041600000,\"name\":\"集团\",\"abbr\":\"集团\",\"endDate\":253402185600000,\"type\":\"1317967b-4a83-442c-a7b4-1ac9e7bf84d9\"},{\"id\":0,\"startDate\":1420041600000,\"name\":\"集团总裁办\",\"abbr\":\"集团总裁办\",\"endDate\":253402185600000,\"pcode\":\"4aa2817e-ae16-4355-a1cc-a73d0b8abc43\",\"type\":\"36e9bde9-2e94-4b91-8b9f-b1078296e3ad\"}],\"errCode\":0,\"success\":true}";

            

Reported by PMD.

Private field 'featureValues' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 26

               */
public class TestIssues569 {

    private int featureValues = JSON.DEFAULT_PARSER_FEATURE;
    private Feature[] features;

    private static final Feature[] EMPTY_SERIALIZER_FEATURES = new Feature[0];

    private String jsonData = "{\"result\":[{\"id\":0,\"startDate\":1420041600000,\"name\":\"集团\",\"abbr\":\"集团\",\"endDate\":253402185600000,\"type\":\"1317967b-4a83-442c-a7b4-1ac9e7bf84d9\"},{\"id\":0,\"startDate\":1420041600000,\"name\":\"集团总裁办\",\"abbr\":\"集团总裁办\",\"endDate\":253402185600000,\"pcode\":\"4aa2817e-ae16-4355-a1cc-a73d0b8abc43\",\"type\":\"36e9bde9-2e94-4b91-8b9f-b1078296e3ad\"}],\"errCode\":0,\"success\":true}";

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 27

              public class TestIssues569 {

    private int featureValues = JSON.DEFAULT_PARSER_FEATURE;
    private Feature[] features;

    private static final Feature[] EMPTY_SERIALIZER_FEATURES = new Feature[0];

    private String jsonData = "{\"result\":[{\"id\":0,\"startDate\":1420041600000,\"name\":\"集团\",\"abbr\":\"集团\",\"endDate\":253402185600000,\"type\":\"1317967b-4a83-442c-a7b4-1ac9e7bf84d9\"},{\"id\":0,\"startDate\":1420041600000,\"name\":\"集团总裁办\",\"abbr\":\"集团总裁办\",\"endDate\":253402185600000,\"pcode\":\"4aa2817e-ae16-4355-a1cc-a73d0b8abc43\",\"type\":\"36e9bde9-2e94-4b91-8b9f-b1078296e3ad\"}],\"errCode\":0,\"success\":true}";


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 31

              
    private static final Feature[] EMPTY_SERIALIZER_FEATURES = new Feature[0];

    private String jsonData = "{\"result\":[{\"id\":0,\"startDate\":1420041600000,\"name\":\"集团\",\"abbr\":\"集团\",\"endDate\":253402185600000,\"type\":\"1317967b-4a83-442c-a7b4-1ac9e7bf84d9\"},{\"id\":0,\"startDate\":1420041600000,\"name\":\"集团总裁办\",\"abbr\":\"集团总裁办\",\"endDate\":253402185600000,\"pcode\":\"4aa2817e-ae16-4355-a1cc-a73d0b8abc43\",\"type\":\"36e9bde9-2e94-4b91-8b9f-b1078296e3ad\"}],\"errCode\":0,\"success\":true}";

    private Type mType1;//MyResponse
    private Type mType;//MyResponse<List<Dept>>

    ParserConfig config = ParserConfig.getGlobalInstance();

            

Reported by PMD.

Private field 'jsonData' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 31

              
    private static final Feature[] EMPTY_SERIALIZER_FEATURES = new Feature[0];

    private String jsonData = "{\"result\":[{\"id\":0,\"startDate\":1420041600000,\"name\":\"集团\",\"abbr\":\"集团\",\"endDate\":253402185600000,\"type\":\"1317967b-4a83-442c-a7b4-1ac9e7bf84d9\"},{\"id\":0,\"startDate\":1420041600000,\"name\":\"集团总裁办\",\"abbr\":\"集团总裁办\",\"endDate\":253402185600000,\"pcode\":\"4aa2817e-ae16-4355-a1cc-a73d0b8abc43\",\"type\":\"36e9bde9-2e94-4b91-8b9f-b1078296e3ad\"}],\"errCode\":0,\"success\":true}";

    private Type mType1;//MyResponse
    private Type mType;//MyResponse<List<Dept>>

    ParserConfig config = ParserConfig.getGlobalInstance();

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 33

              
    private String jsonData = "{\"result\":[{\"id\":0,\"startDate\":1420041600000,\"name\":\"集团\",\"abbr\":\"集团\",\"endDate\":253402185600000,\"type\":\"1317967b-4a83-442c-a7b4-1ac9e7bf84d9\"},{\"id\":0,\"startDate\":1420041600000,\"name\":\"集团总裁办\",\"abbr\":\"集团总裁办\",\"endDate\":253402185600000,\"pcode\":\"4aa2817e-ae16-4355-a1cc-a73d0b8abc43\",\"type\":\"36e9bde9-2e94-4b91-8b9f-b1078296e3ad\"}],\"errCode\":0,\"success\":true}";

    private Type mType1;//MyResponse
    private Type mType;//MyResponse<List<Dept>>

    ParserConfig config = ParserConfig.getGlobalInstance();
    ParserConfig configBug569 = new ParserConfigBug569();//这个是包含bug的代码


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 34

                  private String jsonData = "{\"result\":[{\"id\":0,\"startDate\":1420041600000,\"name\":\"集团\",\"abbr\":\"集团\",\"endDate\":253402185600000,\"type\":\"1317967b-4a83-442c-a7b4-1ac9e7bf84d9\"},{\"id\":0,\"startDate\":1420041600000,\"name\":\"集团总裁办\",\"abbr\":\"集团总裁办\",\"endDate\":253402185600000,\"pcode\":\"4aa2817e-ae16-4355-a1cc-a73d0b8abc43\",\"type\":\"36e9bde9-2e94-4b91-8b9f-b1078296e3ad\"}],\"errCode\":0,\"success\":true}";

    private Type mType1;//MyResponse
    private Type mType;//MyResponse<List<Dept>>

    ParserConfig config = ParserConfig.getGlobalInstance();
    ParserConfig configBug569 = new ParserConfigBug569();//这个是包含bug的代码

    @Before

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 36

                  private Type mType1;//MyResponse
    private Type mType;//MyResponse<List<Dept>>

    ParserConfig config = ParserConfig.getGlobalInstance();
    ParserConfig configBug569 = new ParserConfigBug569();//这个是包含bug的代码

    @Before
    public void init() {
        mType = new TypeReference<MyResponse<List<Dept>>>() {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 37

                  private Type mType;//MyResponse<List<Dept>>

    ParserConfig config = ParserConfig.getGlobalInstance();
    ParserConfig configBug569 = new ParserConfigBug569();//这个是包含bug的代码

    @Before
    public void init() {
        mType = new TypeReference<MyResponse<List<Dept>>>() {
        }.getType();

            

Reported by PMD.

Avoid unused local variables such as 'resp1'.
Design

Line: 51

                  @Test
    public void testBug569() {
        //第一次反序列化是使用的 MyResponse, 没有指定泛型类型,貌似会缓存 MyResponse, 后面在调用的MyResponse<?>反序列化就受影响了
        MyResponse resp1 = JSON.parseObject(jsonData, mType1, configBug569, featureValues,
                features != null ? features : EMPTY_SERIALIZER_FEATURES);

        //expect MyResponse<JSONArray<JSONObject>>
        MyResponse resp = JSON.parseObject(jsonData, mType, configBug569, featureValues,
                features != null ? features : EMPTY_SERIALIZER_FEATURES);

            

Reported by PMD.

src/test/java/com/alibaba/json/test/SymbolTableDupTest.java
20 issues
System.out.println is used
Design

Line: 81

                  private void test3(char[] chars) {
        int hash = SymbolTable.hash(chars, 0, chars.length);
        if (hash == VALUE) {
            System.out.println(new String(chars));
        }
    }

    private void test2(char[] chars) {
        int hash = SymbolTable.hash(chars, 0, chars.length);

            

Reported by PMD.

Private field 'map' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 15

              
public class SymbolTableDupTest extends TestCase {

    private HashMap<Integer, Integer>      map          = new HashMap<Integer, Integer>();
    private Set<Integer>                   dupHashCodes = new HashSet<Integer>();
    private HashMap<Integer, List<String>> dupList      = new HashMap<Integer, List<String>>();

    private final int                      VALUE        = 114788;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 15

              
public class SymbolTableDupTest extends TestCase {

    private HashMap<Integer, Integer>      map          = new HashMap<Integer, Integer>();
    private Set<Integer>                   dupHashCodes = new HashSet<Integer>();
    private HashMap<Integer, List<String>> dupList      = new HashMap<Integer, List<String>>();

    private final int                      VALUE        = 114788;


            

Reported by PMD.

Avoid using implementation types like 'HashMap'; use the interface instead
Design

Line: 15

              
public class SymbolTableDupTest extends TestCase {

    private HashMap<Integer, Integer>      map          = new HashMap<Integer, Integer>();
    private Set<Integer>                   dupHashCodes = new HashSet<Integer>();
    private HashMap<Integer, List<String>> dupList      = new HashMap<Integer, List<String>>();

    private final int                      VALUE        = 114788;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 16

              public class SymbolTableDupTest extends TestCase {

    private HashMap<Integer, Integer>      map          = new HashMap<Integer, Integer>();
    private Set<Integer>                   dupHashCodes = new HashSet<Integer>();
    private HashMap<Integer, List<String>> dupList      = new HashMap<Integer, List<String>>();

    private final int                      VALUE        = 114788;

    public void test_0() throws Exception {

            

Reported by PMD.

Private field 'dupHashCodes' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 16

              public class SymbolTableDupTest extends TestCase {

    private HashMap<Integer, Integer>      map          = new HashMap<Integer, Integer>();
    private Set<Integer>                   dupHashCodes = new HashSet<Integer>();
    private HashMap<Integer, List<String>> dupList      = new HashMap<Integer, List<String>>();

    private final int                      VALUE        = 114788;

    public void test_0() throws Exception {

            

Reported by PMD.

Avoid using implementation types like 'HashMap'; use the interface instead
Design

Line: 17

              
    private HashMap<Integer, Integer>      map          = new HashMap<Integer, Integer>();
    private Set<Integer>                   dupHashCodes = new HashSet<Integer>();
    private HashMap<Integer, List<String>> dupList      = new HashMap<Integer, List<String>>();

    private final int                      VALUE        = 114788;

    public void test_0() throws Exception {
        int len = 3;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 17

              
    private HashMap<Integer, Integer>      map          = new HashMap<Integer, Integer>();
    private Set<Integer>                   dupHashCodes = new HashSet<Integer>();
    private HashMap<Integer, List<String>> dupList      = new HashMap<Integer, List<String>>();

    private final int                      VALUE        = 114788;

    public void test_0() throws Exception {
        int len = 3;

            

Reported by PMD.

Private field 'dupList' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 17

              
    private HashMap<Integer, Integer>      map          = new HashMap<Integer, Integer>();
    private Set<Integer>                   dupHashCodes = new HashSet<Integer>();
    private HashMap<Integer, List<String>> dupList      = new HashMap<Integer, List<String>>();

    private final int                      VALUE        = 114788;

    public void test_0() throws Exception {
        int len = 3;

            

Reported by PMD.

This final field could be made static
Design

Line: 19

                  private Set<Integer>                   dupHashCodes = new HashSet<Integer>();
    private HashMap<Integer, List<String>> dupList      = new HashMap<Integer, List<String>>();

    private final int                      VALUE        = 114788;

    public void test_0() throws Exception {
        int len = 3;
        char[] chars = new char[len];
        tryBit(chars, len);

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1500/Issue1570.java
20 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 10

              import java.util.List;

public class Issue1570 extends TestCase {
    public void test_for_issue() throws Exception {
        Model model = new Model();
        assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
        assertEquals("{\"value\":\"\"}", JSON.toJSONString(model, SerializerFeature.WriteNullStringAsEmpty));
    }


            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 10

              import java.util.List;

public class Issue1570 extends TestCase {
    public void test_for_issue() throws Exception {
        Model model = new Model();
        assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
        assertEquals("{\"value\":\"\"}", JSON.toJSONString(model, SerializerFeature.WriteNullStringAsEmpty));
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 12

              public class Issue1570 extends TestCase {
    public void test_for_issue() throws Exception {
        Model model = new Model();
        assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
        assertEquals("{\"value\":\"\"}", JSON.toJSONString(model, SerializerFeature.WriteNullStringAsEmpty));
    }

    public void test_for_issue_int() throws Exception {
        ModelInt model = new ModelInt();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 13

                  public void test_for_issue() throws Exception {
        Model model = new Model();
        assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
        assertEquals("{\"value\":\"\"}", JSON.toJSONString(model, SerializerFeature.WriteNullStringAsEmpty));
    }

    public void test_for_issue_int() throws Exception {
        ModelInt model = new ModelInt();
        assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 16

                      assertEquals("{\"value\":\"\"}", JSON.toJSONString(model, SerializerFeature.WriteNullStringAsEmpty));
    }

    public void test_for_issue_int() throws Exception {
        ModelInt model = new ModelInt();
        assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
        assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
    }


            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 16

                      assertEquals("{\"value\":\"\"}", JSON.toJSONString(model, SerializerFeature.WriteNullStringAsEmpty));
    }

    public void test_for_issue_int() throws Exception {
        ModelInt model = new ModelInt();
        assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
        assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

              
    public void test_for_issue_int() throws Exception {
        ModelInt model = new ModelInt();
        assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
        assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
    }

    public void test_for_issue_long() throws Exception {
        ModelLong model = new ModelLong();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                  public void test_for_issue_int() throws Exception {
        ModelInt model = new ModelInt();
        assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
        assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
    }

    public void test_for_issue_long() throws Exception {
        ModelLong model = new ModelLong();
        assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 22

                      assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
    }

    public void test_for_issue_long() throws Exception {
        ModelLong model = new ModelLong();
        assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
        assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
    }


            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 22

                      assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
    }

    public void test_for_issue_long() throws Exception {
        ModelLong model = new ModelLong();
        assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
        assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
    }


            

Reported by PMD.

src/test/java/com/alibaba/json/test/codec/Jackson2Codec.java
20 issues
Avoid throwing raw exception types.
Design

Line: 28

                      try {
            return mapper.readValue(text, clazz);
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    }
    

    public <T> T decodeObject(byte[] input, Class<T> clazz) throws Exception {

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 37

                      try {
            return mapper.readValue(input, clazz);
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    }

    public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {
        try {

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 46

                          return (Collection<T>) mapper.readValue(text, new TypeReference<T>() {
            });
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    }

    public final Object decodeObject(String text) {
        try {

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 54

                      try {
            return (ObjectNode) mapper.readTree(text);
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    }

    public Object decode(String text) {
        try {

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 62

                      try {
            return mapper.readTree(text);
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    }

    public String encode(Object object) throws Exception {
        return mapper.writeValueAsString(object);

            

Reported by PMD.

Private field 'mapper' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 18

              
public class Jackson2Codec implements Codec {

    private ObjectMapper mapper = new ObjectMapper();

    public String getName() {
        return "jackson2";
    }


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 18

              
public class Jackson2Codec implements Codec {

    private ObjectMapper mapper = new ObjectMapper();

    public String getName() {
        return "jackson2";
    }


            

Reported by PMD.

Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
Design

Line: 27

                  public final <T> T decodeObject(String text, Class<T> clazz) {
        try {
            return mapper.readValue(text, clazz);
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    }
    


            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 33

                  }
    

    public <T> T decodeObject(byte[] input, Class<T> clazz) throws Exception {
        try {
            return mapper.readValue(input, clazz);
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage(), e);
        }

            

Reported by PMD.

Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
Design

Line: 36

                  public <T> T decodeObject(byte[] input, Class<T> clazz) throws Exception {
        try {
            return mapper.readValue(input, clazz);
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    }

    public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {

            

Reported by PMD.