The following issues were found

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

Line: 32

                      
        String text = JSON.toJSONString(tigers, SerializerFeature.WriteClassName);
        
        System.out.println(text);
        Tigers tigers1 = (Tigers) JSON.parse(text);
        Assert.assertNotNull(tigers1.getTiger());
    }
}

            

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

              

public class Bug_for_dubbo extends TestCase {
    protected void setUp() throws Exception {
        ParserConfig.global.addAccept("com.alibaba.json.test.dubbo.Tigers");
    }

    public void test_0 () throws Exception {
        HelloServiceImpl helloService = new HelloServiceImpl();

            

Reported by PMD.

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

Line: 16

              
public class Bug_for_dubbo extends TestCase {
    protected void setUp() throws Exception {
        ParserConfig.global.addAccept("com.alibaba.json.test.dubbo.Tigers");
    }

    public void test_0 () throws Exception {
        HelloServiceImpl helloService = new HelloServiceImpl();
        

            

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.test.dubbo.Tigers");
    }

    public void test_0 () throws Exception {
        HelloServiceImpl helloService = new HelloServiceImpl();
        
        Tiger tiger = new Tiger();
        tiger.setTigerName("东北虎");
        tiger.setTigerSex(true);

            

Reported by PMD.

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

Line: 28

                      //Tiger tigers = helloService.eatTiger(tiger).getTiger();
        
        Tigers tigers = helloService.eatTiger(tiger);
        Assert.assertNotNull(tigers.getTiger());
        
        String text = JSON.toJSONString(tigers, SerializerFeature.WriteClassName);
        
        System.out.println(text);
        Tigers tigers1 = (Tigers) JSON.parse(text);

            

Reported by PMD.

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

Line: 34

                      
        System.out.println(text);
        Tigers tigers1 = (Tigers) JSON.parse(text);
        Assert.assertNotNull(tigers1.getTiger());
    }
}

            

Reported by PMD.

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

              
public class Bug_for_hifor_issue_511 extends TestCase {

    public void test_for_issue() throws Exception {
        String resultString = "{"
                + "    \"errCode\": 0, "
                + "    \"errMsg\": \"ok\", "
                + "    \"model\": {"
                + "        \"doctor\": {"

            

Reported by PMD.

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

Line: 60

                              + "}";
        
        TResult<BookConfirmVo> result = JSON.parseObject(resultString, new TypeReference<TResult<BookConfirmVo>>() { });
        Assert.assertSame(BookConfirmVo.class, result.model.getClass());
    }
    
    public static class TResult<T> {
        int errCode = 0;
        String errMsg = "ok";

            

Reported by PMD.

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

Line: 63

                      Assert.assertSame(BookConfirmVo.class, result.model.getClass());
    }
    
    public static class TResult<T> {
        int errCode = 0;
        String errMsg = "ok";
        List<T> data = null;
        String stringData;
        Integer intData;

            

Reported by PMD.

Avoid using redundant field initializer for 'errCode'
Performance

Line: 64

                  }
    
    public static class TResult<T> {
        int errCode = 0;
        String errMsg = "ok";
        List<T> data = null;
        String stringData;
        Integer intData;
        T model;

            

Reported by PMD.

Avoid using redundant field initializer for 'data'
Performance

Line: 66

                  public static class TResult<T> {
        int errCode = 0;
        String errMsg = "ok";
        List<T> data = null;
        String stringData;
        Integer intData;
        T model;
        String url;
        

            

Reported by PMD.

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

Line: 149

                      byte[] pic;
    }

    public static class PatientInfoVo extends PatientInfo {

        String cols;
        String glide;
        String s_ic_no;


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_283.java
6 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: 15

              
public class Bug_for_issue_283 extends TestCase {

    public void test_for_issue() throws Exception {
        String jsons = "[[1,1,1,2,3],[2,3,12,3,4],[1],[2]]";

        Collection<Collection<Integer>> collections //
                = JSON.parseObject(jsons, new TypeReference<Collection<Collection<Integer>>>() {
                });

            

Reported by PMD.

Avoid using implementation types like 'ArrayList'; use the interface instead
Design

Line: 23

                              });
        
        Assert.assertEquals(4, collections.size());
        Assert.assertEquals(ArrayList.class, collections.getClass());
        
        Collection<Integer> firstItemCollection = collections.iterator().next();
        Assert.assertEquals(5, firstItemCollection.size());
        Assert.assertEquals(ArrayList.class, firstItemCollection.getClass());
    }

            

Reported by PMD.

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

Line: 25

                      Assert.assertEquals(4, collections.size());
        Assert.assertEquals(ArrayList.class, collections.getClass());
        
        Collection<Integer> firstItemCollection = collections.iterator().next();
        Assert.assertEquals(5, firstItemCollection.size());
        Assert.assertEquals(ArrayList.class, firstItemCollection.getClass());
    }
}

            

Reported by PMD.

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

Line: 26

                      Assert.assertEquals(ArrayList.class, collections.getClass());
        
        Collection<Integer> firstItemCollection = collections.iterator().next();
        Assert.assertEquals(5, firstItemCollection.size());
        Assert.assertEquals(ArrayList.class, firstItemCollection.getClass());
    }
}

            

