The following issues were found

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

               * Created by wenshao on 11/03/2017.
 */
public class Issue1020 extends TestCase {
    public void test_null() throws Exception {
        Vo vo = JSON.parseObject("{\"ld\":null}", Vo.class);
        assertNull(vo.ld);

    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

              public class Issue1020 extends TestCase {
    public void test_null() throws Exception {
        Vo vo = JSON.parseObject("{\"ld\":null}", Vo.class);
        assertNull(vo.ld);

    }

    public void test_empty() throws Exception {
        Vo vo = JSON.parseObject("{\"ld\":\"\"}", Vo.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: 18

              
    }

    public void test_empty() throws Exception {
        Vo vo = JSON.parseObject("{\"ld\":\"\"}", Vo.class);
        assertNull(vo.ld);

    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

              
    public void test_empty() throws Exception {
        Vo vo = JSON.parseObject("{\"ld\":\"\"}", Vo.class);
        assertNull(vo.ld);

    }

    public static class Vo {
        public LocalDate ld;

            

Reported by PMD.

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

Line: 25

                  }

    public static class Vo {
        public LocalDate ld;
    }
}

            

Reported by PMD.

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

Line: 19

              
    public void test_for_zhuangzaowen() throws Exception {
        String value = "{\"begin\":1340263804415,\"buildIds\":[\"42\"],\"end\":1340265305070,\"endBuildId\":\"50\",\"id\":\"4\",\"jobs\":[\"cb-intl-rfqma-UT\",\"cb-intl-rfqma-selenium\"],\"owners\":[\"wb_jianping.shenjp\"],\"triggerBuildId\":\"42\"}";
        System.out.println(JSON.parseObject(value, JenkinsFailedPhase.class, Feature.DisableASM));
    }

    public static class JenkinsFailedPhase {// extends BaseEntity<JenkinsFailedPhase> {

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

              
public class Bug_for_zhuangzaowen extends TestCase {

    public void test_for_zhuangzaowen() throws Exception {
        String value = "{\"begin\":1340263804415,\"buildIds\":[\"42\"],\"end\":1340265305070,\"endBuildId\":\"50\",\"id\":\"4\",\"jobs\":[\"cb-intl-rfqma-UT\",\"cb-intl-rfqma-selenium\"],\"owners\":[\"wb_jianping.shenjp\"],\"triggerBuildId\":\"42\"}";
        System.out.println(JSON.parseObject(value, JenkinsFailedPhase.class, Feature.DisableASM));
    }

    public static class JenkinsFailedPhase {// extends BaseEntity<JenkinsFailedPhase> {

            

Reported by PMD.

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

Line: 17

              
public class Bug_for_zhuangzaowen extends TestCase {

    public void test_for_zhuangzaowen() throws Exception {
        String value = "{\"begin\":1340263804415,\"buildIds\":[\"42\"],\"end\":1340265305070,\"endBuildId\":\"50\",\"id\":\"4\",\"jobs\":[\"cb-intl-rfqma-UT\",\"cb-intl-rfqma-selenium\"],\"owners\":[\"wb_jianping.shenjp\"],\"triggerBuildId\":\"42\"}";
        System.out.println(JSON.parseObject(value, JenkinsFailedPhase.class, Feature.DisableASM));
    }

    public static class JenkinsFailedPhase {// extends BaseEntity<JenkinsFailedPhase> {

            

Reported by PMD.

The class 'JenkinsFailedPhase' is suspected to be a Data Class (WOC=15.789%, NOPA=1, NOAM=16, WMC=22)
Design

Line: 22

                      System.out.println(JSON.parseObject(value, JenkinsFailedPhase.class, Feature.DisableASM));
    }

    public static class JenkinsFailedPhase {// extends BaseEntity<JenkinsFailedPhase> {

        private String             id;
        public static final String KEY_NAME_SPACE = "phase";

        private Set<String>        owners;

            

Reported by PMD.

Avoid unused imports such as 'java.util.Collection'
Design

Line: 4

              package com.alibaba.json.bvt.bug;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;


            

Reported by PMD.

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

              
public class ByteArrayFieldTest_3 extends TestCase {

    public void test_0() throws Exception {
        Entity entity = new Entity("中华人民共和国");
        String text = JSON.toJSONString(entity);
        JSONObject json = JSON.parseObject(text);
        Assert.assertEquals(TestUtils.encodeToBase64String(entity.getValue(), false), json.getString("value"));
        

            

Reported by PMD.

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

Line: 18

                      Entity entity = new Entity("中华人民共和国");
        String text = JSON.toJSONString(entity);
        JSONObject json = JSON.parseObject(text);
        Assert.assertEquals(TestUtils.encodeToBase64String(entity.getValue(), false), json.getString("value"));
        
        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertEquals("中华人民共和国", new String(entity2.getValue(), "UTF-8"));
    }


            

Reported by PMD.

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

Line: 21

                      Assert.assertEquals(TestUtils.encodeToBase64String(entity.getValue(), false), json.getString("value"));
        
        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertEquals("中华人民共和国", new String(entity2.getValue(), "UTF-8"));
    }

    private static class Entity {

        private byte[] value;

            

Reported by PMD.

Returning 'value' may expose an internal array.
Design

Line: 37

                      }

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

                          return value;
        }

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

    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/JsonValueTest.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: 27

              
public class JsonValueTest extends TestCase {

    public void test_toJSONString() throws Exception {
        Assert.assertEquals("null", JSON.toJSONString(Double.NaN));
        Assert.assertEquals("3.0", JSON.toJSONString(3D));
        Assert.assertEquals("null", JSON.toJSONString(Float.NaN));
        Assert.assertEquals("3.0", JSON.toJSONString(3F));
        Assert.assertEquals("1292939095640", JSON.toJSONString(new Date(1292939095640L)));

            

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

                      Assert.assertEquals(new Date(1292939095640L), JSON.parse("new Date(1292939095640)"));
    }

    public void test_bug_0() throws Exception {
        String text = "[{\"S\":0,\"T\":\"Register\"},{\"HOST_NAME\":\"qa-qd-62-187\",\"IP\":[\"172.29.62.187\"],\"MAC_ADDR\":[\"00:16:3E:43:E5:1C\"],\"SERVICE_TAG\":\"NOSN00:16:3E:43:E5:1C\",\"VERSION\":\"2.5\"}]  ";
        JSON.parseArray(text);
    }

    public void test_bug_1() throws Exception {

            

Reported by PMD.

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

Line: 36

                      Assert.assertEquals(new Date(1292939095640L), JSON.parse("new Date(1292939095640)"));
    }

    public void test_bug_0() throws Exception {
        String text = "[{\"S\":0,\"T\":\"Register\"},{\"HOST_NAME\":\"qa-qd-62-187\",\"IP\":[\"172.29.62.187\"],\"MAC_ADDR\":[\"00:16:3E:43:E5:1C\"],\"SERVICE_TAG\":\"NOSN00:16:3E:43:E5:1C\",\"VERSION\":\"2.5\"}]  ";
        JSON.parseArray(text);
    }

    public void test_bug_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: 41

                      JSON.parseArray(text);
    }

    public void test_bug_1() throws Exception {
        String text = "[{\"S\":2,\"T\":\"ConnectResp\"},\n\r \t{\"VAL\" :null}]\r\f";
        JSON.parseArray(text);
    }

}

            

Reported by PMD.

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

Line: 41

                      JSON.parseArray(text);
    }

    public void test_bug_1() throws Exception {
        String text = "[{\"S\":2,\"T\":\"ConnectResp\"},\n\r \t{\"VAL\" :null}]\r\f";
        JSON.parseArray(text);
    }

}

            

Reported by PMD.

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

              
public class ByteArrayFieldTest_2 extends TestCase {

    public void test_0() throws Exception {
        Entity entity = new Entity("中华人民共和国");
        String text = JSON.toJSONString(entity);
        JSONObject json = JSON.parseObject(text);
        Assert.assertEquals(TestUtils.encodeToBase64String(entity.getValue(), false), json.getString("value"));
        

            

Reported by PMD.

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

Line: 18

                      Entity entity = new Entity("中华人民共和国");
        String text = JSON.toJSONString(entity);
        JSONObject json = JSON.parseObject(text);
        Assert.assertEquals(TestUtils.encodeToBase64String(entity.getValue(), false), json.getString("value"));
        
        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertEquals("中华人民共和国", new String(entity2.getValue(), "UTF-8"));
    }


            

Reported by PMD.

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

Line: 21

                      Assert.assertEquals(TestUtils.encodeToBase64String(entity.getValue(), false), json.getString("value"));
        
        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertEquals("中华人民共和国", new String(entity2.getValue(), "UTF-8"));
    }

    public static class Entity {

        private byte[] value;

            

Reported by PMD.

Returning 'value' may expose an internal array.
Design

Line: 37

                      }

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

                          return value;
        }

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

    }
}

            

Reported by PMD.

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

Line: 34

                          text = JSON.toJSONString(map, SerializerFeature.WriteClassName);
        }
        
