The following issues were found

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

              import java.util.List;

public class Issue2234 extends TestCase {
    public void test_for_issue() throws Exception {
        String userStr = "{\"name\":\"asdfad\",\"ss\":\"\"}";
        User user = JSON.parseObject(userStr, User.class);
    }

    public static class User {

            

Reported by PMD.

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

Line: 9

              import java.util.List;

public class Issue2234 extends TestCase {
    public void test_for_issue() throws Exception {
        String userStr = "{\"name\":\"asdfad\",\"ss\":\"\"}";
        User user = JSON.parseObject(userStr, User.class);
    }

    public static class User {

            

Reported by PMD.

Avoid unused local variables such as 'user'.
Design

Line: 11

              public class Issue2234 extends TestCase {
    public void test_for_issue() throws Exception {
        String userStr = "{\"name\":\"asdfad\",\"ss\":\"\"}";
        User user = JSON.parseObject(userStr, User.class);
    }

    public static class User {
        public String name;
        public List ss;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'user' (lines '11'-'12').
Error

Line: 11

              public class Issue2234 extends TestCase {
    public void test_for_issue() throws Exception {
        String userStr = "{\"name\":\"asdfad\",\"ss\":\"\"}";
        User user = JSON.parseObject(userStr, User.class);
    }

    public static class User {
        public String name;
        public List ss;

            

Reported by PMD.

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

              import junit.framework.TestCase;

public class Issue2515 extends TestCase  {
    public void test_for_issue() throws Exception {
        String json = "{\n" +
                "    \"a\":\"{\\\"b\\\":\\\"cd\\\"}\"\n" +
                "}";

        JSONObject obj = JSON.parseObject(json);

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 9

              import junit.framework.TestCase;

public class Issue2515 extends TestCase  {
    public void test_for_issue() throws Exception {
        String json = "{\n" +
                "    \"a\":\"{\\\"b\\\":\\\"cd\\\"}\"\n" +
                "}";

        JSONObject obj = JSON.parseObject(json);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

              
        JSONObject obj = JSON.parseObject(json);

        assertEquals("cd", JSONPath.eval(obj, "$.a.b"));
        assertEquals(1, JSONPath.eval(obj, "$.a.size"));
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                      JSONObject obj = JSON.parseObject(json);

        assertEquals("cd", JSONPath.eval(obj, "$.a.b"));
        assertEquals(1, JSONPath.eval(obj, "$.a.size"));
    }
}

            

Reported by PMD.

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

Line: 13

              import java.util.TimeZone;

public class Issue2606 extends TestCase {
    @Override
    public void setUp() throws Exception {
        JSON.defaultTimeZone = TimeZone.getDefault();
        JSON.defaultLocale = Locale.CHINA;
    }


            

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

                      JSON.defaultLocale = Locale.CHINA;
    }

    public void test_for_issue() throws Exception {
        String str = "2019-07-03 19:34:22,547";
        Date d = TypeUtils.castToDate(str);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS");
        sdf.setTimeZone(TimeZone.getDefault());
        assertEquals(str, sdf.format(d));

            

Reported by PMD.

When instantiating a SimpleDateFormat object, specify a Locale
Error

Line: 22

                  public void test_for_issue() throws Exception {
        String str = "2019-07-03 19:34:22,547";
        Date d = TypeUtils.castToDate(str);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS");
        sdf.setTimeZone(TimeZone.getDefault());
        assertEquals(str, sdf.format(d));
    }
}
            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 24

                      Date d = TypeUtils.castToDate(str);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS");
        sdf.setTimeZone(TimeZone.getDefault());
        assertEquals(str, sdf.format(d));
    }
}
            

Reported by PMD.

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

               */
public class Bug_for_lixianfeng extends TestCase {

    public void test_long_list() throws Exception {
        String str = "{\"id\":14281,\"name\":\"test\",\"canPurchase\":1,\"categoryId\":955063}";

        JSON.parseObject(str, Te.class);
    }


            

Reported by PMD.

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

Line: 17

               */
public class Bug_for_lixianfeng extends TestCase {

    public void test_long_list() throws Exception {
        String str = "{\"id\":14281,\"name\":\"test\",\"canPurchase\":1,\"categoryId\":955063}";

        JSON.parseObject(str, Te.class);
    }


            

Reported by PMD.

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

Line: 23

                      JSON.parseObject(str, Te.class);
    }

    public static class Te {

        private Long       id;
        private String     name;
        private List<Long> catIds;


            

Reported by PMD.

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

Line: 3

