The following issues were found

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

    public void test_for_issue() throws Exception {
        JSON.parseObject("{\"list\":[{\"spec\":{}}]}", A.class);
    }

    public static class A {


            

Reported by PMD.

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

Line: 12

              
public class Bug_for_issue_555_setter extends TestCase {

    public void test_for_issue() throws Exception {
        JSON.parseObject("{\"list\":[{\"spec\":{}}]}", A.class);
    }

    public static class A {


            

Reported by PMD.

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

Line: 38

              
    public static class Spec {

        private int id;

        public Spec(int id){
            this.id = id;
        }
    }

            

Reported by PMD.

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

Line: 38

              
    public static class Spec {

        private int id;

        public Spec(int id){
            this.id = id;
        }
    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_555.java
4 issues
JUnit tests should include assert() or fail()
Design

Line: 12

              
public class Bug_for_issue_555 extends TestCase {

    public void test_for_issue() throws Exception {
        JSON.parseObject("{\"list\":[{\"spec\":{}}]}", A.class);
    }

    public static class A {


            

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 Bug_for_issue_555 extends TestCase {

    public void test_for_issue() throws Exception {
        JSON.parseObject("{\"list\":[{\"spec\":{}}]}", A.class);
    }

    public static class A {


            

Reported by PMD.

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

Line: 28

                  }

    public static class Spec {
        private int id;
        
        public Spec(int id) {
            this.id = id;
        }
    }

            

Reported by PMD.

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

Line: 28

                  }

    public static class Spec {
        private int id;
        
        public Spec(int id) {
            this.id = id;
        }
    }

            

Reported by PMD.

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

              import junit.framework.TestCase;

public class ModuleTest extends TestCase {
    public void test_for_module() throws Exception {
        ParserConfig config = new ParserConfig();
        config.register(new MyModuel2());
        config.register(new MyModuel());

        assertSame(MiscCodec.instance, config.getDeserializer(A.class));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                      config.register(new MyModuel2());
        config.register(new MyModuel());

        assertSame(MiscCodec.instance, config.getDeserializer(A.class));
    }

    public void test_for_module_1() throws Exception {
        SerializeConfig config = new SerializeConfig();
        config.register(new MyModuel2());

            

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

                      assertSame(MiscCodec.instance, config.getDeserializer(A.class));
    }

    public void test_for_module_1() throws Exception {
        SerializeConfig config = new SerializeConfig();
        config.register(new MyModuel2());
        config.register(new MyModuel());

        assertSame(MiscCodec.instance, config.getObjectWriter(A.class));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 25

                      config.register(new MyModuel2());
        config.register(new MyModuel());

        assertSame(MiscCodec.instance, config.getObjectWriter(A.class));
    }

    public static class A {

    }

            

Reported by PMD.

src/test/java/com/alibaba/fastjson/deserializer/issues3796/bean/ObjectH.java
4 issues
Too many fields
Design

Line: 9

              import java.util.List;


public class ObjectH {
	
	private int a;

	
	private long b;

            

Reported by PMD.

The class 'ObjectH' is suspected to be a Data Class (WOC=0.000%, NOPA=0, NOAM=34, WMC=34)
Design

Line: 9

              import java.util.List;


public class ObjectH {
	
	private int a;

	
	private long b;

            

Reported by PMD.

Avoid using redundant field initializer for 'p'
Performance

Line: 52

              	private int o;

	
	private boolean p = false;

	
	private boolean q = false;

	public int getA() {

            

Reported by PMD.

Avoid using redundant field initializer for 'q'
Performance

Line: 55

              	private boolean p = false;

	
	private boolean q = false;

	public int getA() {
		return a;
	}


            

Reported by PMD.

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

Line: 9

              import java.util.List;


public class ObjectI1 {
	
	private int a = 0;
	
	private long b = 0;


            

Reported by PMD.

Avoid using redundant field initializer for 'a'
Performance

Line: 11

              
public class ObjectI1 {
	
	private int a = 0;
	
	private long b = 0;

	
	private int c = 0;

            

Reported by PMD.

Avoid using redundant field initializer for 'b'
Performance

Line: 13

              	
	private int a = 0;
	
	private long b = 0;

	
	private int c = 0;

	

            

Reported by PMD.

Avoid using redundant field initializer for 'c'
Performance

Line: 16

              	private long b = 0;

	
	private int c = 0;

	
	private List<Integer> d;

	public int getA() {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_435.java
4 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: 9

              
public class Bug_for_issue_435 extends TestCase {

    public void test_for_issue() throws Exception {
        JSON.parseObject("\ufeff{\"value\":null}", Model.class);
    }

    public void test_for_issue_Float() throws Exception {
        JSON.parseObject("\ufeff{\"value\":null}", ModelFloat.class);

            

Reported by PMD.

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

Line: 9

              
public class Bug_for_issue_435 extends TestCase {

    public void test_for_issue() throws Exception {
        JSON.parseObject("\ufeff{\"value\":null}", Model.class);
    }

    public void test_for_issue_Float() throws Exception {
        JSON.parseObject("\ufeff{\"value\":null}", ModelFloat.class);

            

Reported by PMD.

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

Line: 13

                      JSON.parseObject("\ufeff{\"value\":null}", Model.class);
    }

    public void test_for_issue_Float() throws Exception {
        JSON.parseObject("\ufeff{\"value\":null}", ModelFloat.class);
    }
    
    public static class Model {
        public float 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: 13

                      JSON.parseObject("\ufeff{\"value\":null}", Model.class);
    }

    public void test_for_issue_Float() throws Exception {
        JSON.parseObject("\ufeff{\"value\":null}", ModelFloat.class);
    }
    
    public static class Model {
        public float value;

            

Reported by PMD.

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

Line: 17

                      String s = JSON.toJSONString(arr);

        Object[] ar = JSON.parseObject(s, Object[].class);
        System.out.println();
    }
}

            

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_O_I_See_you extends TestCase {

    public void test_bug() throws Exception {
        Object[] arra = { "aa", "bb" };

        Object[] arr = { "sssss", arra };

        String s = JSON.toJSONString(arr);

            

Reported by PMD.

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

Line: 9

              
public class Bug_for_O_I_See_you extends TestCase {

    public void test_bug() throws Exception {
        Object[] arra = { "aa", "bb" };

        Object[] arr = { "sssss", arra };

        String s = JSON.toJSONString(arr);

            

Reported by PMD.

Found 'DU'-anomaly for variable 'ar' (lines '16'-'18').
Error

Line: 16

              
        String s = JSON.toJSONString(arr);

        Object[] ar = JSON.parseObject(s, Object[].class);
        System.out.println();
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_jinghui70.java
4 issues
This abstract class does not have any abstract methods
Design

Line: 10

              
public class Bug_for_jinghui70 extends TestCase {

    public static abstract class IdObject<I> {

        private I id;

        public I getId() {
            return id;

            

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_generic() throws Exception {
        String str = "{\"id\":0}";
        
        Child child = JSON.parseObject(str, Child.class);
        Assert.assertEquals(Long.class, child.getId().getClass());
    }

            

Reported by PMD.

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

Line: 31

                      String str = "{\"id\":0}";
        
        Child child = JSON.parseObject(str, Child.class);
        Assert.assertEquals(Long.class, child.getId().getClass());
    }
}

            

Reported by PMD.

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

Line: 31

                      String str = "{\"id\":0}";
        
        Child child = JSON.parseObject(str, Child.class);
        Assert.assertEquals(Long.class, child.getId().getClass());
    }
}

            

Reported by PMD.

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

Line: 13

                  public void test_for_SpringFire() {
        Generic<String> q = new Generic<String>();
        String text = JSON.toJSONString(q, SerializerFeature.WriteClassName);
        System.out.println(text);
        JSON.parseObject(text, Generic.class);
    }

    public static class Generic<T> {


            

Reported by PMD.

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

Line: 10

              
public class Bug_for_SpitFire_2 extends TestCase {

    public void test_for_SpringFire() {
        Generic<String> q = new Generic<String>();
        String text = JSON.toJSONString(q, SerializerFeature.WriteClassName);
        System.out.println(text);
        JSON.parseObject(text, Generic.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: 10

              
public class Bug_for_SpitFire_2 extends TestCase {

    public void test_for_SpringFire() {
        Generic<String> q = new Generic<String>();
        String text = JSON.toJSONString(q, SerializerFeature.WriteClassName);
        System.out.println(text);
        JSON.parseObject(text, Generic.class);
    }

            

Reported by PMD.

The class 'Generic' is suspected to be a Data Class (WOC=0.000%, NOPA=0, NOAM=4, WMC=4)
Design

Line: 17

                      JSON.parseObject(text, Generic.class);
    }

    public static class Generic<T> {

        String header;
        T      payload;

        public String getHeader() {

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/support/spring/FastJsonpResponseBodyAdvice.java
4 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 37

                   * Pattern for validating jsonp callback parameter values.
     */
    private static final Pattern CALLBACK_PARAM_PATTERN = Pattern.compile("[0-9A-Za-z_\\.]*");
    private final String[] jsonpQueryParamNames;
    /**
     * Default JSONP query param names: callback/jsonp
     */
    public static final String[] DEFAULT_JSONP_QUERY_PARAM_NAMES = {"callback", "jsonp"};


            

Reported by PMD.

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

Line: 47

                      this.jsonpQueryParamNames = DEFAULT_JSONP_QUERY_PARAM_NAMES;
    }

    public FastJsonpResponseBodyAdvice(String... queryParamNames) {
        Assert.isTrue(!ObjectUtils.isEmpty(queryParamNames), "At least one query param name is required");
        this.jsonpQueryParamNames = queryParamNames;
    }

    public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {

            

Reported by PMD.

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

Line: 100

                   * @param value the query param value, never {@code null}
     */
    protected boolean isValidJsonpQueryParam(String value) {
        return CALLBACK_PARAM_PATTERN.matcher(value).matches();
    }

    /**
     * Return the content type to set the response to.
     * This implementation always returns "application/javascript".

            

Reported by PMD.

Found 'DU'-anomaly for variable 'servletRequest' (lines '77'-'90').
Error

Line: 77

                   */
    public void beforeBodyWriteInternal(MappingFastJsonValue bodyContainer, MediaType contentType,
                                        MethodParameter returnType, ServerHttpRequest request, ServerHttpResponse response) {
        HttpServletRequest servletRequest = ((ServletServerHttpRequest) request).getServletRequest();
        for (String name : this.jsonpQueryParamNames) {
            String value = servletRequest.getParameter(name);
            if (value != null) {
                if (!isValidJsonpQueryParam(value)) {
                    continue;

            

Reported by PMD.