The following issues were found

src/test/java/com/alibaba/json/bvt/ArrayListFieldTest.java
5 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

              import com.alibaba.fastjson.serializer.SerializerFeature;

public class ArrayListFieldTest extends TestCase {
    public void test_codec_null() throws Exception {
        V0 v = new V0();

        SerializeConfig mapping = new SerializeConfig();
        mapping.setAsmEnable(false);


            

Reported by PMD.

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

Line: 28

                      
        V0 v1 = JSON.parseObject(text, V0.class, config, JSON.DEFAULT_PARSER_FEATURE);

        Assert.assertEquals(v1.getValue(), v.getValue());
    }

	private static class V0 {

		private ArrayList<Object> value;

            

Reported by PMD.

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

Line: 33

              
	private static class V0 {

		private ArrayList<Object> value;

		public ArrayList<Object> getValue() {
			return value;
		}


            

Reported by PMD.

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

Line: 35

              
		private ArrayList<Object> value;

		public ArrayList<Object> getValue() {
			return value;
		}

		public void setValue(ArrayList<Object> value) {
			this.value = value;

            

Reported by PMD.

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

Line: 39

              			return value;
		}

		public void setValue(ArrayList<Object> value) {
			this.value = value;
		}

	}
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_265.java
5 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: 19

              
public class Bug_for_issue_265 extends TestCase {

    public void test_for_issue() throws Exception {
        User user = new User();
        user.setName("wenshao");
        
        String text = JSON.toJSONString(user);
        

            

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

                      
    }
    
    public void test_for_issue_decode() throws Exception {
        String text = "{\"name\":\"wenshao\",\"id\":1001}";
        
        User user = JSON.parseObject(text, User.class);
        Assert.assertEquals("wenshao", user.getName());
        Assert.assertEquals(1001, user.getAttribute("id"));

            

Reported by PMD.

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

Line: 33

                      String text = "{\"name\":\"wenshao\",\"id\":1001}";
        
        User user = JSON.parseObject(text, User.class);
        Assert.assertEquals("wenshao", user.getName());
        Assert.assertEquals(1001, user.getAttribute("id"));
    }

    public static class Model implements JSONSerializable, ExtraProcessable {


            

Reported by PMD.

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

Line: 34

                      
        User user = JSON.parseObject(text, User.class);
        Assert.assertEquals("wenshao", user.getName());
        Assert.assertEquals(1001, user.getAttribute("id"));
    }

    public static class Model implements JSONSerializable, ExtraProcessable {

        protected Map<String, Object> attributes = new HashMap<String, Object>();

            

Reported by PMD.

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

Line: 39

              
    public static class Model implements JSONSerializable, ExtraProcessable {

        protected Map<String, Object> attributes = new HashMap<String, Object>();

        public Map<String, Object> getAttributes() {
            return attributes;
        }
        

            

Reported by PMD.

src/test/java/com/alibaba/fastjson/deserializer/issues3796/bean/ObjectK1_A.java
5 issues
The class 'ObjectK1_A' is suspected to be a Data Class (WOC=0.000%, NOPA=0, NOAM=8, WMC=8)
Design

Line: 8

              


public class ObjectK1_A {
	
	private int a = 0;
	
	private int b = 0;
	

            

Reported by PMD.

Avoid using redundant field initializer for 'a'
Performance

Line: 10

              
public class ObjectK1_A {
	
	private int a = 0;
	
	private int b = 0;
	
	private int c = 0;
	

            

Reported by PMD.

Avoid using redundant field initializer for 'b'
Performance

Line: 12

              	
	private int a = 0;
	
	private int b = 0;
	
	private int c = 0;
	
	private int d = 0;


            

Reported by PMD.

Avoid using redundant field initializer for 'c'
Performance

Line: 14

              	
	private int b = 0;
	
	private int c = 0;
	
	private int d = 0;

