The following issues were found

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

    public void test_class_array() throws Exception {
        String text = "{\"clazz\":\"[Ljava.lang.String;\",\"value\":\"[\\\"武汉银行\\\"]\"}";
        
        VO vo = JSON.parseObject(text, VO.class);
        
        Assert.assertEquals(String[].class, vo.getClazz());

            

Reported by PMD.

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

Line: 15

                      
        VO vo = JSON.parseObject(text, VO.class);
        
        Assert.assertEquals(String[].class, vo.getClazz());
    }
    
    public void test_class() throws Exception {
        String text = "{\"clazz\":\"Ljava.lang.String;\",\"value\":\"[\\\"武汉银行\\\"]\"}";
        

            

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(String[].class, vo.getClazz());
    }
    
    public void test_class() throws Exception {
        String text = "{\"clazz\":\"Ljava.lang.String;\",\"value\":\"[\\\"武汉银行\\\"]\"}";
        
        VO vo = JSON.parseObject(text, VO.class);
        Assert.assertEquals(String.class, vo.getClazz());
    }

            

Reported by PMD.

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

Line: 22

                      String text = "{\"clazz\":\"Ljava.lang.String;\",\"value\":\"[\\\"武汉银行\\\"]\"}";
        
        VO vo = JSON.parseObject(text, VO.class);
        Assert.assertEquals(String.class, vo.getClazz());
    }

    public static class VO {

        private Class<?> clazz;

            

Reported by PMD.

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

Line: 25

                      Assert.assertEquals(String.class, vo.getClazz());
    }

    public static class VO {

        private Class<?> clazz;
        private Object   value;

        public Class<?> getClazz() {

            

Reported by PMD.

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

    public void test_readOnly() throws Exception {
        Model model = new Model();
        model.value.set(1001);

        String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":1001}", text);

            

Reported by PMD.

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

Line: 15

              
    public void test_readOnly() throws Exception {
        Model model = new Model();
        model.value.set(1001);

        String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":1001}", text);
        Model model2 = JSON.parseObject(text, Model.class);
        Assert.assertEquals(model.value.get(), model2.value.get());

            

Reported by PMD.

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

Line: 20

                      String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":1001}", text);
        Model model2 = JSON.parseObject(text, Model.class);
        Assert.assertEquals(model.value.get(), model2.value.get());
    }

    public static class Model {
        public final AtomicInteger value = new AtomicInteger();


            

Reported by PMD.

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

Line: 20

                      String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":1001}", text);
        Model model2 = JSON.parseObject(text, Model.class);
        Assert.assertEquals(model.value.get(), model2.value.get());
    }

    public static class Model {
        public final AtomicInteger value = new AtomicInteger();


            

Reported by PMD.

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

Line: 24

                  }

    public static class Model {
        public final AtomicInteger value = new AtomicInteger();

    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/DateParserTest_sql.java
5 issues
A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 15

              @SuppressWarnings("deprecation")
public class DateParserTest_sql extends TestCase {

    public void f_test_date_0() throws Exception {
        DefaultJSONParser parser = new DefaultJSONParser("1294552193254");

        java.sql.Date date = parser.parseObject(java.sql.Date.class);

        Assert.assertEquals(new java.sql.Date(1294552193254L), date);

            

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

                      parser.close();
    }

    public void test_date_1() throws Exception {
        int features = JSON.DEFAULT_PARSER_FEATURE;
        features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
        DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09T13:49:53.254\"", ParserConfig.getGlobalInstance(), features);

        java.sql.Date date = parser.parseObject(java.sql.Date.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: 36

                      parser.close();
    }

    public void test_date_2() throws Exception {
        int features = JSON.DEFAULT_PARSER_FEATURE;
        DefaultJSONParser parser = new DefaultJSONParser("new Date(1294552193254)", ParserConfig.getGlobalInstance(), features);

        java.sql.Date date = parser.parseObject(java.sql.Date.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: 46

                      parser.close();
    }

    public void test_date_3() throws Exception {
        int features = JSON.DEFAULT_PARSER_FEATURE;
        features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
        DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09T13:49:53\"", ParserConfig.getGlobalInstance(), features);

        java.sql.Date date = parser.parseObject(java.sql.Date.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: 57

                      parser.close();
    }

    public void test_date_4() throws Exception {
        int features = JSON.DEFAULT_PARSER_FEATURE;
        features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
        DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09\"", ParserConfig.getGlobalInstance(), features);

        java.sql.Date date = parser.parseObject(java.sql.Date.class);

            

Reported by PMD.

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

    public void test_readOnly() throws Exception {
        Model model = new Model();
        model.value.set(true);

        String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":true}", text);

            

Reported by PMD.

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

Line: 15

              
    public void test_readOnly() throws Exception {
        Model model = new Model();
        model.value.set(true);

        String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":true}", text);
        Model model2 = JSON.parseObject(text, Model.class);
        Assert.assertEquals(model.value.get(), model2.value.get());

            

Reported by PMD.

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

Line: 20

                      String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":true}", text);
        Model model2 = JSON.parseObject(text, Model.class);
        Assert.assertEquals(model.value.get(), model2.value.get());
    }

    public static class Model {
        public final AtomicBoolean value = new AtomicBoolean();


            

Reported by PMD.

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

Line: 20

                      String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":true}", text);
        Model model2 = JSON.parseObject(text, Model.class);
        Assert.assertEquals(model.value.get(), model2.value.get());
    }

    public static class Model {
        public final AtomicBoolean value = new AtomicBoolean();


            

Reported by PMD.

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

Line: 24

                  }

    public static class Model {
        public final AtomicBoolean value = new AtomicBoolean();

    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1600/issue_1699/obj/RatingDetailBO.java
5 issues
This class has a bunch of public methods and attributes
Design

Line: 1

              package com.alibaba.json.bvt.issue_1600.issue_1699.obj;

import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.json.bvt.issue_1600.issue_1699.def.InnerTypeMEnum;
import com.alibaba.json.bvt.issue_1600.issue_1699.def.RatingDetailIsJoinMEnum;
import com.alibaba.json.bvt.issue_1600.issue_1699.def.*;

import java.io.Serializable;
import java.math.BigDecimal;

            

Reported by PMD.

Too many fields
Design

Line: 17

              /**
 *
 */
public class RatingDetailBO implements Serializable {

    private static final long serialVersionUID = 6413142622719509002L;

    /**
     * *

            

Reported by PMD.

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

Line: 69

                  /**
     * 主订单ID
     */
    private Long pTradeId;

    /**
     * 子订单ID
     */
    private Long tradeId;

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.annotation.JSONType'
Design

Line: 3

              package com.alibaba.json.bvt.issue_1600.issue_1699.obj;

import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.json.bvt.issue_1600.issue_1699.def.InnerTypeMEnum;
import com.alibaba.json.bvt.issue_1600.issue_1699.def.RatingDetailIsJoinMEnum;
import com.alibaba.json.bvt.issue_1600.issue_1699.def.*;

import java.io.Serializable;
import java.math.BigDecimal;

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.json.bvt.issue_1600.issue_1699.def'
Design

Line: 6

              import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.json.bvt.issue_1600.issue_1699.def.InnerTypeMEnum;
import com.alibaba.json.bvt.issue_1600.issue_1699.def.RatingDetailIsJoinMEnum;
import com.alibaba.json.bvt.issue_1600.issue_1699.def.*;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Currency;
import java.util.Date;

            

Reported by PMD.

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

    public void test_for_issue() throws Exception {
        String str = createLargeBasicStr();
        SerializeWriter writer = new SerializeWriter();
        //写入大于12K的字符串
        writer.writeString(str);
        writer.writeString(str);

            

Reported by PMD.

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

Line: 23

              
        //检查bytesLocal大小,如果缓存成功应该大于等于输出的bytes长度
        Field bytesBufLocalField = SerializeWriter.class.getDeclaredField("bytesBufLocal");
        bytesBufLocalField.setAccessible(true);
        ThreadLocal<byte[]> bytesBufLocal = (ThreadLocal<byte[]>) bytesBufLocalField.get(null);
        byte[] bytesLocal = bytesBufLocal.get();
        Assert.assertNotNull("bytesLocal is null", bytesLocal);
        Assert.assertTrue("bytesLocal is smaller than expected", bytesLocal.length >= bytes.length);


            

Reported by PMD.

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

Line: 24

                      //检查bytesLocal大小,如果缓存成功应该大于等于输出的bytes长度
        Field bytesBufLocalField = SerializeWriter.class.getDeclaredField("bytesBufLocal");
        bytesBufLocalField.setAccessible(true);
        ThreadLocal<byte[]> bytesBufLocal = (ThreadLocal<byte[]>) bytesBufLocalField.get(null);
        byte[] bytesLocal = bytesBufLocal.get();
        Assert.assertNotNull("bytesLocal is null", bytesLocal);
        Assert.assertTrue("bytesLocal is smaller than expected", bytesLocal.length >= bytes.length);

    }

            

Reported by PMD.

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

Line: 25

                      Field bytesBufLocalField = SerializeWriter.class.getDeclaredField("bytesBufLocal");
        bytesBufLocalField.setAccessible(true);
        ThreadLocal<byte[]> bytesBufLocal = (ThreadLocal<byte[]>) bytesBufLocalField.get(null);
        byte[] bytesLocal = bytesBufLocal.get();
        Assert.assertNotNull("bytesLocal is null", bytesLocal);
        Assert.assertTrue("bytesLocal is smaller than expected", bytesLocal.length >= bytes.length);

    }


            

Reported by PMD.

Found 'DU'-anomaly for variable 'tmp' (lines '32'-'38').
Error

Line: 32

                  }

    private String createLargeBasicStr() {
        String tmp = new String(IOUtils.DIGITS);
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < 400; i++) {
            builder.append(tmp);
        }
        return builder.toString();

            

