The following issues were found

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

Line: 9

              import java.util.List;


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

            

Reported by PMD.

Avoid using redundant field initializer for 'a'
Performance

Line: 11

              
public class ObjectJ1_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: 13

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

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

            

Reported by PMD.

Avoid using redundant field initializer for 'd'
Performance

Line: 17

              	
	private int c = 0;
	
	private int d = 0;
	
	private int e = 0;
	
	private List<CommonObject> f;
	

            

Reported by PMD.

Avoid using redundant field initializer for 'e'
Performance

Line: 19

              	
	private int d = 0;
	
	private int e = 0;
	
	private List<CommonObject> f;
	
	private List<ObjectJ1_C> g;


            

Reported by PMD.

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

Line: 8

              


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

            

Reported by PMD.

Avoid using redundant field initializer for 'a'
Performance

Line: 10

              
public class ObjectJ1_C {
	
	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;
	
	private boolean e = false;


            

Reported by PMD.

Avoid using redundant field initializer for 'd'
Performance

Line: 16

              	
	private int c = 0;
	
	private int d = 0;
	
	private boolean e = false;

	public int getA() {
		return a;

            

Reported by PMD.

Avoid using redundant field initializer for 'e'
Performance

Line: 18

              	
	private int d = 0;
	
	private boolean e = false;

	public int getA() {
		return a;
	}


            

Reported by PMD.

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

Line: 9

              import java.util.List;


public class ObjectT {
	
	private int a = 0;

	
	private int b = 0;

            

Reported by PMD.

Avoid using redundant field initializer for 'a'
Performance

Line: 11

              
public class ObjectT {
	
	private int a = 0;

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

            

Reported by PMD.

Avoid using redundant field initializer for 'b'
Performance

Line: 14

              	private int a = 0;

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

	
	private List<ObjectT_A> d;

            

Reported by PMD.

Avoid using redundant field initializer for 'c'
Performance

Line: 16

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

	
	private List<ObjectT_A> d;

	

            

Reported by PMD.

Avoid using redundant field initializer for 'e'
Performance

Line: 22

              	private List<ObjectT_A> d;

	
	private int e = 0;

	
	private int f;

	

            

Reported by PMD.

Avoid using redundant field initializer for 'k'
Performance

Line: 40

              	private int j;

	
	private boolean k = false;


	public int getA() {
		return a;
	}

            

Reported by PMD.

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

Line: 10

              import java.util.List;


public class ObjectY {
	
	private List<ObjectY_A> a;

	
	private long b;

            

Reported by PMD.

Avoid using redundant field initializer for 'c'
Performance

Line: 18

              	private long b;

	
	private int c = 0;

	
	private boolean d = false;

	

            

Reported by PMD.

Avoid using redundant field initializer for 'd'
Performance

Line: 21

              	private int c = 0;

	
	private boolean d = false;

	
	private int e = -1;

	

            

Reported by PMD.

Avoid using redundant field initializer for 'f'
Performance

Line: 27

              	private int e = -1;

	
	private int f = 0;

	
	private int g = 0;

	

            

Reported by PMD.

Avoid using redundant field initializer for 'g'
Performance

Line: 30

              	private int f = 0;

	
	private int g = 0;

	

	
	private int h;

            

Reported by PMD.

Avoid using redundant field initializer for 'i'
Performance

Line: 37

              	
	private int h;
	
	private boolean i =false;
	
	private List<Integer> j;
	
	private List<Integer> k;


            

Reported by PMD.

src/test/java/com/alibaba/fastjson/serializer/issue3084/TestRefWithQuote.java
6 issues
It is somewhat confusing to have a field name matching the declaring class name
Error

Line: 15

              public class TestRefWithQuote {

    public static class X {
        private String x;

        public X(String x) {
            this.x = x;
        }


            

Reported by PMD.

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

Line: 40

                      try {
            String json = JSON.toJSONString(origin, true);
            JSONObject root = JSON.parseObject(json);
            assertSame(root.get("bbbb\\"), root.get("aaaa\\"));
        } catch (Exception e) {
            fail("should not fail !!!");
        }
    }
}

            

Reported by PMD.

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

Line: 40

                      try {
            String json = JSON.toJSONString(origin, true);
            JSONObject root = JSON.parseObject(json);
            assertSame(root.get("bbbb\\"), root.get("aaaa\\"));
        } catch (Exception e) {
            fail("should not fail !!!");
        }
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 40

                      try {
            String json = JSON.toJSONString(origin, true);
            JSONObject root = JSON.parseObject(json);
            assertSame(root.get("bbbb\\"), root.get("aaaa\\"));
        } catch (Exception e) {
            fail("should not fail !!!");
        }
    }
}

            

Reported by PMD.

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

Line: 41

                          String json = JSON.toJSONString(origin, true);
            JSONObject root = JSON.parseObject(json);
            assertSame(root.get("bbbb\\"), root.get("aaaa\\"));
        } catch (Exception e) {
            fail("should not fail !!!");
        }
    }
}

            

Reported by PMD.

Avoid unused imports such as 'org.junit.Assert'
Design

Line: 10

              import java.util.HashMap;
import java.util.Map;

import static org.junit.Assert.*;

public class TestRefWithQuote {