	public int getA() {
		return a;

            

Reported by PMD.

Avoid using redundant field initializer for 'd'
Performance

Line: 16

              	
	private int c = 0;
	
	private int d = 0;

	public int getA() {
		return a;
	}


            

Reported by PMD.

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

Line: 13

                      final String text = "{int1:\"NULL\",int2:\"null\",long1:NULL,long2:null, dou1:\"NULL\",dou2:\"null\",str1:\"NULL\",str2:NULL, bool2:\"NULL\",bool1:null}";
        VO vo = JSON.parseObject(text, VO.class);

        System.out.println(vo);
    }

    public static class VO {

        public int     int1;

            

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

              
public class Bug_for_issue_242 extends TestCase {

    public void test_true() throws Exception {
        final String text = "{int1:\"NULL\",int2:\"null\",long1:NULL,long2:null, dou1:\"NULL\",dou2:\"null\",str1:\"NULL\",str2:NULL, bool2:\"NULL\",bool1:null}";
        VO vo = JSON.parseObject(text, VO.class);

        System.out.println(vo);
    }

            

Reported by PMD.

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

Line: 9

              
public class Bug_for_issue_242 extends TestCase {

    public void test_true() throws Exception {
        final String text = "{int1:\"NULL\",int2:\"null\",long1:NULL,long2:null, dou1:\"NULL\",dou2:\"null\",str1:\"NULL\",str2:NULL, bool2:\"NULL\",bool1:null}";
        VO vo = JSON.parseObject(text, VO.class);

        System.out.println(vo);
    }

            

Reported by PMD.

The class 'VO' is suspected to be a Data Class (WOC=4.545%, NOPA=10, NOAM=20, WMC=22)
Design

Line: 16

                      System.out.println(vo);
    }

    public static class VO {

        public int     int1;
        public int     int2;
        public long    long1;
        public long    long2;

            

Reported by PMD.

StringBuffer constructor is initialized with size 16, but has at least 83 characters appended.
Performance

Line: 34

                      }

        public String toString() {
            StringBuffer sb = new StringBuffer();
            sb.append("int1 = ").append(int1)//
            .append(" int2 = ").append(int2)//
            .append(" long1 = ").append(long1)//
            .append(" long2 = ").append(long2)//
            .append(" dou1 = ").append(dou1)//

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_generic_huansi.java
5 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

               * Created by wenshao on 19/12/2016.
 */
public class Bug_for_generic_huansi extends TestCase {
    public void test_for_issue() throws Exception {
        String jsonStr = "{\"id\": 1234}";

        SimpleGenericObject jsonObj = JSON.parseObject(jsonStr, SimpleGenericObject.class);

        try {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

              
        try {
            Long id = jsonObj.getId();
            assertTrue(id.equals(1234L));
        } catch (Exception e) {
            fail("parse error:" + e.getMessage());
        }
    }


            

Reported by PMD.

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

Line: 17

              
        try {
            Long id = jsonObj.getId();
            assertTrue(id.equals(1234L));
        } catch (Exception e) {
            fail("parse error:" + e.getMessage());
        }
    }


            

Reported by PMD.

Use assertEquals(x, y) instead of assertTrue(x.equals(y))
Design

Line: 17

              
        try {
            Long id = jsonObj.getId();
            assertTrue(id.equals(1234L));
        } catch (Exception e) {
            fail("parse error:" + e.getMessage());
        }
    }


            

Reported by PMD.

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

Line: 18

                      try {
            Long id = jsonObj.getId();
            assertTrue(id.equals(1234L));
        } catch (Exception e) {
            fail("parse error:" + e.getMessage());
        }
    }

    public static class BaseGenericType<T> {

            

Reported by PMD.

src/test/java/com/alibaba/fastjson/deserializer/issues3796/bean/ObjectL1.java
5 issues
The class 'ObjectL1' is suspected to be a Data Class (WOC=0.000%, NOPA=0, NOAM=20, WMC=20)
Design

Line: 10

              import java.util.List;


public class ObjectL1 {
    
    
    List<ObjectL1_A> a;
    
    int b;

            

Reported by PMD.

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

Line: 30

                  
    List<CommonObject> h;