              package com.alibaba.json.bvt.parser.bug;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSON;

import junit.framework.TestCase;


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_2900/Issue2982.java
4 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 13

              

    @Test
    public void test_for_issue() {
        String jsonStr = "[ { \"activity_type\" : 0, \"activity_id\" : \"***\", \"activity_tip\" : \"***\", \"position\" : \"1\" }, { \"activity_type\" : 0, \"activity_id\" : \"2669\", \"activity_tip\" : \"****\", \"position\" : \"1\" }]";
        assertTrue(JSONArray.isValidArray(jsonStr));
        assertTrue(JSON.isValidArray(jsonStr));
        assertTrue(JSONObject.isValidArray(jsonStr));
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 15

                  @Test
    public void test_for_issue() {
        String jsonStr = "[ { \"activity_type\" : 0, \"activity_id\" : \"***\", \"activity_tip\" : \"***\", \"position\" : \"1\" }, { \"activity_type\" : 0, \"activity_id\" : \"2669\", \"activity_tip\" : \"****\", \"position\" : \"1\" }]";
        assertTrue(JSONArray.isValidArray(jsonStr));
        assertTrue(JSON.isValidArray(jsonStr));
        assertTrue(JSONObject.isValidArray(jsonStr));
    }



            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                  public void test_for_issue() {
        String jsonStr = "[ { \"activity_type\" : 0, \"activity_id\" : \"***\", \"activity_tip\" : \"***\", \"position\" : \"1\" }, { \"activity_type\" : 0, \"activity_id\" : \"2669\", \"activity_tip\" : \"****\", \"position\" : \"1\" }]";
        assertTrue(JSONArray.isValidArray(jsonStr));
        assertTrue(JSON.isValidArray(jsonStr));
        assertTrue(JSONObject.isValidArray(jsonStr));
    }


}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                      String jsonStr = "[ { \"activity_type\" : 0, \"activity_id\" : \"***\", \"activity_tip\" : \"***\", \"position\" : \"1\" }, { \"activity_type\" : 0, \"activity_id\" : \"2669\", \"activity_tip\" : \"****\", \"position\" : \"1\" }]";
        assertTrue(JSONArray.isValidArray(jsonStr));
        assertTrue(JSON.isValidArray(jsonStr));
        assertTrue(JSONObject.isValidArray(jsonStr));
    }


}

            

Reported by PMD.

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

              import junit.framework.TestCase;

public class Issue3057 extends TestCase {
    public void test_for_issue() throws Exception {
        String str = "{\"q\":[]}";
        Bean bean = JSON.parseObject(str, Bean.class);
        assertEquals(0, bean.q.size());
    }


            

Reported by PMD.

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

Line: 10

                  public void test_for_issue() throws Exception {
        String str = "{\"q\":[]}";
        Bean bean = JSON.parseObject(str, Bean.class);
        assertEquals(0, bean.q.size());
    }

    public static class Bean {
        public java.util.Deque q;
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 10

                  public void test_for_issue() throws Exception {
        String str = "{\"q\":[]}";
        Bean bean = JSON.parseObject(str, Bean.class);
        assertEquals(0, bean.q.size());
    }

    public static class Bean {
        public java.util.Deque q;
    }

            

Reported by PMD.

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

Line: 14

                  }

    public static class Bean {
        public java.util.Deque q;
    }
}

            

Reported by PMD.

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

              import java.util.Map;

public class Issue3138 extends TestCase {
    public void test_0() throws Exception {
        VO vo = JSON.parseObject("{\"value\":{\"@type\":\"aa\"}}", VO.class);
    }

    public static class VO {
        @JSONField(parseFeatures = Feature.DisableSpecialKeyDetect)

            

Reported by PMD.

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

Line: 11

              import java.util.Map;

public class Issue3138 extends TestCase {
    public void test_0() throws Exception {
        VO vo = JSON.parseObject("{\"value\":{\"@type\":\"aa\"}}", VO.class);
    }

    public static class VO {
        @JSONField(parseFeatures = Feature.DisableSpecialKeyDetect)

            

Reported by PMD.

Avoid unused local variables such as 'vo'.
Design

Line: 12

              
public class Issue3138 extends TestCase {
    public void test_0() throws Exception {
        VO vo = JSON.parseObject("{\"value\":{\"@type\":\"aa\"}}", VO.class);
    }

    public static class VO {
        @JSONField(parseFeatures = Feature.DisableSpecialKeyDetect)
        public Map<String, Object> value;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'vo' (lines '12'-'13').
Error

Line: 12

              
public class Issue3138 extends TestCase {
    public void test_0() throws Exception {
        VO vo = JSON.parseObject("{\"value\":{\"@type\":\"aa\"}}", VO.class);
    }