    public static class X {
        private String x;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/ArrayListFieldTest_1.java
6 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 ArrayListFieldTest_1 extends TestCase {

    public void test_var() throws Exception {
        JSON.parseObject("{\"value\":[{}]}", V0.class);
        V0<A> v1 = JSON.parseObject("{\"value\":[{}]}", new TypeReference<V0<A>>() {
        });
        Assert.assertTrue(v1.getValue().get(0) instanceof A);
        

            

Reported by PMD.

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

Line: 18

                      JSON.parseObject("{\"value\":[{}]}", V0.class);
        V0<A> v1 = JSON.parseObject("{\"value\":[{}]}", new TypeReference<V0<A>>() {
        });
        Assert.assertTrue(v1.getValue().get(0) instanceof A);
        
        V0<B> v2 = JSON.parseObject("{\"value\":[{}]}", new TypeReference<V0<B>>() {
        });
        Assert.assertTrue(v2.getValue().get(0) instanceof B);
    }

            

Reported by PMD.

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

Line: 22

                      
        V0<B> v2 = JSON.parseObject("{\"value\":[{}]}", new TypeReference<V0<B>>() {
        });
        Assert.assertTrue(v2.getValue().get(0) instanceof B);
    }

    private static class V<T> {

    }

            

Reported by PMD.

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

Line: 31

              
    private static class V0<T> extends V<T> {

        private ArrayList<T> value;

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


            

Reported by PMD.

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

Line: 33

              
        private ArrayList<T> value;

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

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

            

Reported by PMD.

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

Line: 37

                          return value;
        }

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

    public static class A {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/ArrayListFloatFieldTest.java
6 issues
System.out.println is used
Design

Line: 19

                      user.getValue().add(1F);

        String text = JSON.toJSONString(user);
        System.out.println(text);

        User user1 = JSON.parseObject(text, User.class);

        Assert.assertEquals(user.getValue(), user1.getValue());
    }

            

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

              
public class ArrayListFloatFieldTest extends TestCase {

    public void test_codec() throws Exception {
        User user = new User();
        user.setValue(new ArrayList<Float>());
        user.getValue().add(1F);

        String text = JSON.toJSONString(user);

            

Reported by PMD.

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

Line: 16

                  public void test_codec() throws Exception {
        User user = new User();
        user.setValue(new ArrayList<Float>());
        user.getValue().add(1F);

        String text = JSON.toJSONString(user);
        System.out.println(text);

        User user1 = JSON.parseObject(text, User.class);

            

Reported by PMD.

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

Line: 23

              
        User user1 = JSON.parseObject(text, User.class);

        Assert.assertEquals(user.getValue(), user1.getValue());
    }

    public static class User {

        private ArrayList<Float> value;

            

Reported by PMD.

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

Line: 28

              
    public static class User {

        private ArrayList<Float> value;
        
        public User() {
            
        }


            

Reported by PMD.

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

Line: 38

                          return value;
        }

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

    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/BooleanArrayFieldTest.java
6 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: 12

              
public class BooleanArrayFieldTest 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: 23

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

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

    public void test_codec_null_1() throws Exception {
        V0 v = new V0();


            

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

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

    public void test_codec_null_1() throws Exception {
        V0 v = new V0();

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


            

Reported by PMD.

Returning 'value' may expose an internal array.
Design

Line: 41

                      private Boolean[] value;

        public Boolean[] getValue() {
            return value;
        }

        public void setValue(Boolean[] value) {
            this.value = value;
        }

            

Reported by PMD.

The user-supplied array 'value' is stored directly.
Design

Line: 44

                          return value;
        }

        public void setValue(Boolean[] value) {
            this.value = value;
        }

    }
}

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 44

                          return value;
        }

        public void setValue(Boolean[] value) {
            this.value = value;
        }

    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/ByteArrayFieldTest_1.java
6 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: 12

              
public class ByteArrayFieldTest_1 extends TestCase {

    public void test_array() throws Exception {
        Assert.assertEquals("\"AQ==\"", JSON.toJSONString(new byte[] { 1 }));

    }

    public void test_codec_null() 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: 17

              
    }

    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);

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

    public void test_codec_null_1() throws Exception {
        V0 v = new V0();


            

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(v1.getValue(), v.getValue());
    }

    public void test_codec_null_1() throws Exception {
        V0 v = new V0();

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


            

Reported by PMD.

Returning 'value' may expose an internal array.
Design

Line: 46

                      private byte[] value;

        public byte[] getValue() {
            return value;
        }

        public void setValue(byte[] value) {
            this.value = value;
        }

            

Reported by PMD.

The user-supplied array 'value' is stored directly.
Design

Line: 49

                          return value;
        }

        public void setValue(byte[] value) {
            this.value = value;
        }

    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/ByteArrayFieldTest_4.java
6 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 ByteArrayFieldTest_4 extends TestCase {

    public void test_0() throws Exception {
        Model model = new Model();

        model.value = "ABCDEG".getBytes();

        String json = JSON.toJSONString(model);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 21

              
        String json = JSON.toJSONString(model);

        assertEquals("{\"value\":x'414243444547'}", json);

        Model model1 = JSON.parseObject(json, Model.class);
        Assert.assertArrayEquals(model.value, model1.value);

    }

            

Reported by PMD.

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

Line: 31

                  private static class Model {

        @JSONField(format = "hex")
        public byte[] value;


    }
}

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.JSONObject'
Design

Line: 4

              package com.alibaba.json.bvt;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.json.test.TestUtils;
import junit.framework.TestCase;
import org.junit.Assert;


            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.json.test.TestUtils'
Design

Line: 6

              import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.json.test.TestUtils;
import junit.framework.TestCase;
import org.junit.Assert;

import java.io.UnsupportedEncodingException;


            

Reported by PMD.

Avoid unused imports such as 'java.io.UnsupportedEncodingException'
Design

Line: 10

              import junit.framework.TestCase;
import org.junit.Assert;

import java.io.UnsupportedEncodingException;

public class ByteArrayFieldTest_4 extends TestCase {

    public void test_0() throws Exception {
        Model model = new Model();

            

Reported by PMD.