The following issues were found

src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_572_private.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: 13

              
public class Bug_for_issue_572_private extends TestCase {

    public void test_for_issue() throws Exception {
        Model model = new Model();
        model.id = 1001;
        model.name = "wenshao";

        String text = JSON.toJSONString(model, SerializerFeature.WriteNonStringValueAsString);

            

Reported by PMD.

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

Line: 22

                      Assert.assertEquals("{\"id\":\"1001\",\"name\":\"wenshao\"}", text);
    }

    public void test_for_issue_1() throws Exception {
        Model model = new Model();
        model.id = 1001;
        model.name = "wenshao";

        ValueFilter valueFilter = new ValueFilter() {

            

Reported by PMD.

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

Line: 42

                      Assert.assertEquals("{\"id\":\"1001\",\"name\":\"wenshao\"}", text);
    }

    private static class Model {

        private int    id;
        private String name;

        public int getId() {

            

Reported by PMD.

Found 'DU'-anomaly for variable 'valueFilter' (lines '27'-'40').
Error

Line: 27

                      model.id = 1001;
        model.name = "wenshao";

        ValueFilter valueFilter = new ValueFilter() {

            @Override
            public Object process(Object object, String name, Object value) {
                if (value instanceof Number) {
                    return null;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'valueFilter' (lines '27'-'40').
Error

Line: 27

                      model.id = 1001;
        model.name = "wenshao";

        ValueFilter valueFilter = new ValueFilter() {

            @Override
            public Object process(Object object, String name, Object value) {
                if (value instanceof Number) {
                    return null;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_Issue_603.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: 17

              
public class Bug_for_Issue_603 extends TestCase {

    public void test_for_issue() throws Exception {
        ParserConfig.getGlobalInstance().putDeserializer(OrderActionEnum.class, new OrderActionEnumDeser());

        {
            Msg msg = JSON.parseObject("{\"actionEnum\":1,\"body\":\"A\"}", Msg.class);
            Assert.assertEquals(msg.body, "A");

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 38

                      @Override
        public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
            Integer intValue = parser.parseObject(int.class);
            if (intValue == 1) {
                return (T) OrderActionEnum.FAIL;
            } else if (intValue == 0) {
                return (T) OrderActionEnum.SUCC;
            }
            throw new IllegalStateException();

            

Reported by PMD.

Perhaps 'code' could be replaced by a local variable.
Design

Line: 56

                  public static enum OrderActionEnum {
                                        FAIL(1), SUCC(0);

        private int code;

        OrderActionEnum(int code){
            this.code = code;
        }
    }

            

Reported by PMD.

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

Line: 65

              
    public static class Msg {

        public OrderActionEnum actionEnum;
        public String          body;
    }
}

            

Reported by PMD.

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

Line: 66

                  public static class Msg {

        public OrderActionEnum actionEnum;
        public String          body;
    }
}

            

Reported by PMD.

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

Line: 12

              
public class Bug_for_issue_427 extends TestCase {

    public void test_for_issue() throws Exception {
        String value = "================================================"
                + "\n服务器名称:[FFFF00]N23-物华天宝 [-]"
                + "\n开服时间:[FFFF00]2015年10月16日11:00(周五)[-]"
                + "\n================================================";
        

            

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

    public void test_for_issue() throws Exception {
        String value = "================================================"
                + "\n服务器名称:[FFFF00]N23-物华天宝 [-]"
                + "\n开服时间:[FFFF00]2015年10月16日11:00(周五)[-]"
                + "\n================================================";
        

            

Reported by PMD.

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

Line: 25

              
    public static class Model {

        public String value;
    }
}

            

Reported by PMD.

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

Line: 3

              package com.alibaba.json.bvt.bug;

import org.junit.Assert;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;

import junit.framework.TestCase;


            

Reported by PMD.

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

Line: 6

              import org.junit.Assert;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;

import junit.framework.TestCase;

public class Bug_for_issue_427 extends TestCase {


            

Reported by PMD.

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

Line: 15

                      q.setHeader("Sdfdf");
        q.setPayload(new Payload());
        String text = JSON.toJSONString(q, SerializerFeature.WriteClassName);
        System.out.println(text);
        JSON.parseObject(text, Generic.class);
    }

    public static abstract class AbstractDTO {


            

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

    public void test_for_SpitFire() {
        Generic<Payload> q = new Generic<Payload>();
        q.setHeader("Sdfdf");
        q.setPayload(new Payload());
        String text = JSON.toJSONString(q, SerializerFeature.WriteClassName);
        System.out.println(text);

            

Reported by PMD.

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

Line: 10

              
public class Bug_for_SpitFire_3 extends TestCase {

    public void test_for_SpitFire() {
        Generic<Payload> q = new Generic<Payload>();
        q.setHeader("Sdfdf");
        q.setPayload(new Payload());
        String text = JSON.toJSONString(q, SerializerFeature.WriteClassName);
        System.out.println(text);

            

Reported by PMD.

This abstract class does not have any abstract methods
Design

Line: 19

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

    public static abstract class AbstractDTO {

        private String test;

        public String getTest() {
            return test;

            

Reported by PMD.

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

Line: 36

              
    }

    public static class Generic<T extends AbstractDTO> extends AbstractDTO {

        String header;
        T      payload;

        public String getHeader() {

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/serializer/ArraySerializer.java
5 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 26

               */
public class ArraySerializer implements ObjectSerializer {

	private final Class<?> componentType;
    private final ObjectSerializer compObjectSerializer;

    public ArraySerializer(Class<?> componentType, ObjectSerializer compObjectSerializer){
        this.componentType = componentType;
        this.compObjectSerializer = compObjectSerializer;

            

Reported by PMD.

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

Line: 27

              public class ArraySerializer implements ObjectSerializer {

	private final Class<?> componentType;
    private final ObjectSerializer compObjectSerializer;

    public ArraySerializer(Class<?> componentType, ObjectSerializer compObjectSerializer){
        this.componentType = componentType;
        this.compObjectSerializer = compObjectSerializer;
    }

            

Reported by PMD.

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

Line: 63

                                  } else {
                        out.append("null");
                    }
                } else if (item.getClass() == componentType) {
                	compObjectSerializer.write(serializer, item, i, null, 0);
                } else {
                	ObjectSerializer itemSerializer = serializer.getObjectWriter(item.getClass());
                	itemSerializer.write(serializer, item, i, null, 0);
                }

            

Reported by PMD.

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

Line: 66

                              } else if (item.getClass() == componentType) {
                	compObjectSerializer.write(serializer, item, i, null, 0);
                } else {
                	ObjectSerializer itemSerializer = serializer.getObjectWriter(item.getClass());
                	itemSerializer.write(serializer, item, i, null, 0);
                }
            }
            out.append(']');
        } finally {

            

Reported by PMD.

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

Line: 67

                              	compObjectSerializer.write(serializer, item, i, null, 0);
                } else {
                	ObjectSerializer itemSerializer = serializer.getObjectWriter(item.getClass());
                	itemSerializer.write(serializer, item, i, null, 0);
                }
            }
            out.append(']');
        } finally {
            serializer.context = context;

            

Reported by PMD.

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

Line: 9

              import java.util.List;


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

            

Reported by PMD.

Avoid using redundant field initializer for 'a'
Performance

Line: 11

              
public class ObjectJ1 {
	
	private int a = 0;
	
	private int b = 0;
	
	private List<ObjectJ1_A> c;
	

            

Reported by PMD.

Avoid using redundant field initializer for 'b'
Performance

Line: 13

              	
	private int a = 0;
	
	private int b = 0;
	
	private List<ObjectJ1_A> c;
	
	private int d = 0;
	

            

Reported by PMD.

Avoid using redundant field initializer for 'd'
Performance

Line: 17

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

            

Reported by PMD.

Avoid using redundant field initializer for 'i'
Performance

Line: 27

              	
	private List<Integer> h;
	
	private boolean i = false;

	public int getA() {
		return a;
	}


            

Reported by PMD.

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

Line: 11

              public class Bug_for_alibank extends TestCase {
    public void test_bug() throws Exception {
        String jsonStrz = "{addContact:[{\"address\":\"=\\\\\\\\\\\'\'\\&quot;);|]*{%0d%0a&lt;%00\"}]}";
        System.out.println(jsonStrz);
        Object o = JSON.parseObject(jsonStrz.replaceAll("\\\\", ""));
        System.out.println(JSON.toJSONString(o));
    }
}

            

Reported by PMD.

System.out.println is used
Design

Line: 13

                      String jsonStrz = "{addContact:[{\"address\":\"=\\\\\\\\\\\'\'\\&quot;);|]*{%0d%0a&lt;%00\"}]}";
        System.out.println(jsonStrz);
        Object o = JSON.parseObject(jsonStrz.replaceAll("\\\\", ""));
        System.out.println(JSON.toJSONString(o));
    }
}

            

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_alibank extends TestCase {
    public void test_bug() throws Exception {
        String jsonStrz = "{addContact:[{\"address\":\"=\\\\\\\\\\\'\'\\&quot;);|]*{%0d%0a&lt;%00\"}]}";
        System.out.println(jsonStrz);
        Object o = JSON.parseObject(jsonStrz.replaceAll("\\\\", ""));
        System.out.println(JSON.toJSONString(o));
    }

            

Reported by PMD.

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

Line: 9

              

public class Bug_for_alibank extends TestCase {
    public void test_bug() throws Exception {
        String jsonStrz = "{addContact:[{\"address\":\"=\\\\\\\\\\\'\'\\&quot;);|]*{%0d%0a&lt;%00\"}]}";
        System.out.println(jsonStrz);
        Object o = JSON.parseObject(jsonStrz.replaceAll("\\\\", ""));
        System.out.println(JSON.toJSONString(o));
    }

            

Reported by PMD.

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

Line: 12

                  public void test_bug() throws Exception {
        String jsonStrz = "{addContact:[{\"address\":\"=\\\\\\\\\\\'\'\\&quot;);|]*{%0d%0a&lt;%00\"}]}";
        System.out.println(jsonStrz);
        Object o = JSON.parseObject(jsonStrz.replaceAll("\\\\", ""));
        System.out.println(JSON.toJSONString(o));
    }
}

            

Reported by PMD.

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

              
public class Bug_for_issue_285 extends TestCase {

    public void test_for_issue() throws Exception {
        VO vo = new VO();
        vo.v1 = new V1();
        vo.v1.v2 = new V2();
        vo.v1.v2.v3 = new V3();
        vo.v1.v2.v3.v4 = new V4();

            

Reported by PMD.

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

Line: 27

              
    public static class VO {

        public V1 v1;
    }

    public static class V1 {

        public V2 v2;

            

Reported by PMD.

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

Line: 32

              
    public static class V1 {

        public V2 v2;
    }

    public static class V2 {

        public V3 v3;

            

Reported by PMD.

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

Line: 37

              
    public static class V2 {

        public V3 v3;
    }

    public static class V3 {
        public V4 v4;
    }

            

Reported by PMD.

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

Line: 41

                  }

    public static class V3 {
        public V4 v4;
    }
    

    public static class V4 {


            

Reported by PMD.

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

Line: 23

              
        String s001 = JSON.toJSONString(params, SerializerFeature.BrowserCompatible);

        System.out.println(s001);
        
        Map<Object, Object> params2 = (Map<Object, Object>) JSON.parse(s001);
        Assert.assertEquals(params.size(), params2.size());
        Assert.assertEquals(params.get("uid"), params2.get("uid"));
        

            

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

              
public class Bug_for_bbl extends TestCase {

    public void test_bug() throws Exception {
        Map<Object, Object> params = new HashMap<Object, Object>();
        params.put("msg",

                   "<img class=\"em\" src=\"http://ab.com/12/33.jpg\" />");
        params.put("uid", "22034343");

            

Reported by PMD.

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

Line: 26

                      System.out.println(s001);
        
        Map<Object, Object> params2 = (Map<Object, Object>) JSON.parse(s001);
        Assert.assertEquals(params.size(), params2.size());
        Assert.assertEquals(params.get("uid"), params2.get("uid"));
        
        Assert.assertEquals(params.get("msg"), params2.get("msg"));
        Assert.assertEquals(params, params2);
    }

            

Reported by PMD.

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

Line: 27

                      
        Map<Object, Object> params2 = (Map<Object, Object>) JSON.parse(s001);
        Assert.assertEquals(params.size(), params2.size());
        Assert.assertEquals(params.get("uid"), params2.get("uid"));
        
        Assert.assertEquals(params.get("msg"), params2.get("msg"));
        Assert.assertEquals(params, params2);
    }
}

            

Reported by PMD.

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

Line: 29

                      Assert.assertEquals(params.size(), params2.size());
        Assert.assertEquals(params.get("uid"), params2.get("uid"));
        
        Assert.assertEquals(params.get("msg"), params2.get("msg"));
        Assert.assertEquals(params, params2);
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Issue_748.java
5 issues
JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 13

              import junit.framework.TestCase;

public class Issue_748 extends TestCase {
    protected void setUp() throws Exception {
        com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Issue_748.");
    }

    public void testJsonObjectWithClassName() {
        JSONObject jsonObject = new JSONObject();

            

Reported by PMD.

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

Line: 14

              
public class Issue_748 extends TestCase {
    protected void setUp() throws Exception {
        com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Issue_748.");
    }

    public void testJsonObjectWithClassName() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("key1", "value1");

            

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

                      com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Issue_748.");
    }

    public void testJsonObjectWithClassName() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("key1", "value1");
        jsonObject.put("key2", "value2");
        DataObject dataObject = new DataObject();
        dataObject.setValue(jsonObject);

            

Reported by PMD.

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

Line: 30

              
        DataObject obj = (DataObject) JSON.parse(jsonStr, Feature.IgnoreNotMatch);
        Assert.assertNotNull(obj.value);
        Assert.assertNotNull(obj.value.get("key1"));
        Assert.assertNotNull(obj.value.get("key2"));
    }

    public static class DataObject {


            

Reported by PMD.

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

Line: 31

                      DataObject obj = (DataObject) JSON.parse(jsonStr, Feature.IgnoreNotMatch);
        Assert.assertNotNull(obj.value);
        Assert.assertNotNull(obj.value.get("key1"));
        Assert.assertNotNull(obj.value.get("key2"));
    }

    public static class DataObject {

        private JSONObject value;

            

Reported by PMD.