        System.out.println(text);
        Map<String, Object> map = JSON.parseObject(text, new TypeReference<Map<String, Object>>() {});
        //Assert.assertEquals(map, map.get("this"));
        Assert.assertEquals(map.get("u1"), map.get("u2"));
    }


            

Reported by PMD.

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

Line: 15

              import com.alibaba.fastjson.serializer.SerializerFeature;

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

    public void test_0() throws Exception {
        String text;

            

Reported by PMD.

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

Line: 16

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

    public void test_0() throws Exception {
        String text;
        {

            

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

                      ParserConfig.global.addAccept("com.alibaba.json.bvt.MapRefTest2");
    }

    public void test_0() throws Exception {
        String text;
        {
            Map<String, Object> map = new HashMap<String, Object>();

            User user = new User();

            

Reported by PMD.

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

Line: 40

                      Assert.assertEquals(map.get("u1"), map.get("u2"));
    }

    public static class User {

        private int    id;
        private String name;

        public int getId() {

            

Reported by PMD.

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

Line: 34

                          text = JSON.toJSONString(map, SerializerFeature.WriteClassName);
        }
        
        System.out.println(text);
        Map<String, Object> map = JSON.parseObject(text, new TypeReference<Map<String, Object>>() {});
        //Assert.assertEquals(map, map.get("this"));
        Assert.assertEquals(map.get("u1"), map.get("u2"));
    }


            

Reported by PMD.

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

Line: 15

              import com.alibaba.fastjson.serializer.SerializerFeature;

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

    public void test_0() throws Exception {
        String text;

            

Reported by PMD.

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

Line: 16

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

    public void test_0() throws Exception {
        String text;
        {

            

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

                      ParserConfig.global.addAccept("com.alibaba.json.bvt.MapRefTest3");
    }

    public void test_0() throws Exception {
        String text;
        {
            Map<String, Object> map = new HashMap<String, Object>();

            User user = new User();

            

Reported by PMD.

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

Line: 40

                      Assert.assertEquals(map.get("u1"), map.get("u2"));
    }

    public static class User {

        private int    id;
        private String name;

        public int getId() {

            

Reported by PMD.

src/test/java/com/alibaba/fastjson/deserializer/issue2951/TestIssue2951.java
5 issues
The class 'Model' is suspected to be a Data Class (WOC=0.000%, NOPA=4, NOAM=0, WMC=1)
Design

Line: 36

                      Assert.assertEquals(model.field4, actualField4);
    }

    public static class Model {
        public final int field1;
        public final float field2;
        public final String field3;
        public final List<String> field4;


            

Reported by PMD.

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

Line: 37

                  }

    public static class Model {
        public final int field1;
        public final float field2;
        public final String field3;
        public final List<String> field4;

        public Model(int field1, float field2, String field3, List<String> field4) {

            

Reported by PMD.

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

Line: 38

              
    public static class Model {
        public final int field1;
        public final float field2;
        public final String field3;
        public final List<String> field4;

        public Model(int field1, float field2, String field3, List<String> field4) {
            this.field1 = field1;

            

Reported by PMD.

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

Line: 39

                  public static class Model {
        public final int field1;
        public final float field2;
        public final String field3;
        public final List<String> field4;

        public Model(int field1, float field2, String field3, List<String> field4) {
            this.field1 = field1;
            this.field2 = field2;

            

Reported by PMD.

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

Line: 40

                      public final int field1;
        public final float field2;
        public final String field3;
        public final List<String> field4;

        public Model(int field1, float field2, String field3, List<String> field4) {
            this.field1 = field1;
            this.field2 = field2;
            this.field3 = field3;

            

Reported by PMD.

src/test/java/com/alibaba/fastjson/deserializer/issue3804/TestIssue3804.java
5 issues
System.out.println is used
Design

Line: 12

                      String textResponse="{\"error\":false,\"code";
        JSONValidator validator = JSONValidator.from(textResponse);
        if (validator.validate() && validator.getType() == JSONValidator.Type.Object) {
            System.out.println("Yes, it is Object");
        } else {
            System.out.println("No, it is not Object");
        }
    }
}

            

Reported by PMD.

System.out.println is used
Design

Line: 14

                      if (validator.validate() && validator.getType() == JSONValidator.Type.Object) {
            System.out.println("Yes, it is Object");
        } else {
            System.out.println("No, it is not Object");
        }
    }
}

            

Reported by PMD.

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

Line: 7

              
public class TestIssue3804 {
    @Test
    public void testIssue3804() {
        //String textResponse="{\"error\":false,\"code\":0}";
        String textResponse="{\"error\":false,\"code";
        JSONValidator validator = JSONValidator.from(textResponse);
        if (validator.validate() && validator.getType() == JSONValidator.Type.Object) {
            System.out.println("Yes, it is Object");

            

Reported by PMD.

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

Line: 11

                      //String textResponse="{\"error\":false,\"code\":0}";
        String textResponse="{\"error\":false,\"code";
        JSONValidator validator = JSONValidator.from(textResponse);
        if (validator.validate() && validator.getType() == JSONValidator.Type.Object) {
            System.out.println("Yes, it is Object");
        } else {
            System.out.println("No, it is not Object");
        }
    }

            

Reported by PMD.

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

Line: 11

                      //String textResponse="{\"error\":false,\"code\":0}";
        String textResponse="{\"error\":false,\"code";
        JSONValidator validator = JSONValidator.from(textResponse);
        if (validator.validate() && validator.getType() == JSONValidator.Type.Object) {
            System.out.println("Yes, it is Object");
        } else {
            System.out.println("No, it is not Object");
        }
    }

            

Reported by PMD.

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

              
public class Bug_for_smoothrat extends TestCase {

    public void test_0() throws Exception {
        Entity entity = new Entity();
        
        entity.setValue("aaa123".toCharArray());
        
        String text = JSON.toJSONString(entity);

            

Reported by PMD.

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

Line: 20

              
        Entity entity2 = JSON.parseObject(text, Entity.class);
        
        Assert.assertEquals(new String(entity.getValue()), new String(entity2.getValue()));
    }

    public static class Entity {

        private char[] value;

            

Reported by PMD.

Returning 'value' may expose an internal array.
Design

Line: 28

                      private char[] value;

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

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

            

Reported by PMD.

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

Line: 31

                          return value;
        }

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

    }
}

            

Reported by PMD.

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

Line: 31

                          return value;
        }

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

    }
}

            

Reported by PMD.