The following issues were found

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

               * Created by wenshao on 13/03/2017.
 */
public class Issue1030 extends TestCase {
    public void test_for_issue() throws Exception {
        String DOC = "{\"books\":[{\"pageWords\":[{\"num\":10},{\"num\":15}]},{\"pageWords\":[{\"num\":20}]}]}";

        //fastjson包
        JSONObject result = JSONObject.parseObject(DOC);


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

              
        List array = (List) JSONPath.eval(result, "$.books[0:].pageWords[0:]");

        assertEquals(3, array.size());
    }
}

            

Reported by PMD.

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

Line: 22

              
        List array = (List) JSONPath.eval(result, "$.books[0:].pageWords[0:]");

        assertEquals(3, array.size());
    }
}

            

Reported by PMD.

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

Line: 3

              package com.alibaba.json.bvt.bug;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPath;
import junit.framework.TestCase;

import java.util.List;


            

Reported by PMD.

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

    public void test_boolean() throws Exception {
        Assert.assertEquals("{\"is-abc\":false}", JSON.toJSONString(new BooleanJson()));
        Assert.assertTrue(JSON.parseObject("{\"is-abc\":true}", BooleanJson.class).isAbc());
    }

    public static class BooleanJson {

            

Reported by PMD.

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

Line: 14

              
    public void test_boolean() throws Exception {
        Assert.assertEquals("{\"is-abc\":false}", JSON.toJSONString(new BooleanJson()));
        Assert.assertTrue(JSON.parseObject("{\"is-abc\":true}", BooleanJson.class).isAbc());
    }

    public static class BooleanJson {

        @JSONField(name = "is-abc")

            

Reported by PMD.

Field isAbc has the same name as a method
Error

Line: 20

                  public static class BooleanJson {

        @JSONField(name = "is-abc")
        private boolean isAbc;

        public boolean isAbc() {
            return isAbc;
        }
        

            

Reported by PMD.

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

Line: 20

                  public static class BooleanJson {

        @JSONField(name = "is-abc")
        private boolean isAbc;

        public boolean isAbc() {
            return isAbc;
        }
        

            

Reported by PMD.

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

Line: 9

              
public class Bug_for_builder extends TestCase {

    public void test_for_longBuilderMethod() throws Exception {
        VO vo = JSON.parseObject("{\"id\":123}", VO.class);
    }

    public static class VO {


            

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

    public void test_for_longBuilderMethod() throws Exception {
        VO vo = JSON.parseObject("{\"id\":123}", VO.class);
    }

    public static class VO {


            

Reported by PMD.

Avoid unused local variables such as 'vo'.
Design

Line: 10

              public class Bug_for_builder extends TestCase {

    public void test_for_longBuilderMethod() throws Exception {
        VO vo = JSON.parseObject("{\"id\":123}", VO.class);
    }

    public static class VO {

        private long id;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'vo' (lines '10'-'11').
Error

Line: 10

              public class Bug_for_builder extends TestCase {

    public void test_for_longBuilderMethod() throws Exception {
        VO vo = JSON.parseObject("{\"id\":123}", VO.class);
    }

    public static class VO {

        private long id;

            

Reported by PMD.

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

Line: 17

              
        String jsonString = JSON.toJSONString(entity);

        System.out.println(jsonString);

        JSON.parseObject(jsonString, Entity.class);
    }

    public static class Entity {

            

Reported by PMD.

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

Line: 12

              
public class Bug_6 extends TestCase {

    public void test_bug6() throws Exception {
        Entity entity = new Entity();

        String jsonString = JSON.toJSONString(entity);

        System.out.println(jsonString);

            

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

    public void test_bug6() throws Exception {
        Entity entity = new Entity();

        String jsonString = JSON.toJSONString(entity);

        System.out.println(jsonString);

            

Reported by PMD.

Avoid using redundant field initializer for 'list'
Performance

Line: 24

              
    public static class Entity {

        private List<HashMap<String, String>> list = null;

        public List<HashMap<String, String>> getList() {
            return list;
        }


            

Reported by PMD.

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

              
public class Bug_for_issue_278 extends TestCase {

    public void test_for_issue() throws Exception {
        VO vo = new VO();
        vo.setTest(true);
        
        String text = JSON.toJSONString(vo);
        Assert.assertEquals("{\"test\":true}", 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

                      Assert.assertEquals("{\"test\":true}", text);
    }
    
    public void test_for_issue_decode() throws Exception {
        VO vo = JSON.parseObject("{\"isTest\":true}", VO.class);
        Assert.assertTrue(vo.isTest);
    }

    public static class VO {

            

Reported by PMD.

Field isTest has the same name as a method
Error

Line: 26

              
    public static class VO {

        private boolean isTest;

        public boolean isTest() {
            return isTest;
        }


            

Reported by PMD.

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

Line: 26

              
    public static class VO {

        private boolean isTest;

        public boolean isTest() {
            return isTest;
        }


            

Reported by PMD.

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

    public void test_double() throws Exception {
        JSONObject json = JSON.parseObject("{\"val\":12.3}");
        Assert.assertTrue(12.3D == json.getDoubleValue("val"));
    }

    public void test_JSONArray_double() throws Exception {

            

Reported by PMD.

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

Line: 14

              
    public void test_double() throws Exception {
        JSONObject json = JSON.parseObject("{\"val\":12.3}");
        Assert.assertTrue(12.3D == json.getDoubleValue("val"));
    }

    public void test_JSONArray_double() throws Exception {
        JSONArray json = JSON.parseArray("[12.3]");
        Assert.assertTrue(12.3D == json.getDoubleValue(0));

            

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

                      Assert.assertTrue(12.3D == json.getDoubleValue("val"));
    }

    public void test_JSONArray_double() throws Exception {
        JSONArray json = JSON.parseArray("[12.3]");
        Assert.assertTrue(12.3D == json.getDoubleValue(0));
    }
}

            

Reported by PMD.

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

Line: 19

              
    public void test_JSONArray_double() throws Exception {
        JSONArray json = JSON.parseArray("[12.3]");
        Assert.assertTrue(12.3D == json.getDoubleValue(0));
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/asm/JSONASMUtilTest.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: 10

              
public class JSONASMUtilTest extends TestCase {

    public void test_1() throws Exception {
        Assert.assertEquals("V", ASMUtils.desc(Void.TYPE));
        Assert.assertEquals("J", ASMUtils.desc(Long.TYPE));
        Assert.assertEquals("[J", ASMUtils.desc(long[].class));
        Assert.assertEquals("[Ljava/lang/Long;", ASMUtils.desc(Long[].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: 17

                      Assert.assertEquals("[Ljava/lang/Long;", ASMUtils.desc(Long[].class));
    }

    public void test_error_1() throws Exception {
        new ASMUtils();

        Exception error = null;
        try {
            ASMUtils.getPrimitiveLetter(Long.class);

            

Reported by PMD.

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

Line: 23

                      Exception error = null;
        try {
            ASMUtils.getPrimitiveLetter(Long.class);
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
}

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '20'-'24').
Error

Line: 20

                  public void test_error_1() throws Exception {
        new ASMUtils();

        Exception error = null;
        try {
            ASMUtils.getPrimitiveLetter(Long.class);
        } catch (Exception ex) {
            error = ex;
        }

            

Reported by PMD.

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

              
public class LoopTest extends TestCase {
    
    public void test_loop() throws Exception {
        Department department = JSON.parseObject("{id:12,name:'R & D', members:[{id:2001, name:'jobs'}]}", Department.class);
        Assert.assertNotNull(department);
        Assert.assertEquals(12, department.getId());
    }


            

Reported by PMD.

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

Line: 16

                  public void test_loop() throws Exception {
        Department department = JSON.parseObject("{id:12,name:'R & D', members:[{id:2001, name:'jobs'}]}", Department.class);
        Assert.assertNotNull(department);
        Assert.assertEquals(12, department.getId());
    }

    public static class Department {

        private int            id;

            

Reported by PMD.

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

Line: 19

                      Assert.assertEquals(12, department.getId());
    }

    public static class Department {

        private int            id;
        private String         name;

        private List<Employee> members = new ArrayList<Employee>();

            

Reported by PMD.

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

Line: 52

              
    }

    public static class Employee {

        private int        id;
        private String     name;

        private Department department;

            

Reported by PMD.

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

Line: 21

                      map.put("a", 1);
        map.put("b", 2);
        String text = JSON.toJSONString(map, SerializerFeature.WriteClassName);
        System.out.println(text);
        
        FieldMap map2 = (FieldMap) JSON.parse(text);
        
        Assert.assertTrue(map.equals(map2));
    }

            

Reported by PMD.

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

Line: 12

              import com.alibaba.fastjson.serializer.SerializerFeature;

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

    public void test_FieldMap() throws Exception {
        FieldMap map = new FieldMap();

            

Reported by PMD.

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

Line: 13

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

    public void test_FieldMap() throws Exception {
        FieldMap map = new FieldMap();
        map.put("a", 1);

            

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

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

    public void test_FieldMap() throws Exception {
        FieldMap map = new FieldMap();
        map.put("a", 1);
        map.put("b", 2);
        String text = JSON.toJSONString(map, SerializerFeature.WriteClassName);
        System.out.println(text);

            

Reported by PMD.

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

              import junit.framework.TestCase;

public class OOMTest extends TestCase {
    public void test_oom() throws Exception {
        
        for (int i = 0; i < 1000 * 1000; ++i) {
            String text = "{\"" + i + "\":0}";
            JSON.parse(text);
        }

            

Reported by PMD.

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

Line: 22

                      }
        
        Field field = SymbolTable.class.getDeclaredField("symbols");
        field.setAccessible(true);
        Object[] symbols = (Object[]) field.get(ParserConfig.getGlobalInstance().symbolTable);
        Assert.assertEquals(4096, symbols.length);
    }
}

            

Reported by PMD.

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

Line: 23

                      
        Field field = SymbolTable.class.getDeclaredField("symbols");
        field.setAccessible(true);
        Object[] symbols = (Object[]) field.get(ParserConfig.getGlobalInstance().symbolTable);
        Assert.assertEquals(4096, symbols.length);
    }
}

            

Reported by PMD.

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

Line: 23

                      
        Field field = SymbolTable.class.getDeclaredField("symbols");
        field.setAccessible(true);
        Object[] symbols = (Object[]) field.get(ParserConfig.getGlobalInstance().symbolTable);
        Assert.assertEquals(4096, symbols.length);
    }
}

            

Reported by PMD.