    HashMap<Integer, HashMap<Integer, ObjectL2_C>> i;
    
    boolean j = false;

    public List<ObjectL1_A> getA() {
        return a;

            

Reported by PMD.

Avoid using redundant field initializer for 'j'
Performance

Line: 32

              
    HashMap<Integer, HashMap<Integer, ObjectL2_C>> i;
    
    boolean j = false;

    public List<ObjectL1_A> getA() {
        return a;
    }


            

Reported by PMD.

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

Line: 98

                      this.h = h;
    }

    public HashMap<Integer, HashMap<Integer, ObjectL2_C>> getI() {
        return i;
    }

    public void setI(HashMap<Integer, HashMap<Integer, ObjectL2_C>> i) {
        this.i = i;

            

Reported by PMD.

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

Line: 102

                      return i;
    }

    public void setI(HashMap<Integer, HashMap<Integer, ObjectL2_C>> i) {
        this.i = i;
    }

    public boolean isJ() {
        return j;

            

Reported by PMD.

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

Line: 27

                          text = JSON.toJSONString(tiger, SerializerFeature.WriteClassName);
        }
        
        System.out.println(text);

        HashMap<String, Collection<String>> tigger2 = (HashMap<String, Collection<String>>) JSON.parse(text);
        Assert.assertEquals(1, tigger2.size());
        Assert.assertEquals(2, tigger2.get("老鼠").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: 15

              
public class Bug_for_dubbo1 extends TestCase {

    public void test_0() throws Exception {
        String text;
        {
            HashSet<String> tigers = new HashSet<String>();
            tigers.add("老虎二");
            tigers.add("老虎大");

            

Reported by PMD.

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

Line: 30

                      System.out.println(text);

        HashMap<String, Collection<String>> tigger2 = (HashMap<String, Collection<String>>) JSON.parse(text);
        Assert.assertEquals(1, tigger2.size());
        Assert.assertEquals(2, tigger2.get("老鼠").size());
    }
}

            

Reported by PMD.

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

Line: 31

              
        HashMap<String, Collection<String>> tigger2 = (HashMap<String, Collection<String>>) JSON.parse(text);
        Assert.assertEquals(1, tigger2.size());
        Assert.assertEquals(2, tigger2.get("老鼠").size());
    }
}

            

Reported by PMD.

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

Line: 31

              
        HashMap<String, Collection<String>> tigger2 = (HashMap<String, Collection<String>>) JSON.parse(text);
        Assert.assertEquals(1, tigger2.size());
        Assert.assertEquals(2, tigger2.get("老鼠").size());
    }
}

            

Reported by PMD.

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

Line: 28

                          text = JSON.toJSONString(tiger, SerializerFeature.WriteClassName);
        }
        
        System.out.println(text);

        HashMap<String, Collection<String>> tigger2 = (HashMap<String, Collection<String>>) JSON.parseObject(text, Map.class);
        Assert.assertEquals(1, tigger2.size());
        Assert.assertEquals(2, tigger2.get("老鼠").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: 16

              
public class Bug_for_dubbo3 extends TestCase {

    public void test_0() throws Exception {
        String text;
        {
            HashSet<String> tigers = new HashSet<String>();
            tigers.add("老虎二");
            tigers.add("老虎大");

            

Reported by PMD.

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

Line: 31

                      System.out.println(text);

        HashMap<String, Collection<String>> tigger2 = (HashMap<String, Collection<String>>) JSON.parseObject(text, Map.class);
        Assert.assertEquals(1, tigger2.size());
        Assert.assertEquals(2, tigger2.get("老鼠").size());
    }
}

            

Reported by PMD.

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

Line: 32

              
        HashMap<String, Collection<String>> tigger2 = (HashMap<String, Collection<String>>) JSON.parseObject(text, Map.class);
        Assert.assertEquals(1, tigger2.size());
        Assert.assertEquals(2, tigger2.get("老鼠").size());
    }
}

            

Reported by PMD.

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

Line: 32

              
        HashMap<String, Collection<String>> tigger2 = (HashMap<String, Collection<String>>) JSON.parseObject(text, Map.class);
        Assert.assertEquals(1, tigger2.size());
        Assert.assertEquals(2, tigger2.get("老鼠").size());
    }
}

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/serializer/JSONObjectCodec.java
5 issues
Potential violation of Law of Demeter (method chain calls)
Design

Line: 17

