The following issues were found

src/test/java/com/alibaba/json/bvt/parser/deser/stream/ReaderLongFieldTest.java
16 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: 16

              
public class ReaderLongFieldTest extends TestCase {

    public void test_long_error_0() throws Exception {
        Exception error = null;
        try {
            JSONReader reader = new JSONReader(new StringReader("{\"value\":1.A}"));
            reader.readObject(Model.class);
        } catch (JSONException ex) {

            

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: 27

                      Assert.assertNotNull(error);
    }

    public void test_long_error_1() throws Exception {
        Exception error = null;
        try {
            JSONReader reader = new JSONReader(new StringReader("{\"value\":9223372036854775808}"));
            reader.readObject(Model.class);
        } catch (JSONException ex) {

            

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: 38

                      Assert.assertNotNull(error);
    }
    
    public void test_long_error_1_x() throws Exception {
        Exception error = null;
        try {
            JSONReader reader = new JSONReader(new StringReader("{\"value\":922337203685477580892233720368547758088}"));
            reader.readObject(Model.class);
        } catch (JSONException ex) {

            

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: 49

                      Assert.assertNotNull(error);
    }

    public void test_long_error_2() throws Exception {
        Exception error = null;
        try {
            JSONReader reader = new JSONReader(new StringReader("{\"value\":AA}"));
            reader.readObject(Model.class);
        } catch (JSONException ex) {

            

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: 60

                      Assert.assertNotNull(error);
    }

    public void test_long_normal() throws Exception {
        JSONReader reader = new JSONReader(new StringReader("{\"value\":1001,\"value2\":-2001}"));
        Model model = reader.readObject(Model.class);
        Assert.assertEquals(1001L, model.value);
        Assert.assertEquals(-2001L, model.value2);
        reader.close();

            

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: 68

                      reader.close();
    }

    public void test_long_normal_2() throws Exception {
        JSONReader reader = new JSONReader(new StringReader("{\"model\":{\"value\":3001,\"value2\":-4001}}"));
        Map<String, Model> map = reader.readObject(new TypeReference<Map<String, Model>>() {
        });
        Model model = map.get("model");
        Assert.assertEquals(3001L, model.value);

            

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: 78

                      reader.close();
    }

    public void test_long_error_map() throws Exception {
        Exception error = null;
        try {
            JSONReader reader = new JSONReader(new StringReader("{\"model\":{\"value\":3001,\"value2\":-4001}["));
            reader.readObject(new TypeReference<Map<String, Model>>() {
            });

            

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: 90

                      Assert.assertNotNull(error);
    }

    public void test_long_error_end() throws Exception {
        Exception error = null;
        try {
            JSONReader reader = new JSONReader(new StringReader("{\"value\":1001,\"value2\":-2001["));
            reader.readObject(Model.class);
        } catch (JSONException ex) {

            

Reported by PMD.

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

Line: 103

              
    private static class Model {

        public long value;
        public long value2;
    }
}

            

Reported by PMD.

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

Line: 104

                  private static class Model {

        public long value;
        public long value2;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/test/performance/DecoderPerformanceTest.java
16 issues
System.out.println is used
Design

Line: 52

                              decode(text, decoder);
                // decodeToJavaBean(text, decoder);
            }
            System.out.println();
        }
        System.out.println();
        System.out.println(text);
    }


            

Reported by PMD.

System.out.println is used
Design

Line: 54

                          }
            System.out.println();
        }
        System.out.println();
        System.out.println(text);
    }

    private void decode(String text, Codec decoder) throws Exception {
        long startNano = System.nanoTime();

            

Reported by PMD.

System.out.println is used
Design

Line: 55

                          System.out.println();
        }
        System.out.println();
        System.out.println(text);
    }

    private void decode(String text, Codec decoder) throws Exception {
        long startNano = System.nanoTime();
        for (int i = 0; i < COUNT; ++i) {

            

Reported by PMD.

System.out.println is used
Design

Line: 64

                          decoder.decode(text);
        }
        long nano = System.nanoTime() - startNano;
        System.out.println(decoder.getName() + " : \t" + NumberFormat.getInstance().format(nano));
    }

    public static class Person {

        private String     name;

            

Reported by PMD.

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

Line: 20

              
public class DecoderPerformanceTest extends TestCase {

    final int      COUNT = 1000 * 100;
    private String text;