Reported by PMD.

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

Line: 14

                  public void test_parse() throws Exception {
        String text = "{\"code\":0,\"message\":\"Register Successfully!\",\"status\":\"OK\"}";
        Map map = JSON.parseObject(text, Map.class);
        System.out.println(map.get("code").getClass());
    }
}

            

Reported by PMD.

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

Line: 11

              

public class ProductViewTest extends TestCase {
    public void test_parse() throws Exception {
        String text = "{\"code\":0,\"message\":\"Register Successfully!\",\"status\":\"OK\"}";
        Map map = JSON.parseObject(text, Map.class);
        System.out.println(map.get("code").getClass());
    }
}

            

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

              

public class ProductViewTest extends TestCase {
    public void test_parse() throws Exception {
        String text = "{\"code\":0,\"message\":\"Register Successfully!\",\"status\":\"OK\"}";
        Map map = JSON.parseObject(text, Map.class);
        System.out.println(map.get("code").getClass());
    }
}

            

Reported by PMD.

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

Line: 14

                  public void test_parse() throws Exception {
        String text = "{\"code\":0,\"message\":\"Register Successfully!\",\"status\":\"OK\"}";
        Map map = JSON.parseObject(text, Map.class);
        System.out.println(map.get("code").getClass());
    }
}

            