Reported by PMD.

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

Line: 27

                      
        Collection<Integer> firstItemCollection = collections.iterator().next();
        Assert.assertEquals(5, firstItemCollection.size());
        Assert.assertEquals(ArrayList.class, firstItemCollection.getClass());
    }
}

            

Reported by PMD.

Avoid using implementation types like 'ArrayList'; use the interface instead
Design

Line: 27

                      
        Collection<Integer> firstItemCollection = collections.iterator().next();
        Assert.assertEquals(5, firstItemCollection.size());
        Assert.assertEquals(ArrayList.class, firstItemCollection.getClass());
    }
}

            

Reported by PMD.

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

Line: 11

              import junit.framework.TestCase;

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

    public void test_for_issue() throws Exception {
        String text = "{\"id\":123,\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_issue_291$VO\",\"value\":54321}";

            

Reported by PMD.

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

Line: 12

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

    public void test_for_issue() throws Exception {
        String text = "{\"id\":123,\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_issue_291$VO\",\"value\":54321}";
        

            

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

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

    public void test_for_issue() throws Exception {
        String text = "{\"id\":123,\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_issue_291$VO\",\"value\":54321}";
        
        Object o = JSON.parse(text);
        Assert.assertEquals(VO.class, o.getClass());
    }

            

Reported by PMD.

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

Line: 19

                      String text = "{\"id\":123,\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_issue_291$VO\",\"value\":54321}";
        
        Object o = JSON.parse(text);
        Assert.assertEquals(VO.class, o.getClass());
    }
    
    public void test_for_issue_private() throws Exception {
        String text = "{\"id\":123,\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_issue_291$VO\",\"value\":54321}";
        

            

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(VO.class, o.getClass());
    }
    
    public void test_for_issue_private() throws Exception {
        String text = "{\"id\":123,\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_issue_291$VO\",\"value\":54321}";
        
        Object o = JSON.parse(text);
        Assert.assertEquals(VO.class, o.getClass());
    }

            

Reported by PMD.

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

Line: 26

                      String text = "{\"id\":123,\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_issue_291$VO\",\"value\":54321}";
        
        Object o = JSON.parse(text);
        Assert.assertEquals(VO.class, o.getClass());
    }
    
    public static class VO {
        public int id;
        public int value;

            

Reported by PMD.

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

    public void test_for_issue() throws Exception {
        String text = "{\"downloadSpeed\":631055,\"responseTime\":1.435,\"url\":\"http://m2.music.126.net/xUqntwOHwpJdXsO_H-kHsw==/5817516022676667.mp3?v=50710699\"}";
        JSONObject obj = (JSONObject) JSON.parse(text);
        Assert.assertEquals(631055, obj.get("downloadSpeed"));
    }


            

Reported by PMD.

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

Line: 15

                  public void test_for_issue() throws Exception {
        String text = "{\"downloadSpeed\":631055,\"responseTime\":1.435,\"url\":\"http://m2.music.126.net/xUqntwOHwpJdXsO_H-kHsw==/5817516022676667.mp3?v=50710699\"}";
        JSONObject obj = (JSONObject) JSON.parse(text);
        Assert.assertEquals(631055, obj.get("downloadSpeed"));
    }

    public void test_for_issue_space() throws Exception {
        String text = "{\"downloadSpeed\":631055} ";
        JSONObject obj = (JSONObject) JSON.parse(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: 18

                      Assert.assertEquals(631055, obj.get("downloadSpeed"));
    }

    public void test_for_issue_space() throws Exception {
        String text = "{\"downloadSpeed\":631055} ";
        JSONObject obj = (JSONObject) JSON.parse(text);
        Assert.assertEquals(631055, obj.get("downloadSpeed"));
    }
    

            

Reported by PMD.

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

Line: 21

                  public void test_for_issue_space() throws Exception {
        String text = "{\"downloadSpeed\":631055} ";
        JSONObject obj = (JSONObject) JSON.parse(text);
        Assert.assertEquals(631055, obj.get("downloadSpeed"));
    }
    

    public void test_for_issue_127() throws Exception {
        String text = "{\"downloadSpeed\":631055}\u007f";

            

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

                  }
    

    public void test_for_issue_127() throws Exception {
        String text = "{\"downloadSpeed\":631055}\u007f";
        JSONObject obj = (JSONObject) JSON.parse(text);
        Assert.assertEquals(631055, obj.get("downloadSpeed"));
    }
}

            

Reported by PMD.

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

Line: 28

                  public void test_for_issue_127() throws Exception {
        String text = "{\"downloadSpeed\":631055}\u007f";
        JSONObject obj = (JSONObject) JSON.parse(text);
        Assert.assertEquals(631055, obj.get("downloadSpeed"));
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_297.java
6 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: 15

              
public class Bug_for_issue_297 extends TestCase {

    public void test_for_issue() throws Exception {
        Response<User> resp = parse("{\"id\":1001,\"values\":[{}]}", User.class);
        Assert.assertEquals(1001, resp.id);
        Assert.assertEquals(1, resp.values.size());
        Assert.assertEquals(User.class, resp.values.get(0).getClass());
    }

            

Reported by PMD.

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

Line: 18

                  public void test_for_issue() throws Exception {
        Response<User> resp = parse("{\"id\":1001,\"values\":[{}]}", User.class);
        Assert.assertEquals(1001, resp.id);
        Assert.assertEquals(1, resp.values.size());
        Assert.assertEquals(User.class, resp.values.get(0).getClass());
    }

    public <T> Response<T> parse(String text, Class<T> clazz) {
        ParameterizedTypeImpl type = new ParameterizedTypeImpl(new Type[] { User.class }, null, Response.class);

            

Reported by PMD.

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

Line: 19

                      Response<User> resp = parse("{\"id\":1001,\"values\":[{}]}", User.class);
        Assert.assertEquals(1001, resp.id);
        Assert.assertEquals(1, resp.values.size());
        Assert.assertEquals(User.class, resp.values.get(0).getClass());
    }

    public <T> Response<T> parse(String text, Class<T> clazz) {
        ParameterizedTypeImpl type = new ParameterizedTypeImpl(new Type[] { User.class }, null, Response.class);
        return JSON.parseObject(text, type);

            

Reported by PMD.

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

Line: 19

                      Response<User> resp = parse("{\"id\":1001,\"values\":[{}]}", User.class);
        Assert.assertEquals(1001, resp.id);
        Assert.assertEquals(1, resp.values.size());
        Assert.assertEquals(User.class, resp.values.get(0).getClass());
    }

    public <T> Response<T> parse(String text, Class<T> clazz) {
        ParameterizedTypeImpl type = new ParameterizedTypeImpl(new Type[] { User.class }, null, Response.class);
        return JSON.parseObject(text, type);

            

Reported by PMD.

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

Line: 29

              
    public static class Response<T> {

        public long    id;
        public List<T> values;
    }

    public static class User {


            

Reported by PMD.

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

Line: 30

                  public static class Response<T> {

        public long    id;
        public List<T> values;
    }

    public static class User {

    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_jiangwei2.java
6 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 com.alibaba.fastjson.JSONArray;

public class Bug_for_jiangwei2 extends TestCase {
	public void test_for_jiangwei() throws Exception {
//		String str = "[2,'韩国篮球联赛','仁川大象(男篮)','首尔SK骑士 男篮',['大/小',3],'总进球 : 138.5 @ 0-0','','大','0.66','',1,25,200,1,0,0,'True','False',0,'','','',0,0,19819905,1,'h',145528,0]";
//		JSONArray array = JSON.parseArray(str);
		String str = "[]";
		str = "[]";
		JSONArray array = JSON.parseArray(str);

            

Reported by PMD.

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

Line: 9

              import com.alibaba.fastjson.JSONArray;

public class Bug_for_jiangwei2 extends TestCase {
	public void test_for_jiangwei() throws Exception {
//		String str = "[2,'韩国篮球联赛','仁川大象(男篮)','首尔SK骑士 男篮',['大/小',3],'总进球 : 138.5 @ 0-0','','大','0.66','',1,25,200,1,0,0,'True','False',0,'','','',0,0,19819905,1,'h',145528,0]";
//		JSONArray array = JSON.parseArray(str);
		String str = "[]";
		str = "[]";
		JSONArray array = JSON.parseArray(str);

            

Reported by PMD.

The initializer for variable 'str' is never used (overwritten on line 13)
Design

Line: 12

              	public void test_for_jiangwei() throws Exception {
//		String str = "[2,'韩国篮球联赛','仁川大象(男篮)','首尔SK骑士 男篮',['大/小',3],'总进球 : 138.5 @ 0-0','','大','0.66','',1,25,200,1,0,0,'True','False',0,'','','',0,0,19819905,1,'h',145528,0]";
//		JSONArray array = JSON.parseArray(str);
		String str = "[]";
		str = "[]";
		JSONArray array = JSON.parseArray(str);
	}
}

            

Reported by PMD.

Avoid unused local variables such as 'array'.
Design

Line: 14

              //		JSONArray array = JSON.parseArray(str);
		String str = "[]";
		str = "[]";
		JSONArray array = JSON.parseArray(str);
	}
}

            

Reported by PMD.

Found 'DD'-anomaly for variable 'str' (lines '12'-'13').
Error

Line: 12

              	public void test_for_jiangwei() throws Exception {
//		String str = "[2,'韩国篮球联赛','仁川大象(男篮)','首尔SK骑士 男篮',['大/小',3],'总进球 : 138.5 @ 0-0','','大','0.66','',1,25,200,1,0,0,'True','False',0,'','','',0,0,19819905,1,'h',145528,0]";
//		JSONArray array = JSON.parseArray(str);
		String str = "[]";
		str = "[]";
		JSONArray array = JSON.parseArray(str);
	}
}

            

Reported by PMD.

Found 'DU'-anomaly for variable 'array' (lines '14'-'15').
Error

Line: 14

              //		JSONArray array = JSON.parseArray(str);
		String str = "[]";
		str = "[]";
		JSONArray array = JSON.parseArray(str);
	}
}

            

Reported by PMD.

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

Line: 32

                              "}";

        WhaleGeneratePrivacyResponseBody resp = JSON.parseObject(str, WhaleGeneratePrivacyResponseBody.class);
        System.out.println(resp.resultInfo.resultStatus);

//        System.out.println(str);
    }



            

Reported by PMD.

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

Line: 10

              
public class Bug_for_km
        extends TestCase {
    public void test_for_issue() throws Exception {
        String str = "{\n" +
                "\t\"bizSubmitInfos\": [{\n" +
                "\t\t\"bizType\": \"ISSUE\",\n" +
                "\t\t\"privacyInfo\": \"{\\\"bcAnchorMid\\\":\\\"101CITI000000001000\\\",\\\"bcMid\\\":\\\"102BABA000000000001\\\",\\\"bcSubmitMid\\\":\\\"102BABA000000000001\\\",\\\"bizId\\\":\\\"transfer_autoTest_pri_weiweitestt_8857136636875877184\\\",\\\"bizType\\\":\\\"ISSUE\\\",\\\"currency\\\":\\\"USD\\\",\\\"exchangeRate\\\":{\\\"encryptedExchangeRate\\\":\\\"123\\\",\\\"envelopeKeyInfos\\\":{}},\\\"pcAmount\\\":{\\\"envelopeKeyInfos\\\":{},\\\"proof\\\":\\\"proff\\\"}}\",\n" +
                "\t\t\"submitInfoList\": [{\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: 10

              
public class Bug_for_km
        extends TestCase {
    public void test_for_issue() throws Exception {
        String str = "{\n" +
                "\t\"bizSubmitInfos\": [{\n" +
                "\t\t\"bizType\": \"ISSUE\",\n" +
                "\t\t\"privacyInfo\": \"{\\\"bcAnchorMid\\\":\\\"101CITI000000001000\\\",\\\"bcMid\\\":\\\"102BABA000000000001\\\",\\\"bcSubmitMid\\\":\\\"102BABA000000000001\\\",\\\"bizId\\\":\\\"transfer_autoTest_pri_weiweitestt_8857136636875877184\\\",\\\"bizType\\\":\\\"ISSUE\\\",\\\"currency\\\":\\\"USD\\\",\\\"exchangeRate\\\":{\\\"encryptedExchangeRate\\\":\\\"123\\\",\\\"envelopeKeyInfos\\\":{}},\\\"pcAmount\\\":{\\\"envelopeKeyInfos\\\":{},\\\"proof\\\":\\\"proff\\\"}}\",\n" +
                "\t\t\"submitInfoList\": [{\n" +

            

Reported by PMD.

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

Line: 39

              

    public static class WhaleGeneratePrivacyResponseBody {
        public ResultInfo resultInfo;
    }

    /**
     * @author freud.wy
     * @version $Id: ResultInfo.java, v 0.1 2019-05-28 上午11:02 freud.wy Exp $$

            

Reported by PMD.

The class 'ResultInfo' is suspected to be a Data Class (WOC=11.111%, NOPA=0, NOAM=8, WMC=9)
Design

Line: 46

                   * @author freud.wy
     * @version $Id: ResultInfo.java, v 0.1 2019-05-28 上午11:02 freud.wy Exp $$
     */
    public static class ResultInfo {
        private String resultStatus;
        private String resultCodeId;
        private String resultCode;
        private String resultMsg;


            

Reported by PMD.

Avoid unused imports such as 'java.util.concurrent.TimeUnit'
Design

Line: 6

              import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;

import java.util.concurrent.TimeUnit;

public class Bug_for_km
        extends TestCase {
    public void test_for_issue() throws Exception {
        String str = "{\n" +

            

Reported by PMD.

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

Line: 29

                      String simpleDateFormatJson = JSON.toJSONString(simpleDateFormat, SerializerFeature.WriteClassName,
                                                        SerializerFeature.WriteMapNullValue);

        System.out.println(simpleDateFormatJson);

        java.text.SimpleDateFormat format = (java.text.SimpleDateFormat) JSON.parse(simpleDateFormatJson);
        Assert.assertEquals("MM-dd-yyyy", format.toPattern());

    }

            

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 Bug_for_lenolix_11 extends TestCase {
    protected void setUp() throws Exception {
        JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
        JSON.defaultLocale = Locale.CHINA;

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

            

Reported by PMD.

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

Line: 19

                      JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
        JSON.defaultLocale = Locale.CHINA;

        ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_lenolix_11.");
    }
    
    public void test_for_objectKey() throws Exception {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd-yyyy", JSON.defaultLocale);
        simpleDateFormat.setTimeZone(JSON.defaultTimeZone);

            

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

                      ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_lenolix_11.");
    }
    
    public void test_for_objectKey() throws Exception {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd-yyyy", JSON.defaultLocale);
        simpleDateFormat.setTimeZone(JSON.defaultTimeZone);

        String simpleDateFormatJson = JSON.toJSONString(simpleDateFormat, SerializerFeature.WriteClassName,
                                                        SerializerFeature.WriteMapNullValue);

            

Reported by PMD.

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

Line: 32

                      System.out.println(simpleDateFormatJson);

        java.text.SimpleDateFormat format = (java.text.SimpleDateFormat) JSON.parse(simpleDateFormatJson);
        Assert.assertEquals("MM-dd-yyyy", format.toPattern());

    }

    public static class User {


            

Reported by PMD.

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

Line: 36

              
    }

    public static class User {

        private int     id;
        private Boolean isBoy;
        private String  name;


            

Reported by PMD.

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

    public void test_emptyStr() throws Exception {
        JSON.parseObject("{\"value\":\"\"}", VO.class);
    }
    
    public void test_null() throws Exception {
        JSON.parseObject("{\"value\":null}", VO.class);

            

Reported by PMD.

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

Line: 9

              
public class Bug_for_primitive_boolean extends TestCase {

    public void test_emptyStr() throws Exception {
        JSON.parseObject("{\"value\":\"\"}", VO.class);
    }
    
    public void test_null() throws Exception {
        JSON.parseObject("{\"value\":null}", 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: 13

                      JSON.parseObject("{\"value\":\"\"}", VO.class);
    }
    
    public void test_null() throws Exception {
        JSON.parseObject("{\"value\":null}", VO.class);
    }
    
    public void test_strNull() throws Exception {
        JSON.parseObject("{\"value\":\"null\"}", VO.class);

            

Reported by PMD.

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

Line: 13

                      JSON.parseObject("{\"value\":\"\"}", VO.class);
    }
    
    public void test_null() throws Exception {
        JSON.parseObject("{\"value\":null}", VO.class);
    }
    
    public void test_strNull() throws Exception {
        JSON.parseObject("{\"value\":\"null\"}", 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: 17

                      JSON.parseObject("{\"value\":null}", VO.class);
    }
    
    public void test_strNull() throws Exception {
        JSON.parseObject("{\"value\":\"null\"}", VO.class);
    }

    public static class VO {


            

Reported by PMD.

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

Line: 17

                      JSON.parseObject("{\"value\":null}", VO.class);
    }
    
    public void test_strNull() throws Exception {
        JSON.parseObject("{\"value\":\"null\"}", VO.class);
    }

    public static class VO {


            

Reported by PMD.