    protected void setUp() throws Exception {
        text = "{\"old\":true,\"description\":\"神棍\",\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}";


            

Reported by PMD.

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

Line: 21

              public class DecoderPerformanceTest extends TestCase {

    final int      COUNT = 1000 * 100;
    private String text;

    protected void setUp() throws Exception {
        text = "{\"old\":true,\"description\":\"神棍\",\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}";

        text = "[{\"S\":321061,\"T\":\"GetAttributeResp\"},{\"ERROR\":null,\"TS\":0,\"VAL\":{\"SqlList\":[{\"BatchSizeMax\":0,\"BatchSizeTotal\":0,\"ConcurrentMax\":1,\"DataSource\":\"jdbc:wrap-jdbc:filters=default,encoding:name=ds-offer:jdbc:mysql://100.10.10.10:8066/xxx\",\"EffectedRowCount\":0,\"ErrorCount\":0,\"ExecuteCount\":5,\"FetchRowCount\":5,\"File\":null,\"ID\":2001,\"LastError\":null,\"LastTime\":1292742908178,\"MaxTimespan\":16,\"MaxTimespanOccurTime\":1292742668191,\"Name\":null,\"RunningCount\":0,\"SQL\":\"SELECT @@SQL_MODE\",\"TotalTime\":83}]}}]";

            

Reported by PMD.

JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 23

                  final int      COUNT = 1000 * 100;
    private String text;

    protected void setUp() throws Exception {
        text = "{\"old\":true,\"description\":\"神棍\",\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}";

        text = "[{\"S\":321061,\"T\":\"GetAttributeResp\"},{\"ERROR\":null,\"TS\":0,\"VAL\":{\"SqlList\":[{\"BatchSizeMax\":0,\"BatchSizeTotal\":0,\"ConcurrentMax\":1,\"DataSource\":\"jdbc:wrap-jdbc:filters=default,encoding:name=ds-offer:jdbc:mysql://100.10.10.10:8066/xxx\",\"EffectedRowCount\":0,\"ErrorCount\":0,\"ExecuteCount\":5,\"FetchRowCount\":5,\"File\":null,\"ID\":2001,\"LastError\":null,\"LastTime\":1292742908178,\"MaxTimespan\":16,\"MaxTimespanOccurTime\":1292742668191,\"Name\":null,\"RunningCount\":0,\"SQL\":\"SELECT @@SQL_MODE\",\"TotalTime\":83}]}}]";
        // text =
        // "[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]";

            

Reported by PMD.

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

Line: 36

                      text = "{\"badboy\":true,\"description\":\"神棍敌人姐\",\"name\":\"校长\",\"age\":3,\"birthdate\":1293278091773,\"salary\":123456789.0123}";

        String resource = "json/group.json";
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
        text = IOUtils.toString(is);
        is.close();
    }

    public void test_performance() throws Exception {

            

Reported by PMD.

Ensure that resources like this InputStream object are closed after use
Error

Line: 36

                      text = "{\"badboy\":true,\"description\":\"神棍敌人姐\",\"name\":\"校长\",\"age\":3,\"birthdate\":1293278091773,\"salary\":123456789.0123}";

        String resource = "json/group.json";
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
        text = IOUtils.toString(is);
        is.close();
    }

    public void test_performance() throws Exception {

            

Reported by PMD.

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

Line: 36

                      text = "{\"badboy\":true,\"description\":\"神棍敌人姐\",\"name\":\"校长\",\"age\":3,\"birthdate\":1293278091773,\"salary\":123456789.0123}";

        String resource = "json/group.json";
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
        text = IOUtils.toString(is);
        is.close();
    }

    public void test_performance() throws Exception {

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/serializer/CollectionCodec.java
16 issues
The class 'CollectionCodec' has a Modified Cyclomatic Complexity of 6 (Highest = 13).
Design

Line: 33

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public class CollectionCodec implements ObjectSerializer, ObjectDeserializer {

    public final static CollectionCodec instance = new CollectionCodec();

    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
        SerializeWriter out = serializer.out;

            

Reported by PMD.

The class 'CollectionCodec' has a Standard Cyclomatic Complexity of 6 (Highest = 13).
Design

Line: 33

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public class CollectionCodec implements ObjectSerializer, ObjectDeserializer {

    public final static CollectionCodec instance = new CollectionCodec();

    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
        SerializeWriter out = serializer.out;

            

Reported by PMD.

The method 'write' has a Standard Cyclomatic Complexity of 13.
Design

Line: 37

              
    public final static CollectionCodec instance = new CollectionCodec();

    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
        SerializeWriter out = serializer.out;

        if (object == null) {
            out.writeNull(SerializerFeature.WriteNullListAsEmpty);
            return;

            

Reported by PMD.

The method 'write(JSONSerializer, Object, Object, Type, int)' has an NPath complexity of 1776, current threshold is 200
Design

Line: 37

              
    public final static CollectionCodec instance = new CollectionCodec();

    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
        SerializeWriter out = serializer.out;

        if (object == null) {
            out.writeNull(SerializerFeature.WriteNullListAsEmpty);
            return;

            

Reported by PMD.

The method 'write(JSONSerializer, Object, Object, Type, int)' has a cyclomatic complexity of 15.
Design

Line: 37

              
    public final static CollectionCodec instance = new CollectionCodec();

    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
        SerializeWriter out = serializer.out;

        if (object == null) {
            out.writeNull(SerializerFeature.WriteNullListAsEmpty);
            return;

            

Reported by PMD.

The method 'write' has a Modified Cyclomatic Complexity of 13.
Design

Line: 37

              
    public final static CollectionCodec instance = new CollectionCodec();

    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
        SerializeWriter out = serializer.out;

        if (object == null) {
            out.writeNull(SerializerFeature.WriteNullListAsEmpty);
            return;

            

Reported by PMD.

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

Line: 46

                      }

        Type elementType = null;
        if (out.isEnabled(SerializerFeature.WriteClassName)
                || SerializerFeature.isEnabled(features, SerializerFeature.WriteClassName))
        {
            elementType = TypeUtils.getCollectionItemType(fieldType);
        }


            

Reported by PMD.

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

Line: 57

                      SerialContext context = serializer.context;
        serializer.setContext(context, object, fieldName, 0);

        if (out.isEnabled(SerializerFeature.WriteClassName)) {
            if (HashSet.class.isAssignableFrom(collection.getClass())) {
                out.append("Set");
            } else if (TreeSet.class == collection.getClass()) {
                out.append("TreeSet");
            }

            

Reported by PMD.

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

Line: 58

                      serializer.setContext(context, object, fieldName, 0);

        if (out.isEnabled(SerializerFeature.WriteClassName)) {
            if (HashSet.class.isAssignableFrom(collection.getClass())) {
                out.append("Set");
            } else if (TreeSet.class == collection.getClass()) {
                out.append("TreeSet");
            }
        }

            

Reported by PMD.

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

Line: 60

                      if (out.isEnabled(SerializerFeature.WriteClassName)) {
            if (HashSet.class.isAssignableFrom(collection.getClass())) {
                out.append("Set");
            } else if (TreeSet.class == collection.getClass()) {
                out.append("TreeSet");
            }
        }

        try {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/list/ListStringFieldTest_dom_array.java
16 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 ListStringFieldTest_dom_array extends TestCase {

    public void test_list() throws Exception {
        String text = "[[\"a\",null,\"b\",\"ab\\\\c\"],[]]";

        Model model = JSON.parseObject(text, Model.class);
        Assert.assertEquals(4, model.values.size());
        Assert.assertEquals("a", model.values.get(0));

            

Reported by PMD.

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

Line: 19

                      String text = "[[\"a\",null,\"b\",\"ab\\\\c\"],[]]";

        Model model = JSON.parseObject(text, Model.class);
        Assert.assertEquals(4, model.values.size());
        Assert.assertEquals("a", model.values.get(0));
        Assert.assertEquals(null, model.values.get(1));
        Assert.assertEquals("b", model.values.get(2));
        Assert.assertEquals("ab\\c", model.values.get(3));


            

Reported by PMD.

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

Line: 20

              
        Model model = JSON.parseObject(text, Model.class);
        Assert.assertEquals(4, model.values.size());
        Assert.assertEquals("a", model.values.get(0));
        Assert.assertEquals(null, model.values.get(1));
        Assert.assertEquals("b", model.values.get(2));
        Assert.assertEquals("ab\\c", model.values.get(3));

        Assert.assertEquals(0, model.values2.size());

            

Reported by PMD.

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

Line: 21

                      Model model = JSON.parseObject(text, Model.class);
        Assert.assertEquals(4, model.values.size());
        Assert.assertEquals("a", model.values.get(0));
        Assert.assertEquals(null, model.values.get(1));
        Assert.assertEquals("b", model.values.get(2));
        Assert.assertEquals("ab\\c", model.values.get(3));

        Assert.assertEquals(0, model.values2.size());
    }

            

Reported by PMD.

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

Line: 22

                      Assert.assertEquals(4, model.values.size());
        Assert.assertEquals("a", model.values.get(0));
        Assert.assertEquals(null, model.values.get(1));
        Assert.assertEquals("b", model.values.get(2));
        Assert.assertEquals("ab\\c", model.values.get(3));

        Assert.assertEquals(0, model.values2.size());
    }


            

Reported by PMD.

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

Line: 23

                      Assert.assertEquals("a", model.values.get(0));
        Assert.assertEquals(null, model.values.get(1));
        Assert.assertEquals("b", model.values.get(2));
        Assert.assertEquals("ab\\c", model.values.get(3));

        Assert.assertEquals(0, model.values2.size());
    }

    public void test_list2() throws Exception {

            

Reported by PMD.

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

Line: 25

                      Assert.assertEquals("b", model.values.get(2));
        Assert.assertEquals("ab\\c", model.values.get(3));

        Assert.assertEquals(0, model.values2.size());
    }

    public void test_list2() throws Exception {
        String text = "{\"values\":[\"a\",null,\"b\",\"ab\\\\c\"],\"values2\":[]}";


            

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

                      Assert.assertEquals(0, model.values2.size());
    }

    public void test_list2() throws Exception {
        String text = "{\"values\":[\"a\",null,\"b\",\"ab\\\\c\"],\"values2\":[]}";

        Model model = JSON.parseObject(text, Model.class);
        Assert.assertEquals(4, model.values.size());
        Assert.assertEquals("a", model.values.get(0));

            

Reported by PMD.

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

Line: 32

                      String text = "{\"values\":[\"a\",null,\"b\",\"ab\\\\c\"],\"values2\":[]}";

        Model model = JSON.parseObject(text, Model.class);
        Assert.assertEquals(4, model.values.size());
        Assert.assertEquals("a", model.values.get(0));
        Assert.assertEquals(null, model.values.get(1));
        Assert.assertEquals("b", model.values.get(2));
        Assert.assertEquals("ab\\c", model.values.get(3));


            

Reported by PMD.

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

Line: 33

              
        Model model = JSON.parseObject(text, Model.class);
        Assert.assertEquals(4, model.values.size());
        Assert.assertEquals("a", model.values.get(0));
        Assert.assertEquals(null, model.values.get(1));
        Assert.assertEquals("b", model.values.get(2));
        Assert.assertEquals("ab\\c", model.values.get(3));

        Assert.assertEquals(0, model.values2.size());

            

Reported by PMD.

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

Line: 13

              
    @SuppressWarnings( "unused" )
    static class BaseClass {
        private String a;
        private String b;

        protected BaseClass() {
        }


            

Reported by PMD.

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

Line: 14

                  @SuppressWarnings( "unused" )
    static class BaseClass {
        private String a;
        private String b;

        protected BaseClass() {
        }

        public BaseClass( String a,String b ) {

            

Reported by PMD.

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

Line: 31

                  }

    static class BaseClass2 {
        private String a;
        private String b;

        protected BaseClass2() {
        }


            

Reported by PMD.

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

Line: 32

              
    static class BaseClass2 {
        private String a;
        private String b;

        protected BaseClass2() {
        }

        public BaseClass2( String a,String b ) {

            

Reported by PMD.

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

Line: 62

                      abstract String takeA();
    }

    public void test() throws Exception{
        BaseClass bean = new BaseClass( "a1", "b2" );

        String jsonString = JSON.toJSONString( bean );
        JSONObject result = JSON.parseObject( jsonString );
        assertEquals( 1, result.size() );

            

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: 62

                      abstract String takeA();
    }

    public void test() throws Exception{
        BaseClass bean = new BaseClass( "a1", "b2" );

        String jsonString = JSON.toJSONString( bean );
        JSONObject result = JSON.parseObject( jsonString );
        assertEquals( 1, result.size() );

            

Reported by PMD.

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

Line: 67

              
        String jsonString = JSON.toJSONString( bean );
        JSONObject result = JSON.parseObject( jsonString );
        assertEquals( 1, result.size() );
        assertEquals( "b2", result.get( "b" ) );

        BaseClass2 bean2 = new BaseClass2( "a1", "b2" );
        JSON.addMixInAnnotations( BaseClass2.class, MixIn.class );
        jsonString = JSON.toJSONString( bean2 );

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 67

              
        String jsonString = JSON.toJSONString( bean );
        JSONObject result = JSON.parseObject( jsonString );
        assertEquals( 1, result.size() );
        assertEquals( "b2", result.get( "b" ) );

        BaseClass2 bean2 = new BaseClass2( "a1", "b2" );
        JSON.addMixInAnnotations( BaseClass2.class, MixIn.class );
        jsonString = JSON.toJSONString( bean2 );

            

Reported by PMD.

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

Line: 68

                      String jsonString = JSON.toJSONString( bean );
        JSONObject result = JSON.parseObject( jsonString );
        assertEquals( 1, result.size() );
        assertEquals( "b2", result.get( "b" ) );

        BaseClass2 bean2 = new BaseClass2( "a1", "b2" );
        JSON.addMixInAnnotations( BaseClass2.class, MixIn.class );
        jsonString = JSON.toJSONString( bean2 );
        result = JSON.parseObject( jsonString );

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 68

                      String jsonString = JSON.toJSONString( bean );
        JSONObject result = JSON.parseObject( jsonString );
        assertEquals( 1, result.size() );
        assertEquals( "b2", result.get( "b" ) );

        BaseClass2 bean2 = new BaseClass2( "a1", "b2" );
        JSON.addMixInAnnotations( BaseClass2.class, MixIn.class );
        jsonString = JSON.toJSONString( bean2 );
        result = JSON.parseObject( jsonString );

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/asm/Item.java
16 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 42

                  /**
     * Index of this item in the constant pool.
     */
    int    index;

    int    type;

    /**
     * Value of this item, for an integer item.

            

Reported by PMD.

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

Line: 44

                   */
    int    index;

    int    type;

    /**
     * Value of this item, for an integer item.
     */
    int    intVal;

            

Reported by PMD.

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

Line: 49

                  /**
     * Value of this item, for an integer item.
     */
    int    intVal;

    /**
     * Value of this item, for a long item.
     */
    long   longVal;

            

Reported by PMD.

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

Line: 54

                  /**
     * Value of this item, for a long item.
     */
    long   longVal;

    /**
     * First part of the value of this item, for items that do not hold a primitive value.
     */
    String strVal1;

            

Reported by PMD.

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

Line: 59

                  /**
     * First part of the value of this item, for items that do not hold a primitive value.
     */
    String strVal1;

    /**
     * Second part of the value of this item, for items that do not hold a primitive value.
     */
    String strVal2;

            

Reported by PMD.

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

Line: 64

                  /**
     * Second part of the value of this item, for items that do not hold a primitive value.
     */
    String strVal2;

    /**
     * Third part of the value of this item, for items that do not hold a primitive value.
     */
    String strVal3;

            

Reported by PMD.

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

Line: 69

                  /**
     * Third part of the value of this item, for items that do not hold a primitive value.
     */
    String strVal3;

    /**
     * The hash code value of this constant pool item.
     */
    int    hashCode;

            

Reported by PMD.

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

Line: 74

                  /**
     * The hash code value of this constant pool item.
     */
    int    hashCode;

    /**
     * Link to another constant pool item, used for collision lists in the constant pool's hash table.
     */
    Item   next;

            

Reported by PMD.

A switch statement does not contain a break
Error

Line: 117

                      this.strVal1 = strVal1;
        this.strVal2 = strVal2;
        this.strVal3 = strVal3;
        switch (type) {
            case 1 /* ClassWriter.UTF8 */:
            case 8 /* ClassWriter.STR */:
            case 7 /* ClassWriter.CLASS */:
            case 13 /* ClassWriter.TYPE_NORMAL */:
                hashCode = 0x7FFFFFFF & (type + strVal1.hashCode());

            

Reported by PMD.

The method 'isEqualTo(Item)' has a cyclomatic complexity of 11.
Design

Line: 153

                   * @param i the item to be compared to this one. Both items must have the same {@link #type}.
     * @return <tt>true</tt> if the given item if equal to this one, <tt>false</tt> otherwise.
     */
    boolean isEqualTo(final Item i) {
        switch (type) {
            case 1 /* ClassWriter.UTF8 */:
            case 8 /* ClassWriter.STR */:
            case 7 /* ClassWriter.CLASS */ :
            case 13 /* ClassWriter.TYPE_NORMAL */ :

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/date/CalendarTest.java
16 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

              
public class CalendarTest extends TestCase {

    public void test_null() throws Exception {
        String text = "{\"calendar\":null}";
        
        VO vo = JSON.parseObject(text, VO.class);
        Assert.assertNull(vo.getCalendar());
    }

            

Reported by PMD.

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

Line: 18

                      String text = "{\"calendar\":null}";
        
        VO vo = JSON.parseObject(text, VO.class);
        Assert.assertNull(vo.getCalendar());
    }
    
    public void test_codec() throws Exception {
        Calendar calendar = Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale);
        VO vo = new VO();

            

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: 21

                      Assert.assertNull(vo.getCalendar());
    }
    
    public void test_codec() throws Exception {
        Calendar calendar = Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale);
        VO vo = new VO();
        vo.setCalendar(calendar);
        String text = JSON.toJSONString(vo);
        

            

Reported by PMD.

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

Line: 28

                      String text = JSON.toJSONString(vo);
        
        VO vo2 = JSON.parseObject(text, VO.class);
        Assert.assertEquals(vo.getCalendar().getTimeInMillis(), vo2.getCalendar().getTimeInMillis());
    }
    
    public void test_codec_iso88591() throws Exception {
        Calendar calendar = Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale);
        VO vo = new VO();

            

Reported by PMD.

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

Line: 28

                      String text = JSON.toJSONString(vo);
        
        VO vo2 = JSON.parseObject(text, VO.class);
        Assert.assertEquals(vo.getCalendar().getTimeInMillis(), vo2.getCalendar().getTimeInMillis());
    }
    
    public void test_codec_iso88591() throws Exception {
        Calendar calendar = Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale);
        VO vo = new VO();

            

Reported by PMD.

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

Line: 28

                      String text = JSON.toJSONString(vo);
        
        VO vo2 = JSON.parseObject(text, VO.class);
        Assert.assertEquals(vo.getCalendar().getTimeInMillis(), vo2.getCalendar().getTimeInMillis());
    }
    
    public void test_codec_iso88591() throws Exception {
        Calendar calendar = Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale);
        VO vo = new VO();

            

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: 31

                      Assert.assertEquals(vo.getCalendar().getTimeInMillis(), vo2.getCalendar().getTimeInMillis());
    }
    
    public void test_codec_iso88591() throws Exception {
        Calendar calendar = Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale);
        VO vo = new VO();
        vo.setCalendar(calendar);
        String text = JSON.toJSONString(vo, SerializerFeature.UseISO8601DateFormat);
        

            

Reported by PMD.

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

Line: 38

                      String text = JSON.toJSONString(vo, SerializerFeature.UseISO8601DateFormat);
        
        VO vo2 = JSON.parseObject(text, VO.class);
        Assert.assertEquals(vo.getCalendar().getTimeInMillis(), vo2.getCalendar().getTimeInMillis());
    }
    
    public void test_codec_iso88591_2() throws Exception {
        Calendar calendar = Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale);
        calendar.set(Calendar.SECOND, 0);

            

Reported by PMD.

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

Line: 38

                      String text = JSON.toJSONString(vo, SerializerFeature.UseISO8601DateFormat);
        
        VO vo2 = JSON.parseObject(text, VO.class);
        Assert.assertEquals(vo.getCalendar().getTimeInMillis(), vo2.getCalendar().getTimeInMillis());
    }
    
    public void test_codec_iso88591_2() throws Exception {
        Calendar calendar = Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale);
        calendar.set(Calendar.SECOND, 0);

            

Reported by PMD.

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

Line: 38

                      String text = JSON.toJSONString(vo, SerializerFeature.UseISO8601DateFormat);
        
        VO vo2 = JSON.parseObject(text, VO.class);
        Assert.assertEquals(vo.getCalendar().getTimeInMillis(), vo2.getCalendar().getTimeInMillis());
    }
    
    public void test_codec_iso88591_2() throws Exception {
        Calendar calendar = Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale);
        calendar.set(Calendar.SECOND, 0);

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/path/JSONPath_9.java
16 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

              
public class JSONPath_9 extends TestCase {

    public void test_paths() throws Exception {
        Model m = new Model();
        m.f0 = 101;
        m.f1 = 102;

        Map<String, Object> paths = JSONPath.paths(m);

            

Reported by PMD.

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

Line: 20

                      m.f1 = 102;

        Map<String, Object> paths = JSONPath.paths(m);
        assertEquals(3, paths.size());
    }

    public void test_paths_1() throws Exception {
        Map map = new HashMap();
        map.put("f0", 1001);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

                      m.f1 = 102;

        Map<String, Object> paths = JSONPath.paths(m);
        assertEquals(3, paths.size());
    }

    public void test_paths_1() throws Exception {
        Map map = new HashMap();
        map.put("f0", 1001);

            

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: 23

                      assertEquals(3, paths.size());
    }

    public void test_paths_1() throws Exception {
        Map map = new HashMap();
        map.put("f0", 1001);
        map.put("f1", 1002);

        Map<String, Object> paths = JSONPath.paths(map);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

                      map.put("f1", 1002);

        Map<String, Object> paths = JSONPath.paths(map);
        assertEquals(3, paths.size());
    }

    public void test_paths_2() throws Exception {
        Map map = new HashMap();
        map.put("f0", 1001);

            

Reported by PMD.

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

Line: 29

                      map.put("f1", 1002);

        Map<String, Object> paths = JSONPath.paths(map);
        assertEquals(3, paths.size());
    }

    public void test_paths_2() throws Exception {
        Map map = new HashMap();
        map.put("f0", 1001);

            

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: 32

                      assertEquals(3, paths.size());
    }

    public void test_paths_2() throws Exception {
        Map map = new HashMap();
        map.put("f0", 1001);
        map.put("f1", 1002);

        JSONPath path = new JSONPath("$.f0");

            

Reported by PMD.

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

Line: 32

                      assertEquals(3, paths.size());
    }

    public void test_paths_2() throws Exception {
        Map map = new HashMap();
        map.put("f0", 1001);
        map.put("f1", 1002);

        JSONPath path = new JSONPath("$.f0");

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 38

                      map.put("f1", 1002);

        JSONPath path = new JSONPath("$.f0");
        assertEquals("$.f0", path.getPath());
        assertEquals(1001, path.eval(map));

        path.remove(null);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 39

              
        JSONPath path = new JSONPath("$.f0");
        assertEquals("$.f0", path.getPath());
        assertEquals(1001, path.eval(map));

        path.remove(null);
    }

    public void test_paths_3() throws Exception {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_zhongyin.java
15 issues
System.out.println is used
Design

Line: 21

                      for (char c = '\u0000'; c < '\u0020'; c++) {
            String s = String.valueOf(c) + "entity";
            String jsons = JSON.toJSONString(new VO(s));
            System.out.println(jsons);
            VO v = JSON.parseObject(jsons, VO.class);
            Assert.assertEquals(s, v.getName());
        }
    }


            

Reported by PMD.

System.out.println is used
Design

Line: 31

                      for (char c = '\u0000'; c < '\u0020'; c++) {
            String s = String.valueOf(c) + "map";
            String jsons = JSON.toJSONString(Collections.singletonMap("value", s));
            System.out.println(jsons);

            JSONObject o = JSON.parseObject(jsons);
            Assert.assertEquals(s, o.getString("value"));
        }
    }

            

Reported by PMD.

System.out.println is used
Design

Line: 45

                      Map <String , Object>map = new HashMap<String, Object>();
        map.put("aaa" , result);
        String stringV = JSON.toJSONString(map);
        System.out.println(stringV);
        JSONObject o = JSON.parseObject(stringV);
        System.out.println(o.getString("aaa"));
        
    }
    

            

Reported by PMD.

System.out.println is used
Design

Line: 47

                      String stringV = JSON.toJSONString(map);
        System.out.println(stringV);
        JSONObject o = JSON.parseObject(stringV);
        System.out.println(o.getString("aaa"));
        
    }
    
    private String getHexStr(String hex) throws UnsupportedEncodingException {
        byte []bytes = new byte[hex.length() / 2];

            

Reported by PMD.

System.out.println is used
Design

Line: 58

                          bytes[i] = (byte)Integer.parseInt(v , 16);
        }
        String str = new String(bytes , "UTF-8");
        System.out.println(str);
        return str;
    }

    public static class VO {


            

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: 17

              
public class Bug_for_zhongyin extends TestCase {

    public void test_entity() throws Exception {
        for (char c = '\u0000'; c < '\u0020'; c++) {
            String s = String.valueOf(c) + "entity";
            String jsons = JSON.toJSONString(new VO(s));
            System.out.println(jsons);
            VO v = JSON.parseObject(jsons, VO.class);

            

Reported by PMD.

No need to call String.valueOf to append to a string.
Performance

Line: 19

              
    public void test_entity() throws Exception {
        for (char c = '\u0000'; c < '\u0020'; c++) {
            String s = String.valueOf(c) + "entity";
            String jsons = JSON.toJSONString(new VO(s));
            System.out.println(jsons);
            VO v = JSON.parseObject(jsons, VO.class);
            Assert.assertEquals(s, v.getName());
        }

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 20

                  public void test_entity() throws Exception {
        for (char c = '\u0000'; c < '\u0020'; c++) {
            String s = String.valueOf(c) + "entity";
            String jsons = JSON.toJSONString(new VO(s));
            System.out.println(jsons);
            VO v = JSON.parseObject(jsons, VO.class);
            Assert.assertEquals(s, v.getName());
        }
    }

            

Reported by PMD.

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

Line: 23

                          String jsons = JSON.toJSONString(new VO(s));
            System.out.println(jsons);
            VO v = JSON.parseObject(jsons, VO.class);
            Assert.assertEquals(s, v.getName());
        }
    }

    public void test_map() throws Exception {
        for (char c = '\u0000'; c < '\u0020'; c++) {

            

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: 27

                      }
    }

    public void test_map() throws Exception {
        for (char c = '\u0000'; c < '\u0020'; c++) {
            String s = String.valueOf(c) + "map";
            String jsons = JSON.toJSONString(Collections.singletonMap("value", s));
            System.out.println(jsons);


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/JSONScannerTest__nextToken.java
15 issues
This class has too many methods, consider refactoring it.
Design

Line: 9

              import com.alibaba.fastjson.parser.JSONScanner;
import com.alibaba.fastjson.parser.JSONToken;

public class JSONScannerTest__nextToken extends TestCase {
    public void test_next() throws Exception {
        String text = "\"aaa\"";
        JSONScanner lexer = new JSONScanner(text);
        lexer.nextToken(JSONToken.LITERAL_INT);
        Assert.assertEquals(JSONToken.LITERAL_STRING, lexer.token());

            

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: 10

              import com.alibaba.fastjson.parser.JSONToken;

public class JSONScannerTest__nextToken extends TestCase {
    public void test_next() throws Exception {
        String text = "\"aaa\"";
        JSONScanner lexer = new JSONScanner(text);
        lexer.nextToken(JSONToken.LITERAL_INT);
        Assert.assertEquals(JSONToken.LITERAL_STRING, lexer.token());
    }

            

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: 17

                      Assert.assertEquals(JSONToken.LITERAL_STRING, lexer.token());
    }
    
    public void test_next_1() throws Exception {
        String text = "[";
        JSONScanner lexer = new JSONScanner(text);
        lexer.nextToken(JSONToken.LITERAL_INT);
        Assert.assertEquals(JSONToken.LBRACKET, lexer.token());
    }

            

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(JSONToken.LBRACKET, lexer.token());
    }
    
    public void test_next_2() throws Exception {
        String text = "{";
        JSONScanner lexer = new JSONScanner(text);
        lexer.nextToken(JSONToken.LITERAL_INT);
        Assert.assertEquals(JSONToken.LBRACE, lexer.token());
    }

            

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: 31

                      Assert.assertEquals(JSONToken.LBRACE, lexer.token());
    }
    
    public void test_next_3() throws Exception {
        String text = "{";
        JSONScanner lexer = new JSONScanner(text);
        lexer.nextToken(JSONToken.LBRACKET);
        Assert.assertEquals(JSONToken.LBRACE, lexer.token());
    }

            

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: 38

                      Assert.assertEquals(JSONToken.LBRACE, lexer.token());
    }
    
    public void test_next_4() throws Exception {
        String text = "";
        JSONScanner lexer = new JSONScanner(text);
        lexer.nextToken(JSONToken.LBRACKET);
        Assert.assertEquals(JSONToken.EOF, lexer.token());
    }

            

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: 45

                      Assert.assertEquals(JSONToken.EOF, lexer.token());
    }
    
    public void test_next_5() throws Exception {
        String text = " \n\r\t\f\b 1";
        JSONScanner lexer = new JSONScanner(text);
        lexer.nextToken(JSONToken.LBRACKET);
        Assert.assertEquals(JSONToken.LITERAL_INT, lexer.token());
    }

            

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: 52

                      Assert.assertEquals(JSONToken.LITERAL_INT, lexer.token());
    }
    
    public void test_next_6() throws Exception {
        String text = "";
        JSONScanner lexer = new JSONScanner(text);
        lexer.nextToken(JSONToken.EOF);
        Assert.assertEquals(JSONToken.EOF, lexer.token());
    }

            

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: 59

                      Assert.assertEquals(JSONToken.EOF, lexer.token());
    }
    
    public void test_next_7() throws Exception {
        String text = "{";
        JSONScanner lexer = new JSONScanner(text);
        lexer.nextToken(JSONToken.EOF);
        Assert.assertEquals(JSONToken.LBRACE, lexer.token());
    }

            

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: 66

                      Assert.assertEquals(JSONToken.LBRACE, lexer.token());
    }
    
    public void test_next_8() throws Exception {
        String text = "\n\r\t\f\b :{";
        JSONScanner lexer = new JSONScanner(text);
        lexer.nextTokenWithColon(JSONToken.LBRACE);
        Assert.assertEquals(JSONToken.LBRACE, lexer.token());
    }

            

Reported by PMD.