Reported by PMD.

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

Line: 14

                  public void test_parse() throws Exception {
        String text = "{\"code\":0,\"message\":\"Register Successfully!\",\"status\":\"OK\"}";
        Map map = JSON.parseObject(text, Map.class);
        System.out.println(map.get("code").getClass());
    }
}

            

Reported by PMD.

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

Line: 15

                      testClass.setMyException(myException);

        String jsonString = JSON.toJSONString(testClass, SerializerFeature.NotWriteDefaultValue);
        System.out.println(jsonString);

        TestClass testClass1 = JSON.parseObject(jsonString, TestClass.class);
        System.out.println(testClass1);
    }


            

Reported by PMD.

System.out.println is used
Design

Line: 18

                      System.out.println(jsonString);

        TestClass testClass1 = JSON.parseObject(jsonString, TestClass.class);
        System.out.println(testClass1);
    }

    public static enum EnumTest{
        FIRST("111","111"),
        SECOND("222","222");

            

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

              import junit.framework.TestCase;

public class Issue3217 extends TestCase {
    public void testException(){
        MyException myException = new MyException();
        myException.enumTest = EnumTest.FIRST;
        TestClass testClass = new TestClass();
        testClass.setMyException(myException);


            

Reported by PMD.

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

Line: 8

              import junit.framework.TestCase;

public class Issue3217 extends TestCase {
    public void testException(){
        MyException myException = new MyException();
        myException.enumTest = EnumTest.FIRST;
        TestClass testClass = new TestClass();
        testClass.setMyException(myException);


            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 49

                      }
    }

    public static class MyException extends Exception {
        private EnumTest enumTest;

        public EnumTest getEnumTest() {
            return enumTest;
        }

            

Reported by PMD.

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

              import java.time.LocalDateTime;

public class Issue1892 extends TestCase {
    public void test_for_issue() throws Exception {
        assertEquals("\"2018-10-10T00:00:00\"",
            JSON.toJSONString(
                    LocalDateTime.of(2018, 10, 10, 0, 0)
            )
        );

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 11

              
public class Issue1892 extends TestCase {
    public void test_for_issue() throws Exception {
        assertEquals("\"2018-10-10T00:00:00\"",
            JSON.toJSONString(
                    LocalDateTime.of(2018, 10, 10, 0, 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: 18

                      );
    }

    public void test_for_issue_1() throws Exception {
        String json = JSON.toJSONString(
                LocalDateTime.of(2018, 10, 10, 0, 0, 40, 788000000)
        );
        assertEquals("\"2018-10-10T00:00:40.788\"", json);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

                      String json = JSON.toJSONString(
                LocalDateTime.of(2018, 10, 10, 0, 0, 40, 788000000)
        );
        assertEquals("\"2018-10-10T00:00:40.788\"", json);
    }
}

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.serializer.SerializerFeature'
Design

Line: 4

              package com.alibaba.json.bvt.issue_1800;

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

import java.time.LocalDateTime;

public class Issue1892 extends TestCase {

            

Reported by PMD.

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

Line: 11

              import java.util.TimeZone;

public class Issue2156 extends TestCase {
    protected void setUp() throws Exception {
        JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
        JSON.defaultLocale = Locale.CHINA;
    }

//    public void test_for_issue() 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: 40

              //        assertEquals("\"2018-07-15\"", str);
//    }

    public void test_for_issue_time() throws Exception {
        java.sql.Time date = java.sql.Time.valueOf("12:13:14");
        String str = JSON.toJSONStringWithDateFormat(date, JSON.DEFFAULT_DATE_FORMAT);
        assertEquals("\"12:13:14\"", str);
    }
}

            

Reported by PMD.

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

Line: 41

              //    }

    public void test_for_issue_time() throws Exception {
        java.sql.Time date = java.sql.Time.valueOf("12:13:14");
        String str = JSON.toJSONStringWithDateFormat(date, JSON.DEFFAULT_DATE_FORMAT);
        assertEquals("\"12:13:14\"", str);
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 43

                  public void test_for_issue_time() throws Exception {
        java.sql.Time date = java.sql.Time.valueOf("12:13:14");
        String str = JSON.toJSONStringWithDateFormat(date, JSON.DEFFAULT_DATE_FORMAT);
        assertEquals("\"12:13:14\"", str);
    }
}

            

Reported by PMD.

Avoid unused imports such as 'java.text.SimpleDateFormat'
Design

Line: 6

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

import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.TimeZone;

public class Issue2156 extends TestCase {
    protected void setUp() throws Exception {

            

Reported by PMD.