The following issues were found

src/test/java/com/alibaba/json/test/JsonIteratorImageTest.java
39 issues
System.out.println is used
Design

Line: 43

                          long startMillis = System.currentTimeMillis();
            fastjson();
            long millis = System.currentTimeMillis() - startMillis;
            System.out.println("fastjson : " + millis);
        }

//        jsoniterator();
//        for (int i = 0; i < 5; ++i) {
//            long startMillis = System.currentTimeMillis();

            

Reported by PMD.

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

Line: 20

               * Created by wenshao on 27/12/2016.
 */
public class JsonIteratorImageTest extends TestCase {
    private String input = "{\"bitrate\":262144,\"duration\":18000000,\"format\":\"video/mpg4\",\"height\":480,\"persons\":[\"Bill Gates\",\"Steve Jobs\"],\"player\":\"JAVA\",\"size\":58982400,\"title\":\"Javaone Keynote\",\"uri\":\"http://javaone.com/keynote.mpg\",\"width\":640}";
    private byte[] inputBytes = input.getBytes();
    private TypeLiteral<Model> modelTypeLiteral; // this is thread-safe can reused
    private JsonIterator iter;

    private int COUNT = 1000 * 1000 * 1;

            

Reported by PMD.

Private field 'input' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 20

               * Created by wenshao on 27/12/2016.
 */
public class JsonIteratorImageTest extends TestCase {
    private String input = "{\"bitrate\":262144,\"duration\":18000000,\"format\":\"video/mpg4\",\"height\":480,\"persons\":[\"Bill Gates\",\"Steve Jobs\"],\"player\":\"JAVA\",\"size\":58982400,\"title\":\"Javaone Keynote\",\"uri\":\"http://javaone.com/keynote.mpg\",\"width\":640}";
    private byte[] inputBytes = input.getBytes();
    private TypeLiteral<Model> modelTypeLiteral; // this is thread-safe can reused
    private JsonIterator iter;

    private int COUNT = 1000 * 1000 * 1;

            

Reported by PMD.

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

Line: 21

               */
public class JsonIteratorImageTest extends TestCase {
    private String input = "{\"bitrate\":262144,\"duration\":18000000,\"format\":\"video/mpg4\",\"height\":480,\"persons\":[\"Bill Gates\",\"Steve Jobs\"],\"player\":\"JAVA\",\"size\":58982400,\"title\":\"Javaone Keynote\",\"uri\":\"http://javaone.com/keynote.mpg\",\"width\":640}";
    private byte[] inputBytes = input.getBytes();
    private TypeLiteral<Model> modelTypeLiteral; // this is thread-safe can reused
    private JsonIterator iter;

    private int COUNT = 1000 * 1000 * 1;


            

Reported by PMD.

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

Line: 22

              public class JsonIteratorImageTest extends TestCase {
    private String input = "{\"bitrate\":262144,\"duration\":18000000,\"format\":\"video/mpg4\",\"height\":480,\"persons\":[\"Bill Gates\",\"Steve Jobs\"],\"player\":\"JAVA\",\"size\":58982400,\"title\":\"Javaone Keynote\",\"uri\":\"http://javaone.com/keynote.mpg\",\"width\":640}";
    private byte[] inputBytes = input.getBytes();
    private TypeLiteral<Model> modelTypeLiteral; // this is thread-safe can reused
    private JsonIterator iter;

    private int COUNT = 1000 * 1000 * 1;