              		MapSerializer mapSerializer = MapSerializer.instance;

		try {
			Field mapField = object.getClass().getDeclaredField("map");
			if (Modifier.isPrivate(mapField.getModifiers())) {
				mapField.setAccessible(true);
			}

			Object map = mapField.get(object);

            

Reported by PMD.

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

Line: 18

              
		try {
			Field mapField = object.getClass().getDeclaredField("map");
			if (Modifier.isPrivate(mapField.getModifiers())) {
				mapField.setAccessible(true);
			}

			Object map = mapField.get(object);
			mapSerializer.write(serializer, map, fieldName, fieldType, features);

            

Reported by PMD.

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

Line: 19

              		try {
			Field mapField = object.getClass().getDeclaredField("map");
			if (Modifier.isPrivate(mapField.getModifiers())) {
				mapField.setAccessible(true);
			}

			Object map = mapField.get(object);
			mapSerializer.write(serializer, map, fieldName, fieldType, features);


            

Reported by PMD.

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

Line: 22

              				mapField.setAccessible(true);
			}

			Object map = mapField.get(object);
			mapSerializer.write(serializer, map, fieldName, fieldType, features);

		} catch (Exception e) {
			out.writeNull();
		}

            

Reported by PMD.

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

Line: 25

              			Object map = mapField.get(object);
			mapSerializer.write(serializer, map, fieldName, fieldType, features);

		} catch (Exception e) {
			out.writeNull();
		}
	}
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/ParseArrayTest.java
5 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

              import com.alibaba.fastjson.JSON;

public class ParseArrayTest extends TestCase {
    public void test_0 () throws Exception {
        List<Object> list = JSON.parseArray("[{}, {}]", new Type[] {TreeMap.class, HashMap.class});
        Assert.assertTrue(list.get(0) instanceof TreeMap);
        Assert.assertTrue(list.get(1) instanceof HashMap);
    }
    

            

Reported by PMD.

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

Line: 15

              
public class ParseArrayTest extends TestCase {
    public void test_0 () throws Exception {
        List<Object> list = JSON.parseArray("[{}, {}]", new Type[] {TreeMap.class, HashMap.class});
        Assert.assertTrue(list.get(0) instanceof TreeMap);
        Assert.assertTrue(list.get(1) instanceof HashMap);
    }
    
    public void test_1 () throws Exception {

            

Reported by PMD.

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

Line: 15

              
public class ParseArrayTest extends TestCase {
    public void test_0 () throws Exception {
        List<Object> list = JSON.parseArray("[{}, {}]", new Type[] {TreeMap.class, HashMap.class});
        Assert.assertTrue(list.get(0) instanceof TreeMap);
        Assert.assertTrue(list.get(1) instanceof HashMap);
    }
    
    public void test_1 () throws Exception {

            

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

                      Assert.assertTrue(list.get(1) instanceof HashMap);
    }
    
    public void test_1 () throws Exception {
        List<Object> list = JSON.parseArray("[1, 2, \"abc\"]", new Type[] {int.class, Integer.class, String.class});
        Assert.assertTrue(list.get(0) instanceof Integer);
        Assert.assertTrue(list.get(1) instanceof Integer);
        Assert.assertTrue(list.get(2) instanceof String);
    }

            

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.assertTrue(list.get(2) instanceof String);
    }
    
    public void test_2 () throws Exception {
        List<Object> list = JSON.parseArray("[1, null, \"abc\"]", new Type[] {int.class, Integer.class, String.class});
        Assert.assertTrue(list.get(0) instanceof Integer);
        Assert.assertTrue(list.get(1) == null);
        Assert.assertTrue(list.get(2) instanceof String);
    }

            

Reported by PMD.