    public static class VO {
        @JSONField(parseFeatures = Feature.DisableSpecialKeyDetect)
        public Map<String, Object> value;

            

Reported by PMD.

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

Line: 11

                      String s = "{\"alarmLevel\":null,\"error\":null,\"errorCount\":0,\"maxAlarmCount\":10,\"warn\":null,"
                + "\"warnCount\":0}";
        TopAlarm b = JSON.parseObject(s, TopAlarm.class);
        System.out.println(JSON.toJSONString(b));
    }

    public static class TopAlarm {

        private Double error;                                  //为null表示不报警

            

Reported by PMD.

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

Line: 7

              import junit.framework.TestCase;

public class Issue_for_dianxing extends TestCase {
    public void test_0() throws Exception {
        String s = "{\"alarmLevel\":null,\"error\":null,\"errorCount\":0,\"maxAlarmCount\":10,\"warn\":null,"
                + "\"warnCount\":0}";
        TopAlarm b = JSON.parseObject(s, TopAlarm.class);
        System.out.println(JSON.toJSONString(b));
    }

            

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

              import junit.framework.TestCase;

public class Issue_for_dianxing extends TestCase {
    public void test_0() throws Exception {
        String s = "{\"alarmLevel\":null,\"error\":null,\"errorCount\":0,\"maxAlarmCount\":10,\"warn\":null,"
                + "\"warnCount\":0}";
        TopAlarm b = JSON.parseObject(s, TopAlarm.class);
        System.out.println(JSON.toJSONString(b));
    }

            

Reported by PMD.

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

Line: 14

                      System.out.println(JSON.toJSONString(b));
    }

    public static class TopAlarm {

        private Double error;                                  //为null表示不报警
        private int errorCount;
        private Double warn;                                   //为null表示不报警
        private int warnCount;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_3200/Issue3264.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: 16

               * @Date :Created in 21:25 2020/6/22
 */
public class Issue3264 extends TestCase {
    public void test_for_issue() throws Exception {
        MyData data = MyData.builder().isTest(true).build();
        String string = JSON.toJSONString(data);
        Assert.assertTrue(string.contains("is_test"));
    }


            

Reported by PMD.

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

Line: 17

               */
public class Issue3264 extends TestCase {
    public void test_for_issue() throws Exception {
        MyData data = MyData.builder().isTest(true).build();
        String string = JSON.toJSONString(data);
        Assert.assertTrue(string.contains("is_test"));
    }

    @Data

            

Reported by PMD.

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

Line: 17

               */
public class Issue3264 extends TestCase {
    public void test_for_issue() throws Exception {
        MyData data = MyData.builder().isTest(true).build();
        String string = JSON.toJSONString(data);
        Assert.assertTrue(string.contains("is_test"));
    }

    @Data

            

Reported by PMD.

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

Line: 19

                  public void test_for_issue() throws Exception {
        MyData data = MyData.builder().isTest(true).build();
        String string = JSON.toJSONString(data);
        Assert.assertTrue(string.contains("is_test"));
    }

    @Data
    @Builder
    @AllArgsConstructor

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1800/Issue1879.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: 19

              //        M1 m = JSON.parseObject(json, M1.class);
//    }

    public void test_for_issue_2() throws Exception {
        String json = "{\n" +
                "   \"ids\" : \"1,2,3\"\n" +
                "}";
        M2 m = JSON.parseObject(json, M2.class);
    }

            

Reported by PMD.

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

Line: 19

              //        M1 m = JSON.parseObject(json, M1.class);
//    }

    public void test_for_issue_2() throws Exception {
        String json = "{\n" +
                "   \"ids\" : \"1,2,3\"\n" +
                "}";
        M2 m = JSON.parseObject(json, M2.class);
    }

            

Reported by PMD.

Avoid unused local variables such as 'm'.
Design

Line: 23

                      String json = "{\n" +
                "   \"ids\" : \"1,2,3\"\n" +
                "}";
        M2 m = JSON.parseObject(json, M2.class);
    }

    public static class M1 {
        private List<Long> ids;


            

Reported by PMD.

Found 'DU'-anomaly for variable 'm' (lines '23'-'24').
Error

Line: 23

                      String json = "{\n" +
                "   \"ids\" : \"1,2,3\"\n" +
                "}";
        M2 m = JSON.parseObject(json, M2.class);
    }

    public static class M1 {
        private List<Long> ids;


            

Reported by PMD.