    protected void setUp() throws Exception {

            

Reported by PMD.

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

Line: 23

                  private String input = "{\"bitrate\":262144,\"duration\":18000000,\"format\":\"video/mpg4\",\"height\":480,\"persons\":[\"Bill Gates\",\"Steve Jobs\"],\"player\":\"JAVA\",\"size\":58982400,\"title\":\"Javaone Keynote\",\"uri\":\"http://javaone.com/keynote.mpg\",\"width\":640}";
    private byte[] inputBytes = input.getBytes();
    private TypeLiteral<Model> modelTypeLiteral; // this is thread-safe can reused
    private JsonIterator iter;

    private int COUNT = 1000 * 1000 * 1;

    protected void setUp() throws Exception {
        inputBytes = input.getBytes();

            

Reported by PMD.

Private field 'COUNT' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 25

                  private TypeLiteral<Model> modelTypeLiteral; // this is thread-safe can reused
    private JsonIterator iter;

    private int COUNT = 1000 * 1000 * 1;

    protected void setUp() throws Exception {
        inputBytes = input.getBytes();
        iter = new JsonIterator();
        modelTypeLiteral = new TypeLiteral<Model>() {

            

Reported by PMD.

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

Line: 25

                  private TypeLiteral<Model> modelTypeLiteral; // this is thread-safe can reused
    private JsonIterator iter;

    private int COUNT = 1000 * 1000 * 1;

    protected void setUp() throws Exception {
        inputBytes = input.getBytes();
        iter = new JsonIterator();
        modelTypeLiteral = new TypeLiteral<Model>() {

            

Reported by PMD.

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

Line: 27

              
    private int COUNT = 1000 * 1000 * 1;

    protected void setUp() throws Exception {
        inputBytes = input.getBytes();
        iter = new JsonIterator();
        modelTypeLiteral = new TypeLiteral<Model>() {
        };
    }

            

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

                      };
    }

    public void test_for_iterator() throws Exception {
        iter.reset(inputBytes);
        Model m2 = iter.read(modelTypeLiteral);

        fastjson();
        for (int i = 0; i < 5; ++i) {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/ParserSpecialCharTest_map_singleQuote.java
38 issues
This class has too many methods, consider refactoring it.
Design

Line: 9

              
import com.alibaba.fastjson.JSON;

public class ParserSpecialCharTest_map_singleQuote extends TestCase {

    public void test_0() throws Exception {
        Assert.assertEquals("\0", JSON.parseObject("{\"value\":\"\\0\"}").getString("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: 11

              
public class ParserSpecialCharTest_map_singleQuote extends TestCase {

    public void test_0() throws Exception {
        Assert.assertEquals("\0", JSON.parseObject("{\"value\":\"\\0\"}").getString("value"));
    }
    
    public void test_1() throws Exception {
        Assert.assertEquals("\1", JSON.parseObject("{\"value\":\"\\1\"}").getString("value"));

            

Reported by PMD.

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

Line: 12

              public class ParserSpecialCharTest_map_singleQuote extends TestCase {

    public void test_0() throws Exception {
        Assert.assertEquals("\0", JSON.parseObject("{\"value\":\"\\0\"}").getString("value"));
    }
    
    public void test_1() throws Exception {
        Assert.assertEquals("\1", JSON.parseObject("{\"value\":\"\\1\"}").getString("value"));
    }

            

Reported by PMD.

The String literal 'value' appears 18 times in this file; the first occurrence is on line 12
Error

Line: 12

              public class ParserSpecialCharTest_map_singleQuote extends TestCase {

    public void test_0() throws Exception {
        Assert.assertEquals("\0", JSON.parseObject("{\"value\":\"\\0\"}").getString("value"));
    }
    
    public void test_1() throws Exception {
        Assert.assertEquals("\1", JSON.parseObject("{\"value\":\"\\1\"}").getString("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: 15

                      Assert.assertEquals("\0", JSON.parseObject("{\"value\":\"\\0\"}").getString("value"));
    }
    
    public void test_1() throws Exception {
        Assert.assertEquals("\1", JSON.parseObject("{\"value\":\"\\1\"}").getString("value"));
    }
    
    public void test_2() throws Exception {
        Assert.assertEquals("\2", JSON.parseObject("{\"value\":\"\\2\"}").getString("value"));

            

Reported by PMD.

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

Line: 16

                  }
    
    public void test_1() throws Exception {
        Assert.assertEquals("\1", JSON.parseObject("{\"value\":\"\\1\"}").getString("value"));
    }
    
    public void test_2() throws Exception {
        Assert.assertEquals("\2", JSON.parseObject("{\"value\":\"\\2\"}").getString("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: 19

                      Assert.assertEquals("\1", JSON.parseObject("{\"value\":\"\\1\"}").getString("value"));
    }
    
    public void test_2() throws Exception {
        Assert.assertEquals("\2", JSON.parseObject("{\"value\":\"\\2\"}").getString("value"));
    }
    
    public void test_3() throws Exception {
        Assert.assertEquals("\3", JSON.parseObject("{\"value\":\"\\3\"}").getString("value"));

            

Reported by PMD.

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

Line: 20

                  }
    
    public void test_2() throws Exception {
        Assert.assertEquals("\2", JSON.parseObject("{\"value\":\"\\2\"}").getString("value"));
    }
    
    public void test_3() throws Exception {
        Assert.assertEquals("\3", JSON.parseObject("{\"value\":\"\\3\"}").getString("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: 23

                      Assert.assertEquals("\2", JSON.parseObject("{\"value\":\"\\2\"}").getString("value"));
    }
    
    public void test_3() throws Exception {
        Assert.assertEquals("\3", JSON.parseObject("{\"value\":\"\\3\"}").getString("value"));
    }
    
    public void test_4() throws Exception {
        Assert.assertEquals("\4", JSON.parseObject("{\"value\":\"\\4\"}").getString("value"));

            

Reported by PMD.

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

Line: 24

                  }
    
    public void test_3() throws Exception {
        Assert.assertEquals("\3", JSON.parseObject("{\"value\":\"\\3\"}").getString("value"));
    }
    
    public void test_4() throws Exception {
        Assert.assertEquals("\4", JSON.parseObject("{\"value\":\"\\4\"}").getString("value"));
    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/dubbo/TestForDubbo.java
38 issues
System.out.println is used
Design

Line: 60

                      Tigers tigers = helloService.eatTiger(tiger);

        String text = JSON.toJSONString(tigers, SerializerFeature.WriteClassName);
        System.out.println(text);

        Tigers tigers2 = JSON.parseObject(text, Tigers.class);

        Assert.assertEquals(text, JSON.toJSONString(tigers2, SerializerFeature.WriteClassName));
    }

            

Reported by PMD.

System.out.println is used
Design

Line: 70

                  public void testPerson() {
        Person p = helloService.showPerson(person);
        String text = JSON.toJSONString(p, SerializerFeature.WriteClassName);
        System.out.println(text);
        
        Person result = JSON.parseObject(text, Person.class);
        
        assertEquals(result.getInfoProfile().getPhones().get(0).getArea(),
                     person.getInfoProfile().getPhones().get(0).getArea());

            

Reported by PMD.

Private field 'helloService' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 51

                      person.setInfoProfile(pi);
    }

    private HelloServiceImpl helloService = new HelloServiceImpl();

    public void f_testParamType4() {
        Tiger tiger = new Tiger();
        tiger.setTigerName("东北虎");
        tiger.setTigerSex(true);

            

Reported by PMD.

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

Line: 51

                      person.setInfoProfile(pi);
    }

    private HelloServiceImpl helloService = new HelloServiceImpl();

    public void f_testParamType4() {
        Tiger tiger = new Tiger();
        tiger.setTigerName("东北虎");
        tiger.setTigerSex(true);

            

Reported by PMD.

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

Line: 67

                      Assert.assertEquals(text, JSON.toJSONString(tigers2, SerializerFeature.WriteClassName));
    }

    public void testPerson() {
        Person p = helloService.showPerson(person);
        String text = JSON.toJSONString(p, SerializerFeature.WriteClassName);
        System.out.println(text);
        
        Person result = JSON.parseObject(text, Person.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: 67

                      Assert.assertEquals(text, JSON.toJSONString(tigers2, SerializerFeature.WriteClassName));
    }

    public void testPerson() {
        Person p = helloService.showPerson(person);
        String text = JSON.toJSONString(p, SerializerFeature.WriteClassName);
        System.out.println(text);
        
        Person result = JSON.parseObject(text, Person.class);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 74

                      
        Person result = JSON.parseObject(text, Person.class);
        
        assertEquals(result.getInfoProfile().getPhones().get(0).getArea(),
                     person.getInfoProfile().getPhones().get(0).getArea());
        assertEquals(result.getInfoProfile().getPhones().get(0).getCountry(),
                     person.getInfoProfile().getPhones().get(0).getCountry());
        assertEquals(result.getInfoProfile().getPhones().get(0).getExtensionNumber(),
                     person.getInfoProfile().getPhones().get(0).getExtensionNumber());

            

Reported by PMD.

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

Line: 74

                      
        Person result = JSON.parseObject(text, Person.class);
        
        assertEquals(result.getInfoProfile().getPhones().get(0).getArea(),
                     person.getInfoProfile().getPhones().get(0).getArea());
        assertEquals(result.getInfoProfile().getPhones().get(0).getCountry(),
                     person.getInfoProfile().getPhones().get(0).getCountry());
        assertEquals(result.getInfoProfile().getPhones().get(0).getExtensionNumber(),
                     person.getInfoProfile().getPhones().get(0).getExtensionNumber());

            

Reported by PMD.

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

Line: 74

                      
        Person result = JSON.parseObject(text, Person.class);
        
        assertEquals(result.getInfoProfile().getPhones().get(0).getArea(),
                     person.getInfoProfile().getPhones().get(0).getArea());
        assertEquals(result.getInfoProfile().getPhones().get(0).getCountry(),
                     person.getInfoProfile().getPhones().get(0).getCountry());
        assertEquals(result.getInfoProfile().getPhones().get(0).getExtensionNumber(),
                     person.getInfoProfile().getPhones().get(0).getExtensionNumber());

            

Reported by PMD.

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

Line: 74

                      
        Person result = JSON.parseObject(text, Person.class);
        
        assertEquals(result.getInfoProfile().getPhones().get(0).getArea(),
                     person.getInfoProfile().getPhones().get(0).getArea());
        assertEquals(result.getInfoProfile().getPhones().get(0).getCountry(),
                     person.getInfoProfile().getPhones().get(0).getCountry());
        assertEquals(result.getInfoProfile().getPhones().get(0).getExtensionNumber(),
                     person.getInfoProfile().getPhones().get(0).getExtensionNumber());

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/ParserSpecialCharTest_map.java
38 issues
This class has too many methods, consider refactoring it.
Design

Line: 9

              
import com.alibaba.fastjson.JSON;

public class ParserSpecialCharTest_map extends TestCase {

    public void test_0() throws Exception {
        Assert.assertEquals("\0", JSON.parseObject("{'value':'\\0'}").getString("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: 11

              
public class ParserSpecialCharTest_map extends TestCase {

    public void test_0() throws Exception {
        Assert.assertEquals("\0", JSON.parseObject("{'value':'\\0'}").getString("value"));
    }
    
    public void test_1() throws Exception {
        Assert.assertEquals("\1", JSON.parseObject("{'value':'\\1'}").getString("value"));

            

Reported by PMD.

The String literal 'value' appears 18 times in this file; the first occurrence is on line 12
Error

Line: 12

              public class ParserSpecialCharTest_map extends TestCase {

    public void test_0() throws Exception {
        Assert.assertEquals("\0", JSON.parseObject("{'value':'\\0'}").getString("value"));
    }
    
    public void test_1() throws Exception {
        Assert.assertEquals("\1", JSON.parseObject("{'value':'\\1'}").getString("value"));
    }

            

Reported by PMD.

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

Line: 12

              public class ParserSpecialCharTest_map extends TestCase {

    public void test_0() throws Exception {
        Assert.assertEquals("\0", JSON.parseObject("{'value':'\\0'}").getString("value"));
    }
    
    public void test_1() throws Exception {
        Assert.assertEquals("\1", JSON.parseObject("{'value':'\\1'}").getString("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: 15

                      Assert.assertEquals("\0", JSON.parseObject("{'value':'\\0'}").getString("value"));
    }
    
    public void test_1() throws Exception {
        Assert.assertEquals("\1", JSON.parseObject("{'value':'\\1'}").getString("value"));
    }
    
    public void test_2() throws Exception {
        Assert.assertEquals("\2", JSON.parseObject("{'value':'\\2'}").getString("value"));

            

Reported by PMD.

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

Line: 16

                  }
    
    public void test_1() throws Exception {
        Assert.assertEquals("\1", JSON.parseObject("{'value':'\\1'}").getString("value"));
    }
    
    public void test_2() throws Exception {
        Assert.assertEquals("\2", JSON.parseObject("{'value':'\\2'}").getString("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: 19

                      Assert.assertEquals("\1", JSON.parseObject("{'value':'\\1'}").getString("value"));
    }
    
    public void test_2() throws Exception {
        Assert.assertEquals("\2", JSON.parseObject("{'value':'\\2'}").getString("value"));
    }
    
    public void test_3() throws Exception {
        Assert.assertEquals("\3", JSON.parseObject("{'value':'\\3'}").getString("value"));

            

Reported by PMD.

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

Line: 20

                  }
    
    public void test_2() throws Exception {
        Assert.assertEquals("\2", JSON.parseObject("{'value':'\\2'}").getString("value"));
    }
    
    public void test_3() throws Exception {
        Assert.assertEquals("\3", JSON.parseObject("{'value':'\\3'}").getString("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: 23

                      Assert.assertEquals("\2", JSON.parseObject("{'value':'\\2'}").getString("value"));
    }
    
    public void test_3() throws Exception {
        Assert.assertEquals("\3", JSON.parseObject("{'value':'\\3'}").getString("value"));
    }
    
    public void test_4() throws Exception {
        Assert.assertEquals("\4", JSON.parseObject("{'value':'\\4'}").getString("value"));

            

Reported by PMD.

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

Line: 24

                  }
    
    public void test_3() throws Exception {
        Assert.assertEquals("\3", JSON.parseObject("{'value':'\\3'}").getString("value"));
    }
    
    public void test_4() throws Exception {
        Assert.assertEquals("\4", JSON.parseObject("{'value':'\\4'}").getString("value"));
    }

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/parser/deserializer/SqlDateDeserializer.java
38 issues
Avoid reassigning parameters such as 'val'
Design

Line: 32

                  }

    @SuppressWarnings("unchecked")
    protected <T> T cast(DefaultJSONParser parser, Type clazz, Object fieldName, Object val) {
        if (timestamp) {
            return castTimestamp(parser, clazz, fieldName, val);
        }
        
        if (val == null) {

            

Reported by PMD.

Avoid reassigning parameters such as 'val'
Design

Line: 32

                  }

    @SuppressWarnings("unchecked")
    protected <T> T cast(DefaultJSONParser parser, Type clazz, Object fieldName, Object val) {
        if (timestamp) {
            return castTimestamp(parser, clazz, fieldName, val);
        }
        
        if (val == null) {

            

Reported by PMD.

Avoid reassigning parameters such as 'val'
Design

Line: 32

                  }

    @SuppressWarnings("unchecked")
    protected <T> T cast(DefaultJSONParser parser, Type clazz, Object fieldName, Object val) {
        if (timestamp) {
            return castTimestamp(parser, clazz, fieldName, val);
        }
        
        if (val == null) {

            

Reported by PMD.

The class 'SqlDateDeserializer' has a Standard Cyclomatic Complexity of 5 (Highest = 11).
Design

Line: 16

              import com.alibaba.fastjson.parser.JSONToken;
import com.alibaba.fastjson.util.TypeUtils;

public class SqlDateDeserializer extends AbstractDateDeserializer implements ObjectDeserializer {

    public final static SqlDateDeserializer instance = new SqlDateDeserializer();
    public final static SqlDateDeserializer instance_timestamp = new SqlDateDeserializer(true);
    
    private boolean                           timestamp = false;

            

Reported by PMD.

The class 'SqlDateDeserializer' has a Modified Cyclomatic Complexity of 5 (Highest = 11).
Design

Line: 16

              import com.alibaba.fastjson.parser.JSONToken;
import com.alibaba.fastjson.util.TypeUtils;

public class SqlDateDeserializer extends AbstractDateDeserializer implements ObjectDeserializer {

    public final static SqlDateDeserializer instance = new SqlDateDeserializer();
    public final static SqlDateDeserializer instance_timestamp = new SqlDateDeserializer(true);
    
    private boolean                           timestamp = false;

            

Reported by PMD.

Avoid using redundant field initializer for 'timestamp'
Performance

Line: 21

                  public final static SqlDateDeserializer instance = new SqlDateDeserializer();
    public final static SqlDateDeserializer instance_timestamp = new SqlDateDeserializer(true);
    
    private boolean                           timestamp = false;
    
    public SqlDateDeserializer() {
        
    }
    

            

Reported by PMD.

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

Line: 21

                  public final static SqlDateDeserializer instance = new SqlDateDeserializer();
    public final static SqlDateDeserializer instance_timestamp = new SqlDateDeserializer(true);
    
    private boolean                           timestamp = false;
    
    public SqlDateDeserializer() {
        
    }
    

            

Reported by PMD.

Avoid unused constructor parameters such as 'timestmap'.
Design

Line: 27

                      
    }
    
    public SqlDateDeserializer(boolean timestmap) {
        this.timestamp = true;
    }

    @SuppressWarnings("unchecked")
    protected <T> T cast(DefaultJSONParser parser, Type clazz, Object fieldName, Object val) {

            

Reported by PMD.

The method 'cast' has a Standard Cyclomatic Complexity of 10.
Design

Line: 32

                  }

    @SuppressWarnings("unchecked")
    protected <T> T cast(DefaultJSONParser parser, Type clazz, Object fieldName, Object val) {
        if (timestamp) {
            return castTimestamp(parser, clazz, fieldName, val);
        }
        
        if (val == null) {

            

Reported by PMD.

The method 'cast(DefaultJSONParser, Type, Object, Object)' has a cyclomatic complexity of 11.
Design

Line: 32

                  }

    @SuppressWarnings("unchecked")
    protected <T> T cast(DefaultJSONParser parser, Type clazz, Object fieldName, Object val) {
        if (timestamp) {
            return castTimestamp(parser, clazz, fieldName, val);
        }
        
        if (val == null) {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/date/DateFormatPriorityTest.java
38 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 24

              

public class DateFormatPriorityTest extends TestCase {
    Calendar calendar;

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


            

Reported by PMD.

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

Line: 26

              public class DateFormatPriorityTest extends TestCase {
    Calendar calendar;

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

        calendar = Calendar.getInstance(JSON.defaultTimeZone);
        calendar.set(1995, Calendar.OCTOBER, 26);

            

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

                      calendar.set(1995, Calendar.OCTOBER, 26);
    }

    public void test_for_fastJsonConfig() throws IOException {
        FastJsonConfig config = new FastJsonConfig();
        config.setDateFormat("yyyy-MM.dd");

        FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
        converter.setFastJsonConfig(config);

            

Reported by PMD.

A Calendar is used to create a Date or DateTime, this is expensive.
Performance

Line: 63

                      };

        VO vo = new VO();
        vo.setDate(calendar.getTime());
        converter.write(vo, VO.class, MediaType.APPLICATION_JSON_UTF8, out);

        byte[] bytes = byteOut.toByteArray();
        String jsonString = new String(bytes, "UTF-8");


            

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

                      Assert.assertEquals("{\"date\":\"1995-10.26\"}", jsonString);
    }

    public void test_for_toJSONStringWithDateFormat() {
        VO vo = new VO();
        vo.setDate(calendar.getTime());

        String jsonString = JSON.toJSONStringWithDateFormat(vo, "yyyy.MM.dd");


            

Reported by PMD.

A Calendar is used to create a Date or DateTime, this is expensive.
Performance

Line: 74

              
    public void test_for_toJSONStringWithDateFormat() {
        VO vo = new VO();
        vo.setDate(calendar.getTime());

        String jsonString = JSON.toJSONStringWithDateFormat(vo, "yyyy.MM.dd");

        assertEquals("{\"date\":\"1995.10.26\"}", jsonString);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 78

              
        String jsonString = JSON.toJSONStringWithDateFormat(vo, "yyyy.MM.dd");

        assertEquals("{\"date\":\"1995.10.26\"}", jsonString);
    }

    public void test_for_Annotation() {
        VO2 vo2 = new VO2();
        vo2.setDate(calendar.getTime());

            

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

                      assertEquals("{\"date\":\"1995.10.26\"}", jsonString);
    }

    public void test_for_Annotation() {
        VO2 vo2 = new VO2();
        vo2.setDate(calendar.getTime());

        String jsonString = JSON.toJSONString(vo2);


            

Reported by PMD.

A Calendar is used to create a Date or DateTime, this is expensive.
Performance

Line: 83

              
    public void test_for_Annotation() {
        VO2 vo2 = new VO2();
        vo2.setDate(calendar.getTime());

        String jsonString = JSON.toJSONString(vo2);

        assertEquals("{\"date\":\"1995.10-26\"}", jsonString);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 87

              
        String jsonString = JSON.toJSONString(vo2);

        assertEquals("{\"date\":\"1995.10-26\"}", jsonString);
    }

    public void test_for_DEFFAULT_DATE_FORMAT() {
        String defaultDateFormat = JSON.DEFFAULT_DATE_FORMAT;


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/compatible/jsonlib/CompatibleTest0.java
38 issues
Do not use the short type
Performance

Line: 269

                      private BigDecimal   f6;

        private byte         f7;
        private short        f8;
        private int          f9;
        private long         f10;

        public Byte getF1() {
            return f1;

            

Reported by PMD.

Do not use the short type
Performance

Line: 329

                          this.f7 = f7;
        }

        public short getF8() {
            return f8;
        }

        public void setF8(short f8) {
            this.f8 = f8;

            

Reported by PMD.

Do not use the short type
Performance

Line: 333

                          return f8;
        }

        public void setF8(short f8) {
            this.f8 = f8;
        }

        public int getF9() {
            return f9;

            

Reported by PMD.

System.out.println is used
Design

Line: 21

              public class CompatibleTest0 extends TestCase {

    protected void setUp() throws Exception {
        System.out.println();
    }

    public void test_0() throws Exception {
        Map<String, Object> obj = new HashMap<String, Object>();
        assertEquals(toCompatibleJSONString(obj), toJSONLibString(obj));

            

Reported by PMD.

System.out.println is used
Design

Line: 95

                  }

    public static void assertEquals(String fastJSON, String jsonLib) {
        System.out.println("fastjson: " + fastJSON);
        System.out.println("json-lib: " + jsonLib);
        Assert.assertEquals(JSON.parse(fastJSON), JSON.parse(jsonLib));
    }

private static final SerializeConfig   mapping;

            

Reported by PMD.

System.out.println is used
Design

Line: 96

              
    public static void assertEquals(String fastJSON, String jsonLib) {
        System.out.println("fastjson: " + fastJSON);
        System.out.println("json-lib: " + jsonLib);
        Assert.assertEquals(JSON.parse(fastJSON), JSON.parse(jsonLib));
    }

private static final SerializeConfig   mapping;
static {

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 1

              package com.alibaba.json.bvt.compatible.jsonlib;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 18

              import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;

public class CompatibleTest0 extends TestCase {

    protected void setUp() throws Exception {
        System.out.println();
    }


            

Reported by PMD.

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

Line: 20

              
public class CompatibleTest0 extends TestCase {

    protected void setUp() throws Exception {
        System.out.println();
    }

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

            

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

                      System.out.println();
    }

    public void test_0() throws Exception {
        Map<String, Object> obj = new HashMap<String, Object>();
        assertEquals(toCompatibleJSONString(obj), toJSONLibString(obj));
    }

    public void test_1() throws Exception {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/SerializeWriterTest.java
38 issues
This class has too many methods, consider refactoring it.
Design

Line: 13

              
import junit.framework.TestCase;

public class SerializeWriterTest extends TestCase {

    public void test_0() throws Exception {
        SerializeWriter out = new SerializeWriter(1);
        out.write('a');
        out.write('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: 15

              
public class SerializeWriterTest extends TestCase {

    public void test_0() throws Exception {
        SerializeWriter out = new SerializeWriter(1);
        out.write('a');
        out.write('b');
        out.write('c');
        Assert.assertEquals("abc", out.toString());

            

Reported by PMD.

The String literal 'abc' appears 6 times in this file; the first occurrence is on line 20
Error

Line: 20

                      out.write('a');
        out.write('b');
        out.write('c');
        Assert.assertEquals("abc", out.toString());

        StringWriter writer = new StringWriter();
        out.writeTo(writer);
        Assert.assertEquals("abc", writer.toString());
    }

            

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

                      Assert.assertEquals("abc", writer.toString());
    }

    public void test_1() throws Exception {
        SerializeWriter out = new SerializeWriter(1);
        out.write((int) 'a');
        out.write((int) 'b');
        out.write((int) 'c');
        out.write(new char[0], 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: 42

                      out.expandCapacity(128);
    }

    public void test_12() throws Exception {
        SerializeWriter out = new SerializeWriter(1);
        out.append("abc");
        Assert.assertEquals("abc", out.toString());
        Assert.assertEquals(3, out.toCharArray().length);
        Assert.assertEquals(3, out.size());

            

Reported by PMD.

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

Line: 46

                      SerializeWriter out = new SerializeWriter(1);
        out.append("abc");
        Assert.assertEquals("abc", out.toString());
        Assert.assertEquals(3, out.toCharArray().length);
        Assert.assertEquals(3, out.size());
        
        Field field = SerializeWriter.class.getDeclaredField("count");
        field.setAccessible(true);
        field.setInt(out, 0);

            

Reported by PMD.

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

Line: 50

                      Assert.assertEquals(3, out.size());
        
        Field field = SerializeWriter.class.getDeclaredField("count");
        field.setAccessible(true);
        field.setInt(out, 0);
        
        Assert.assertEquals("", out.toString());
        Assert.assertEquals(0, out.toCharArray().length);
        Assert.assertEquals(0, out.size());

            

Reported by PMD.

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

Line: 51

                      
        Field field = SerializeWriter.class.getDeclaredField("count");
        field.setAccessible(true);
        field.setInt(out, 0);
        
        Assert.assertEquals("", out.toString());
        Assert.assertEquals(0, out.toCharArray().length);
        Assert.assertEquals(0, out.size());
        out.writeInt(Integer.MIN_VALUE);

            

Reported by PMD.

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

Line: 54

                      field.setInt(out, 0);
        
        Assert.assertEquals("", out.toString());
        Assert.assertEquals(0, out.toCharArray().length);
        Assert.assertEquals(0, out.size());
        out.writeInt(Integer.MIN_VALUE);
        Assert.assertEquals(Integer.toString(Integer.MIN_VALUE), out.toString());
        out.flush();
        out.close();

            

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

                      out.close();
    }

    public void test_13() throws Exception {
        SerializeWriter out = new SerializeWriter(1);
        out.writeInt(Integer.MIN_VALUE);
        Assert.assertEquals(Integer.toString(Integer.MIN_VALUE), out.toString());
    }


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Issue408.java
38 issues
This class has a bunch of public methods and attributes
Design

Line: 1

              package com.alibaba.json.bvt.bug;

import com.alibaba.fastjson.JSONReader;
import com.alibaba.fastjson.parser.Feature;
import junit.framework.TestCase;
import org.junit.Assert;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;

            

Reported by PMD.

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

Line: 13

              
public class Issue408 extends TestCase {

    private InputStream inputStream;

    @Override
    public void setUp() throws Exception {
        String resource = "json/Issue408.json";
        inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);

            

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

              
    private InputStream inputStream;

    @Override
    public void setUp() throws Exception {
        String resource = "json/Issue408.json";
        inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);

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

            

Reported by PMD.

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

Line: 18

                  @Override
    public void setUp() throws Exception {
        String resource = "json/Issue408.json";
        inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);

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



            

Reported by PMD.

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

Line: 18

                  @Override
    public void setUp() throws Exception {
        String resource = "json/Issue408.json";
        inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);

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



            

Reported by PMD.

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

Line: 20

                      String resource = "json/Issue408.json";
        inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);

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


    @Override
    public void tearDown() throws Exception {

            

Reported by PMD.

JUnit 4 tests that clean up tests should use the @After annotation, JUnit5 tests should use @AfterEach or @AfterAll
Design

Line: 24

                  }


    @Override
    public void tearDown() throws Exception {
        inputStream.close();
    }

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

                      inputStream.close();
    }

    public void test_for_issue() throws Exception {

        JSONReader jsonReader = new JSONReader(new InputStreamReader(inputStream, Charset.forName("UTF-8")));
        jsonReader.config(Feature.AllowArbitraryCommas, true);
        jsonReader.config(Feature.IgnoreNotMatch, true);
        jsonReader.config(Feature.SortFeidFastMatch, false);

            

Reported by PMD.

The initializer for variable 'deserialized' is never used (overwritten on line 40)
Design

Line: 38

                      jsonReader.config(Feature.DisableCircularReferenceDetect, true);
        jsonReader.config(Feature.AutoCloseSource, true);

        VOList deserialized = null;
        try {
            deserialized = (VOList)jsonReader.readObject();
        }finally {
            jsonReader.close();
        }

            

Reported by PMD.

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

Line: 46

                      }

        for (int i = 0; i < 17; i++) {
            Assert.assertEquals(deserialized.getVolist()[i].getLongid0(), Long.valueOf(1234567890123L));
            Assert.assertEquals(deserialized.getVolist()[i].getLongid1(), Long.valueOf(1234567890123L));
            Assert.assertEquals(deserialized.getVolist()[i].getLongid2(), Long.valueOf(1234567890123L));
            Assert.assertEquals(deserialized.getVolist()[i].getLongid3(), Long.valueOf(1234567890123L));
            Assert.assertEquals(deserialized.getVolist()[i].getLongid4(), Long.valueOf(1234567890123L));
            Assert.assertEquals(deserialized.getVolist()[i].getLongid5(), Long.valueOf(1234567890123L));

            

Reported by PMD.

src/test/java/com/derbysoft/spitfire/fastjson/TestFastJson.java
38 issues
System.out.println is used
Design

Line: 70

                  public void f_test() throws Exception {

        String text = JSON.toJSONString(createTest(), SerializerFeature.WriteClassName);
        System.out.println(text.length());
        System.out.println(text);
        System.out.println("serialize finished");
        GenericRS<HotelAvailRS> o = (GenericRS<HotelAvailRS>) JSON.parseObject(text, GenericRS.class);

        System.out.println(o);

            

Reported by PMD.

System.out.println is used
Design

Line: 71

              
        String text = JSON.toJSONString(createTest(), SerializerFeature.WriteClassName);
        System.out.println(text.length());
        System.out.println(text);
        System.out.println("serialize finished");
        GenericRS<HotelAvailRS> o = (GenericRS<HotelAvailRS>) JSON.parseObject(text, GenericRS.class);

        System.out.println(o);
    }

            

Reported by PMD.

System.out.println is used
Design

Line: 72

                      String text = JSON.toJSONString(createTest(), SerializerFeature.WriteClassName);
        System.out.println(text.length());
        System.out.println(text);
        System.out.println("serialize finished");
        GenericRS<HotelAvailRS> o = (GenericRS<HotelAvailRS>) JSON.parseObject(text, GenericRS.class);

        System.out.println(o);
    }


            

Reported by PMD.

System.out.println is used
Design

Line: 75

                      System.out.println("serialize finished");
        GenericRS<HotelAvailRS> o = (GenericRS<HotelAvailRS>) JSON.parseObject(text, GenericRS.class);

        System.out.println(o);
    }

    public void testFP() throws IOException {
        Generic<String> q = new Generic<String>();
        for (int x = 0; x < STAYS_COUNT; ++x) {

            

Reported by PMD.

System.out.println is used
Design

Line: 88

                          }
            stopWatch.stop();

            System.out.println("JSON serialize:" + stopWatch.getTime());

            stopWatch.reset();
            stopWatch.start();
            for (int i = 0; i < TIMES; ++i) {
                javaSerialize(q);

            

Reported by PMD.

System.out.println is used
Design

Line: 96

                              javaSerialize(q);
            }
            stopWatch.stop();
            System.out.println("JAVA serialize:" + stopWatch.getTime());
            System.out.println();
        }
    }

    private <T> void jsonSerialize(T t) throws IOException {

            

Reported by PMD.

System.out.println is used
Design

Line: 97

                          }
            stopWatch.stop();
            System.out.println("JAVA serialize:" + stopWatch.getTime());
            System.out.println();
        }
    }

    private <T> void jsonSerialize(T t) throws IOException {
        // String text = JSON.toJSONString(t, SerializerFeature.WriteClassName, SerializerFeature.PrettyFormat);

            

Reported by PMD.

System.out.println is used
Design

Line: 147

                          }
            stopWatch.stop();

            System.out.println("JSON serialize:" + stopWatch.getTime());

            stopWatch.reset();
            stopWatch.start();
            for (int i = 0; i < TIMES; ++i) {
                javaSerialize(obj);

            

Reported by PMD.

System.out.println is used
Design

Line: 155

                              javaSerialize(obj);
            }
            stopWatch.stop();
            System.out.println("JAVA serialize:" + stopWatch.getTime());
            System.out.println();
        }
    }

    public void testDeserializePerformance() throws IOException, ClassNotFoundException {

            

Reported by PMD.

System.out.println is used
Design

Line: 156

                          }
            stopWatch.stop();
            System.out.println("JAVA serialize:" + stopWatch.getTime());
            System.out.println();
        }
    }

    public void testDeserializePerformance() throws IOException, ClassNotFoundException {
        Object obj = createTest();

            

Reported by PMD.