The following issues were found

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

Line: 7

              import junit.framework.TestCase;

public class JSON_isValid_1_error extends TestCase {
    public void test_for_isValid_0() throws Exception {
        assertFalse(JSON.isValid(null));
        assertFalse(JSON.isValid(""));
    }

    public void test_for_isValid_value() 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: 7

              import junit.framework.TestCase;

public class JSON_isValid_1_error extends TestCase {
    public void test_for_isValid_0() throws Exception {
        assertFalse(JSON.isValid(null));
        assertFalse(JSON.isValid(""));
    }

    public void test_for_isValid_value() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 8

              
public class JSON_isValid_1_error extends TestCase {
    public void test_for_isValid_0() throws Exception {
        assertFalse(JSON.isValid(null));
        assertFalse(JSON.isValid(""));
    }

    public void test_for_isValid_value() throws Exception {
        assertFalse(JSON.isValid("nul"));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 9

              public class JSON_isValid_1_error extends TestCase {
    public void test_for_isValid_0() throws Exception {
        assertFalse(JSON.isValid(null));
        assertFalse(JSON.isValid(""));
    }

    public void test_for_isValid_value() throws Exception {
        assertFalse(JSON.isValid("nul"));
        assertFalse(JSON.isValid("null,null"));

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 12

                      assertFalse(JSON.isValid(""));
    }

    public void test_for_isValid_value() throws Exception {
        assertFalse(JSON.isValid("nul"));
        assertFalse(JSON.isValid("null,null"));
        assertFalse(JSON.isValid("123,"));
        assertFalse(JSON.isValid("123,123"));
        assertFalse(JSON.isValid("12.34,true"));

            

Reported by PMD.

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

Line: 12

                      assertFalse(JSON.isValid(""));
    }

    public void test_for_isValid_value() throws Exception {
        assertFalse(JSON.isValid("nul"));
        assertFalse(JSON.isValid("null,null"));
        assertFalse(JSON.isValid("123,"));
        assertFalse(JSON.isValid("123,123"));
        assertFalse(JSON.isValid("12.34,true"));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 13

                  }

    public void test_for_isValid_value() throws Exception {
        assertFalse(JSON.isValid("nul"));
        assertFalse(JSON.isValid("null,null"));
        assertFalse(JSON.isValid("123,"));
        assertFalse(JSON.isValid("123,123"));
        assertFalse(JSON.isValid("12.34,true"));
        assertFalse(JSON.isValid("12.34,123"));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

              
    public void test_for_isValid_value() throws Exception {
        assertFalse(JSON.isValid("nul"));
        assertFalse(JSON.isValid("null,null"));
        assertFalse(JSON.isValid("123,"));
        assertFalse(JSON.isValid("123,123"));
        assertFalse(JSON.isValid("12.34,true"));
        assertFalse(JSON.isValid("12.34,123"));
        assertFalse(JSON.isValid("tru"));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 15

                  public void test_for_isValid_value() throws Exception {
        assertFalse(JSON.isValid("nul"));
        assertFalse(JSON.isValid("null,null"));
        assertFalse(JSON.isValid("123,"));
        assertFalse(JSON.isValid("123,123"));
        assertFalse(JSON.isValid("12.34,true"));
        assertFalse(JSON.isValid("12.34,123"));
        assertFalse(JSON.isValid("tru"));
        assertFalse(JSON.isValid("true,123"));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                      assertFalse(JSON.isValid("nul"));
        assertFalse(JSON.isValid("null,null"));
        assertFalse(JSON.isValid("123,"));
        assertFalse(JSON.isValid("123,123"));
        assertFalse(JSON.isValid("12.34,true"));
        assertFalse(JSON.isValid("12.34,123"));
        assertFalse(JSON.isValid("tru"));
        assertFalse(JSON.isValid("true,123"));
        assertFalse(JSON.isValid("fals"));

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/serializer/JSONSerializer.java
47 issues
Possible God Class (WMC=91, ATFD=38, TCC=25.513%)
Design

Line: 34

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public class JSONSerializer extends SerializeFilterable {

    protected final SerializeConfig                  config;
    public final SerializeWriter                     out;

    private int                                      indentCount = 0;

            

Reported by PMD.

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

Line: 34

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public class JSONSerializer extends SerializeFilterable {

    protected final SerializeConfig                  config;
    public final SerializeWriter                     out;

    private int                                      indentCount = 0;

            

Reported by PMD.

The class 'JSONSerializer' has a total cyclomatic complexity of 91 (highest 18).
Design

Line: 34

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public class JSONSerializer extends SerializeFilterable {

    protected final SerializeConfig                  config;
    public final SerializeWriter                     out;

    private int                                      indentCount = 0;

            

Reported by PMD.

The class 'JSONSerializer' has a Standard Cyclomatic Complexity of 2 (Highest = 16).
Design

Line: 34

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public class JSONSerializer extends SerializeFilterable {

    protected final SerializeConfig                  config;
    public final SerializeWriter                     out;

    private int                                      indentCount = 0;

            

Reported by PMD.

The class 'JSONSerializer' has a Modified Cyclomatic Complexity of 2 (Highest = 16).
Design

Line: 34

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public class JSONSerializer extends SerializeFilterable {

    protected final SerializeConfig                  config;
    public final SerializeWriter                     out;

    private int                                      indentCount = 0;

            

Reported by PMD.

Field config has the same name as a method
Error

Line: 36

               */
public class JSONSerializer extends SerializeFilterable {

    protected final SerializeConfig                  config;
    public final SerializeWriter                     out;

    private int                                      indentCount = 0;
    private String                                   indent      = "\t";


            

Reported by PMD.

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

Line: 36

               */
public class JSONSerializer extends SerializeFilterable {

    protected final SerializeConfig                  config;
    public final SerializeWriter                     out;

    private int                                      indentCount = 0;
    private String                                   indent      = "\t";


            

Reported by PMD.

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

Line: 37

              public class JSONSerializer extends SerializeFilterable {

    protected final SerializeConfig                  config;
    public final SerializeWriter                     out;

    private int                                      indentCount = 0;
    private String                                   indent      = "\t";

    /**

            

Reported by PMD.

Avoid using redundant field initializer for 'indentCount'
Performance

Line: 39

                  protected final SerializeConfig                  config;
    public final SerializeWriter                     out;

    private int                                      indentCount = 0;
    private String                                   indent      = "\t";

    /**
     * #1868 为了区分全局配置(FastJsonConfig)的日期格式配置以及toJSONString传入的日期格式配置
     * 建议使用以下调整:

            

Reported by PMD.

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

Line: 39

                  protected final SerializeConfig                  config;
    public final SerializeWriter                     out;

    private int                                      indentCount = 0;
    private String                                   indent      = "\t";

    /**
     * #1868 为了区分全局配置(FastJsonConfig)的日期格式配置以及toJSONString传入的日期格式配置
     * 建议使用以下调整:

            

Reported by PMD.

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

Line: 15

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

public class JSONSerializerFeatureTest extends TestCase {

    public void test_0() throws Exception {
        JSONSerializer serializer = new JSONSerializer(new SerializeWriter());

        Assert.assertEquals(true, serializer.isEnabled(SerializerFeature.QuoteFieldNames));

            

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

              
public class JSONSerializerFeatureTest extends TestCase {

    public void test_0() throws Exception {
        JSONSerializer serializer = new JSONSerializer(new SerializeWriter());

        Assert.assertEquals(true, serializer.isEnabled(SerializerFeature.QuoteFieldNames));
        Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.UseSingleQuotes));
    }

            

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

                      Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.UseSingleQuotes));
    }

    public void test_0_g() throws Exception {
        JSONSerializer serializer = new JSONSerializer(new SerializeWriter());

        Assert.assertEquals(true, serializer.isEnabled(SerializerFeature.QuoteFieldNames));
        Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.UseSingleQuotes));
    }

            

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

                      Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.UseSingleQuotes));
    }

    public void test_1() throws Exception {
        JSONSerializer serializer = new JSONSerializer(new SerializeWriter());

        Assert.assertEquals(true, serializer.isEnabled(SerializerFeature.QuoteFieldNames));
        Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.UseSingleQuotes));


            

Reported by PMD.

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

Line: 42

              
        serializer.write("abc");

        Assert.assertEquals("'abc'", serializer.getWriter().toString());
    }

    public void test_1_s() throws Exception {
        JSONSerializer serializer = new JSONSerializer(new SerializeWriter());


            

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

                      Assert.assertEquals("'abc'", serializer.getWriter().toString());
    }

    public void test_1_s() throws Exception {
        JSONSerializer serializer = new JSONSerializer(new SerializeWriter());

        Assert.assertEquals(true, serializer.isEnabled(SerializerFeature.QuoteFieldNames));
        Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.UseSingleQuotes));


            

Reported by PMD.

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

Line: 56

              
        serializer.write("abc");

        Assert.assertEquals("'abc'", serializer.getWriter().toString());
    }

    public void test_2() throws Exception {
        JSONSerializer serializer = new JSONSerializer(new SerializeWriter());


            

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

                      Assert.assertEquals("'abc'", serializer.getWriter().toString());
    }

    public void test_2() throws Exception {
        JSONSerializer serializer = new JSONSerializer(new SerializeWriter());

        serializer.config(SerializerFeature.UseSingleQuotes, true);
        Assert.assertEquals(true, serializer.isEnabled(SerializerFeature.UseSingleQuotes));


            

Reported by PMD.

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

Line: 65

                      serializer.config(SerializerFeature.UseSingleQuotes, true);
        Assert.assertEquals(true, serializer.isEnabled(SerializerFeature.UseSingleQuotes));

        serializer.write(Collections.singletonMap("age", 33));

        Assert.assertEquals("{'age':33}", serializer.getWriter().toString());
    }

    public void test_2_s() throws Exception {

            

Reported by PMD.

The String literal '{'age':33}' appears 4 times in this file; the first occurrence is on line 67
Error

Line: 67

              
        serializer.write(Collections.singletonMap("age", 33));

        Assert.assertEquals("{'age':33}", serializer.getWriter().toString());
    }

    public void test_2_s() throws Exception {
        JSONSerializer serializer = new JSONSerializer(new SerializeWriter());


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/basicType/LongTest2.java
47 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 14

               * Created by wenshao on 11/08/2017.
 */
public class LongTest2 extends TestCase {
    public void test_0() throws Exception {
        String json = "{\"v1\":-1883391953414482124,\"v2\":-3019416596934963650,\"v3\":6497525620823745793,\"v4\":2136224289077142499,\"v5\":-2090575024006307745}";
        String json2 = "{\"v1\":\"-1883391953414482124\",\"v2\":\"-3019416596934963650\",\"v3\":\"6497525620823745793\",\"v4\":\"2136224289077142499\",\"v5\":\"-2090575024006307745\"}";

        Model m1 = JSON.parseObject(json, Model.class);
        Model m2 = JSON.parseObject(json2, Model.class);

            

Reported by PMD.

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

Line: 14

               * Created by wenshao on 11/08/2017.
 */
public class LongTest2 extends TestCase {
    public void test_0() throws Exception {
        String json = "{\"v1\":-1883391953414482124,\"v2\":-3019416596934963650,\"v3\":6497525620823745793,\"v4\":2136224289077142499,\"v5\":-2090575024006307745}";
        String json2 = "{\"v1\":\"-1883391953414482124\",\"v2\":\"-3019416596934963650\",\"v3\":\"6497525620823745793\",\"v4\":\"2136224289077142499\",\"v5\":\"-2090575024006307745\"}";

        Model m1 = JSON.parseObject(json, Model.class);
        Model m2 = JSON.parseObject(json2, Model.class);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 21

                      Model m1 = JSON.parseObject(json, Model.class);
        Model m2 = JSON.parseObject(json2, Model.class);

        assertNotNull(m1);
        assertNotNull(m2);

        assertEquals(-1883391953414482124L, m1.v1);
        assertEquals(-3019416596934963650L, m1.v2);
        assertEquals(6497525620823745793L, m1.v3);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

                      Model m2 = JSON.parseObject(json2, Model.class);

        assertNotNull(m1);
        assertNotNull(m2);

        assertEquals(-1883391953414482124L, m1.v1);
        assertEquals(-3019416596934963650L, m1.v2);
        assertEquals(6497525620823745793L, m1.v3);
        assertEquals(2136224289077142499L, m1.v4);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 24

                      assertNotNull(m1);
        assertNotNull(m2);

        assertEquals(-1883391953414482124L, m1.v1);
        assertEquals(-3019416596934963650L, m1.v2);
        assertEquals(6497525620823745793L, m1.v3);
        assertEquals(2136224289077142499L, m1.v4);
        assertEquals(-2090575024006307745L, m1.v5);


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 25

                      assertNotNull(m2);

        assertEquals(-1883391953414482124L, m1.v1);
        assertEquals(-3019416596934963650L, m1.v2);
        assertEquals(6497525620823745793L, m1.v3);
        assertEquals(2136224289077142499L, m1.v4);
        assertEquals(-2090575024006307745L, m1.v5);

        assertEquals(-1883391953414482124L, m2.v1);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 26

              
        assertEquals(-1883391953414482124L, m1.v1);
        assertEquals(-3019416596934963650L, m1.v2);
        assertEquals(6497525620823745793L, m1.v3);
        assertEquals(2136224289077142499L, m1.v4);
        assertEquals(-2090575024006307745L, m1.v5);

        assertEquals(-1883391953414482124L, m2.v1);
        assertEquals(-3019416596934963650L, m2.v2);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 27

                      assertEquals(-1883391953414482124L, m1.v1);
        assertEquals(-3019416596934963650L, m1.v2);
        assertEquals(6497525620823745793L, m1.v3);
        assertEquals(2136224289077142499L, m1.v4);
        assertEquals(-2090575024006307745L, m1.v5);

        assertEquals(-1883391953414482124L, m2.v1);
        assertEquals(-3019416596934963650L, m2.v2);
        assertEquals(6497525620823745793L, m2.v3);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 28

                      assertEquals(-3019416596934963650L, m1.v2);
        assertEquals(6497525620823745793L, m1.v3);
        assertEquals(2136224289077142499L, m1.v4);
        assertEquals(-2090575024006307745L, m1.v5);

        assertEquals(-1883391953414482124L, m2.v1);
        assertEquals(-3019416596934963650L, m2.v2);
        assertEquals(6497525620823745793L, m2.v3);
        assertEquals(2136224289077142499L, m2.v4);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

                      assertEquals(2136224289077142499L, m1.v4);
        assertEquals(-2090575024006307745L, m1.v5);

        assertEquals(-1883391953414482124L, m2.v1);
        assertEquals(-3019416596934963650L, m2.v2);
        assertEquals(6497525620823745793L, m2.v3);
        assertEquals(2136224289077142499L, m2.v4);
        assertEquals(-2090575024006307745L, m2.v5);
    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_yangzhou.java
47 issues
Avoid throwing raw exception types.
Design

Line: 149

              
            protected void addCriterion(String condition) {
                if (condition == null) {
                    throw new RuntimeException("Value for condition cannot be null");
                }
                criteria.add(new Criterion(condition));
            }

            protected void addCriterion(String condition, Object value, String property) {

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 156

              
            protected void addCriterion(String condition, Object value, String property) {
                if (value == null) {
                    throw new RuntimeException("Value for " + property + " cannot be null");
                }
                criteria.add(new Criterion(condition, value));
            }

            protected void addCriterion(String condition, Object value1, Object value2, String property) {

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 163

              
            protected void addCriterion(String condition, Object value1, Object value2, String property) {
                if (value1 == null || value2 == null) {
                    throw new RuntimeException("Between values for " + property + " cannot be null");
                }
                criteria.add(new Criterion(condition, value1, value2));
            }

            public Criteria andIdIsNull() {

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 1104

                                      return orderCondition;
                    }
                }
                throw new RuntimeException("OrderCondition of " + name + " enum not exist");
            }

            @Override
            public String toString() {
                return columnName;

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 1134

                                      return sortType;
                    }
                }
                throw new RuntimeException("SortType of " + name + " enum not exist");
            }

            @Override
            public String toString() {
                return value;

            

Reported by PMD.

System.out.println is used
Design

Line: 15

                  public void test_for_issue() throws Exception {
        String test = "{\"distinct\":false,\"oredCriteria\":[{\"allCriteria\":[{\"betweenValue\":false,\"condition\":\"area_id =\",\"listValue\":false,\"noValue\":false,\"singleValue\":true,\"value\":917477670000000000},{\"betweenValue\":false,\"condition\":\"cabinet_id =\",\"listValue\":false,\"noValue\":false,\"singleValue\":true,\"value\":500036},{\"betweenValue\":false,\"condition\":\"status =\",\"listValue\":false,\"noValue\":false,\"singleValue\":true,\"value\":0}],\"criteria\":[{\"$ref\":\"$.oredCriteria[0].allCriteria[0]\"},{\"$ref\":\"$.oredCriteria[0].allCriteria[1]\"},{\"$ref\":\"$.oredCriteria[0].allCriteria[2]\"}],\"valid\":true}],\"page\":true,\"pageIndex\":0,\"pageSize\":1,\"pageStart\":1}";

        System.out.println(test);
        CabinetAuthCodeParam cabinetAuthCodeParam = JSONObject.toJavaObject(JSON.parseObject(test), CabinetAuthCodeParam.class);
        System.out.println(JSON.toJSONString(cabinetAuthCodeParam));
        final String jsonString = JSON.toJSONString(cabinetAuthCodeParam);
        assertEquals("{\"distinct\":false,\"oredCriteria\":[{\"allCriteria\":[{\"listValue\":false,\"noValue\":false,\"condition\":\"area_id =\",\"betweenValue\":false,\"singleValue\":true,\"value\":917477670000000000},{\"listValue\":false,\"noValue\":false,\"condition\":\"cabinet_id =\",\"betweenValue\":false,\"singleValue\":true,\"value\":500036},{\"listValue\":false,\"noValue\":false,\"condition\":\"status =\",\"betweenValue\":false,\"singleValue\":true,\"value\":0}],\"criteria\":[{\"$ref\":\"$.oredCriteria[0].allCriteria[0]\"},{\"$ref\":\"$.oredCriteria[0].allCriteria[1]\"},{\"$ref\":\"$.oredCriteria[0].allCriteria[2]\"}],\"valid\":true}],\"page\":true,\"pageIndex\":0,\"pageSize\":1,\"pageStart\":1}", jsonString);
//        CabinetAuthCodeRecordParam cabinetAuthCodeRecordParam = JSONObject.toJavaObject(JSON.parseObject(jsonString), CabinetAuthCodeRecordParam.class);

            

Reported by PMD.

System.out.println is used
Design

Line: 17

              
        System.out.println(test);
        CabinetAuthCodeParam cabinetAuthCodeParam = JSONObject.toJavaObject(JSON.parseObject(test), CabinetAuthCodeParam.class);
        System.out.println(JSON.toJSONString(cabinetAuthCodeParam));
        final String jsonString = JSON.toJSONString(cabinetAuthCodeParam);
        assertEquals("{\"distinct\":false,\"oredCriteria\":[{\"allCriteria\":[{\"listValue\":false,\"noValue\":false,\"condition\":\"area_id =\",\"betweenValue\":false,\"singleValue\":true,\"value\":917477670000000000},{\"listValue\":false,\"noValue\":false,\"condition\":\"cabinet_id =\",\"betweenValue\":false,\"singleValue\":true,\"value\":500036},{\"listValue\":false,\"noValue\":false,\"condition\":\"status =\",\"betweenValue\":false,\"singleValue\":true,\"value\":0}],\"criteria\":[{\"$ref\":\"$.oredCriteria[0].allCriteria[0]\"},{\"$ref\":\"$.oredCriteria[0].allCriteria[1]\"},{\"$ref\":\"$.oredCriteria[0].allCriteria[2]\"}],\"valid\":true}],\"page\":true,\"pageIndex\":0,\"pageSize\":1,\"pageStart\":1}", jsonString);
//        CabinetAuthCodeRecordParam cabinetAuthCodeRecordParam = JSONObject.toJavaObject(JSON.parseObject(jsonString), CabinetAuthCodeRecordParam.class);
//        System.out.println(JSON.toJSONString(cabinetAuthCodeRecordParam));
    }

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 1

              package com.alibaba.json.bvt.bug;

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

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

            

Reported by PMD.

Avoid really long classes.
Design

Line: 11

              import java.util.Date;
import java.util.List;

public class Bug_for_yangzhou extends TestCase {
    public void test_for_issue() throws Exception {
        String test = "{\"distinct\":false,\"oredCriteria\":[{\"allCriteria\":[{\"betweenValue\":false,\"condition\":\"area_id =\",\"listValue\":false,\"noValue\":false,\"singleValue\":true,\"value\":917477670000000000},{\"betweenValue\":false,\"condition\":\"cabinet_id =\",\"listValue\":false,\"noValue\":false,\"singleValue\":true,\"value\":500036},{\"betweenValue\":false,\"condition\":\"status =\",\"listValue\":false,\"noValue\":false,\"singleValue\":true,\"value\":0}],\"criteria\":[{\"$ref\":\"$.oredCriteria[0].allCriteria[0]\"},{\"$ref\":\"$.oredCriteria[0].allCriteria[1]\"},{\"$ref\":\"$.oredCriteria[0].allCriteria[2]\"}],\"valid\":true}],\"page\":true,\"pageIndex\":0,\"pageSize\":1,\"pageStart\":1}";

        System.out.println(test);
        CabinetAuthCodeParam cabinetAuthCodeParam = JSONObject.toJavaObject(JSON.parseObject(test), CabinetAuthCodeParam.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: 12

              import java.util.List;

public class Bug_for_yangzhou extends TestCase {
    public void test_for_issue() throws Exception {
        String test = "{\"distinct\":false,\"oredCriteria\":[{\"allCriteria\":[{\"betweenValue\":false,\"condition\":\"area_id =\",\"listValue\":false,\"noValue\":false,\"singleValue\":true,\"value\":917477670000000000},{\"betweenValue\":false,\"condition\":\"cabinet_id =\",\"listValue\":false,\"noValue\":false,\"singleValue\":true,\"value\":500036},{\"betweenValue\":false,\"condition\":\"status =\",\"listValue\":false,\"noValue\":false,\"singleValue\":true,\"value\":0}],\"criteria\":[{\"$ref\":\"$.oredCriteria[0].allCriteria[0]\"},{\"$ref\":\"$.oredCriteria[0].allCriteria[1]\"},{\"$ref\":\"$.oredCriteria[0].allCriteria[2]\"}],\"valid\":true}],\"page\":true,\"pageIndex\":0,\"pageSize\":1,\"pageStart\":1}";

        System.out.println(test);
        CabinetAuthCodeParam cabinetAuthCodeParam = JSONObject.toJavaObject(JSON.parseObject(test), CabinetAuthCodeParam.class);
        System.out.println(JSON.toJSONString(cabinetAuthCodeParam));

            

Reported by PMD.

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

Line: 17

              import com.alibaba.fastjson.serializer.SerializerFeature;

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

                      JSON.defaultLocale = Locale.CHINA;
    }
    
    public void test_0() throws Exception {
        VO vo = new VO();
        vo.setCalendar(Calendar.getInstance());

        String text = JSON.toJSONString(vo);


            

Reported by PMD.

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

Line: 29

                      String text = JSON.toJSONString(vo);

        VO vo1 = JSON.parseObject(text, VO.class);
        Assert.assertEquals(vo.getCalendar().getTime(), vo1.getCalendar().getTime());
    }
    
    public void test_format() throws Exception {
        VO vo = new VO();
        vo.setCalendar(Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale));

            

Reported by PMD.

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

Line: 29

                      String text = JSON.toJSONString(vo);

        VO vo1 = JSON.parseObject(text, VO.class);
        Assert.assertEquals(vo.getCalendar().getTime(), vo1.getCalendar().getTime());
    }
    
    public void test_format() throws Exception {
        VO vo = new VO();
        vo.setCalendar(Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale));

            

Reported by PMD.

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

Line: 29

                      String text = JSON.toJSONString(vo);

        VO vo1 = JSON.parseObject(text, VO.class);
        Assert.assertEquals(vo.getCalendar().getTime(), vo1.getCalendar().getTime());
    }
    
    public void test_format() throws Exception {
        VO vo = new VO();
        vo.setCalendar(Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale));

            

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

                      Assert.assertEquals(vo.getCalendar().getTime(), vo1.getCalendar().getTime());
    }
    
    public void test_format() throws Exception {
        VO vo = new VO();
        vo.setCalendar(Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale));
        
        String text = JSON.toJSONString(vo, SerializerFeature.WriteDateUseDateFormat);
        

            

Reported by PMD.

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

Line: 39

                      String text = JSON.toJSONString(vo, SerializerFeature.WriteDateUseDateFormat);
        
        VO vo1 = JSON.parseObject(text, VO.class);
        Assert.assertEquals(vo.getCalendar().get(Calendar.YEAR), vo1.getCalendar().get(Calendar.YEAR));
        Assert.assertEquals(vo.getCalendar().get(Calendar.MONTH), vo1.getCalendar().get(Calendar.MONTH));
        Assert.assertEquals(vo.getCalendar().get(Calendar.DAY_OF_MONTH), vo1.getCalendar().get(Calendar.DAY_OF_MONTH));
        Assert.assertEquals(vo.getCalendar().get(Calendar.HOUR_OF_DAY), vo1.getCalendar().get(Calendar.HOUR_OF_DAY));
        Assert.assertEquals(vo.getCalendar().get(Calendar.MINUTE), vo1.getCalendar().get(Calendar.MINUTE));
        Assert.assertEquals(vo.getCalendar().get(Calendar.SECOND), vo1.getCalendar().get(Calendar.SECOND));

            

Reported by PMD.

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

Line: 39

                      String text = JSON.toJSONString(vo, SerializerFeature.WriteDateUseDateFormat);
        
        VO vo1 = JSON.parseObject(text, VO.class);
        Assert.assertEquals(vo.getCalendar().get(Calendar.YEAR), vo1.getCalendar().get(Calendar.YEAR));
        Assert.assertEquals(vo.getCalendar().get(Calendar.MONTH), vo1.getCalendar().get(Calendar.MONTH));
        Assert.assertEquals(vo.getCalendar().get(Calendar.DAY_OF_MONTH), vo1.getCalendar().get(Calendar.DAY_OF_MONTH));
        Assert.assertEquals(vo.getCalendar().get(Calendar.HOUR_OF_DAY), vo1.getCalendar().get(Calendar.HOUR_OF_DAY));
        Assert.assertEquals(vo.getCalendar().get(Calendar.MINUTE), vo1.getCalendar().get(Calendar.MINUTE));
        Assert.assertEquals(vo.getCalendar().get(Calendar.SECOND), vo1.getCalendar().get(Calendar.SECOND));

            

Reported by PMD.

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

Line: 39

                      String text = JSON.toJSONString(vo, SerializerFeature.WriteDateUseDateFormat);
        
        VO vo1 = JSON.parseObject(text, VO.class);
        Assert.assertEquals(vo.getCalendar().get(Calendar.YEAR), vo1.getCalendar().get(Calendar.YEAR));
        Assert.assertEquals(vo.getCalendar().get(Calendar.MONTH), vo1.getCalendar().get(Calendar.MONTH));
        Assert.assertEquals(vo.getCalendar().get(Calendar.DAY_OF_MONTH), vo1.getCalendar().get(Calendar.DAY_OF_MONTH));
        Assert.assertEquals(vo.getCalendar().get(Calendar.HOUR_OF_DAY), vo1.getCalendar().get(Calendar.HOUR_OF_DAY));
        Assert.assertEquals(vo.getCalendar().get(Calendar.MINUTE), vo1.getCalendar().get(Calendar.MINUTE));
        Assert.assertEquals(vo.getCalendar().get(Calendar.SECOND), vo1.getCalendar().get(Calendar.SECOND));

            

Reported by PMD.

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

Line: 40

                      
        VO vo1 = JSON.parseObject(text, VO.class);
        Assert.assertEquals(vo.getCalendar().get(Calendar.YEAR), vo1.getCalendar().get(Calendar.YEAR));
        Assert.assertEquals(vo.getCalendar().get(Calendar.MONTH), vo1.getCalendar().get(Calendar.MONTH));
        Assert.assertEquals(vo.getCalendar().get(Calendar.DAY_OF_MONTH), vo1.getCalendar().get(Calendar.DAY_OF_MONTH));
        Assert.assertEquals(vo.getCalendar().get(Calendar.HOUR_OF_DAY), vo1.getCalendar().get(Calendar.HOUR_OF_DAY));
        Assert.assertEquals(vo.getCalendar().get(Calendar.MINUTE), vo1.getCalendar().get(Calendar.MINUTE));
        Assert.assertEquals(vo.getCalendar().get(Calendar.SECOND), vo1.getCalendar().get(Calendar.SECOND));
    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/path/JSONPath_2.java
45 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 11

              import junit.framework.TestCase;

public class JSONPath_2 extends TestCase {
    public void test_path() throws Exception {
        String json ="{\"user\":[{\"amount\":1.11,\"isadmin\":true,\"age\":18},{\"amount\":0.22,\"isadmin\":false,\"age\":28}]}";
        
        
        {
            JSONArray array = (JSONArray) JSONPath.read(json, "$.user");

            

Reported by PMD.

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

Line: 17

                      
        {
            JSONArray array = (JSONArray) JSONPath.read(json, "$.user");
            Assert.assertEquals(2, array.size());
            
            Assert.assertTrue(1.11D == array.getJSONObject(0).getDoubleValue("amount"));
            Assert.assertTrue(array.getJSONObject(0).getBoolean("isadmin"));
            Assert.assertTrue(18 == array.getJSONObject(0).getIntValue("age"));
            

            

Reported by PMD.

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

Line: 19

                          JSONArray array = (JSONArray) JSONPath.read(json, "$.user");
            Assert.assertEquals(2, array.size());
            
            Assert.assertTrue(1.11D == array.getJSONObject(0).getDoubleValue("amount"));
            Assert.assertTrue(array.getJSONObject(0).getBoolean("isadmin"));
            Assert.assertTrue(18 == array.getJSONObject(0).getIntValue("age"));
            
            Assert.assertTrue(0.22D == array.getJSONObject(1).getDoubleValue("amount"));
            Assert.assertFalse(array.getJSONObject(1).getBoolean("isadmin"));

            

Reported by PMD.

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

Line: 19

                          JSONArray array = (JSONArray) JSONPath.read(json, "$.user");
            Assert.assertEquals(2, array.size());
            
            Assert.assertTrue(1.11D == array.getJSONObject(0).getDoubleValue("amount"));
            Assert.assertTrue(array.getJSONObject(0).getBoolean("isadmin"));
            Assert.assertTrue(18 == array.getJSONObject(0).getIntValue("age"));
            
            Assert.assertTrue(0.22D == array.getJSONObject(1).getDoubleValue("amount"));
            Assert.assertFalse(array.getJSONObject(1).getBoolean("isadmin"));

            

Reported by PMD.

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

Line: 19

                          JSONArray array = (JSONArray) JSONPath.read(json, "$.user");
            Assert.assertEquals(2, array.size());
            
            Assert.assertTrue(1.11D == array.getJSONObject(0).getDoubleValue("amount"));
            Assert.assertTrue(array.getJSONObject(0).getBoolean("isadmin"));
            Assert.assertTrue(18 == array.getJSONObject(0).getIntValue("age"));
            
            Assert.assertTrue(0.22D == array.getJSONObject(1).getDoubleValue("amount"));
            Assert.assertFalse(array.getJSONObject(1).getBoolean("isadmin"));

            

Reported by PMD.

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

Line: 20

                          Assert.assertEquals(2, array.size());
            
            Assert.assertTrue(1.11D == array.getJSONObject(0).getDoubleValue("amount"));
            Assert.assertTrue(array.getJSONObject(0).getBoolean("isadmin"));
            Assert.assertTrue(18 == array.getJSONObject(0).getIntValue("age"));
            
            Assert.assertTrue(0.22D == array.getJSONObject(1).getDoubleValue("amount"));
            Assert.assertFalse(array.getJSONObject(1).getBoolean("isadmin"));
            Assert.assertTrue(28 == array.getJSONObject(1).getIntValue("age"));

            

Reported by PMD.

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

Line: 20

                          Assert.assertEquals(2, array.size());
            
            Assert.assertTrue(1.11D == array.getJSONObject(0).getDoubleValue("amount"));
            Assert.assertTrue(array.getJSONObject(0).getBoolean("isadmin"));
            Assert.assertTrue(18 == array.getJSONObject(0).getIntValue("age"));
            
            Assert.assertTrue(0.22D == array.getJSONObject(1).getDoubleValue("amount"));
            Assert.assertFalse(array.getJSONObject(1).getBoolean("isadmin"));
            Assert.assertTrue(28 == array.getJSONObject(1).getIntValue("age"));

            

Reported by PMD.

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

Line: 20

                          Assert.assertEquals(2, array.size());
            
            Assert.assertTrue(1.11D == array.getJSONObject(0).getDoubleValue("amount"));
            Assert.assertTrue(array.getJSONObject(0).getBoolean("isadmin"));
            Assert.assertTrue(18 == array.getJSONObject(0).getIntValue("age"));
            
            Assert.assertTrue(0.22D == array.getJSONObject(1).getDoubleValue("amount"));
            Assert.assertFalse(array.getJSONObject(1).getBoolean("isadmin"));
            Assert.assertTrue(28 == array.getJSONObject(1).getIntValue("age"));

            

Reported by PMD.

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

Line: 21

                          
            Assert.assertTrue(1.11D == array.getJSONObject(0).getDoubleValue("amount"));
            Assert.assertTrue(array.getJSONObject(0).getBoolean("isadmin"));
            Assert.assertTrue(18 == array.getJSONObject(0).getIntValue("age"));
            
            Assert.assertTrue(0.22D == array.getJSONObject(1).getDoubleValue("amount"));
            Assert.assertFalse(array.getJSONObject(1).getBoolean("isadmin"));
            Assert.assertTrue(28 == array.getJSONObject(1).getIntValue("age"));
        }

            

Reported by PMD.

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

Line: 21

                          
            Assert.assertTrue(1.11D == array.getJSONObject(0).getDoubleValue("amount"));
            Assert.assertTrue(array.getJSONObject(0).getBoolean("isadmin"));
            Assert.assertTrue(18 == array.getJSONObject(0).getIntValue("age"));
            
            Assert.assertTrue(0.22D == array.getJSONObject(1).getDoubleValue("amount"));
            Assert.assertFalse(array.getJSONObject(1).getBoolean("isadmin"));
            Assert.assertTrue(28 == array.getJSONObject(1).getIntValue("age"));
        }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/jdk8/LocalDateTest5.java
45 issues
This class has too many methods, consider refactoring it.
Design

Line: 12

              
import junit.framework.TestCase;

public class LocalDateTest5 extends TestCase {

    private Locale origin;

    protected void setUp() throws Exception {
        origin = Locale.getDefault();

            

Reported by PMD.

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

Line: 14

              
public class LocalDateTest5 extends TestCase {

    private Locale origin;

    protected void setUp() throws Exception {
        origin = Locale.getDefault();
    }


            

Reported by PMD.

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

Line: 16

              
    private Locale origin;

    protected void setUp() throws Exception {
        origin = Locale.getDefault();
    }

    protected void tearDown() throws Exception {
        Locale.setDefault(origin);

            

Reported by PMD.

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

Line: 20

                      origin = Locale.getDefault();
    }

    protected void tearDown() throws Exception {
        Locale.setDefault(origin);
    }

    public void test_for_tw() throws Exception {
        VO vo = JSON.parseObject("{\"date\":\"2016/05/06\"}", 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: 24

                      Locale.setDefault(origin);
    }

    public void test_for_tw() throws Exception {
        VO vo = JSON.parseObject("{\"date\":\"2016/05/06\"}", VO.class);

        Assert.assertEquals(2016, vo.date.getYear());
        Assert.assertEquals(5, vo.date.getMonthValue());
        Assert.assertEquals(6, vo.date.getDayOfMonth());

            

Reported by PMD.

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

Line: 27

                  public void test_for_tw() throws Exception {
        VO vo = JSON.parseObject("{\"date\":\"2016/05/06\"}", VO.class);

        Assert.assertEquals(2016, vo.date.getYear());
        Assert.assertEquals(5, vo.date.getMonthValue());
        Assert.assertEquals(6, vo.date.getDayOfMonth());
    }

    public void test_for_jp() throws Exception {

            

Reported by PMD.

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

Line: 28

                      VO vo = JSON.parseObject("{\"date\":\"2016/05/06\"}", VO.class);

        Assert.assertEquals(2016, vo.date.getYear());
        Assert.assertEquals(5, vo.date.getMonthValue());
        Assert.assertEquals(6, vo.date.getDayOfMonth());
    }

    public void test_for_jp() throws Exception {
        VO vo = JSON.parseObject("{\"date\":\"2016年5月6日\"}", VO.class);

            

Reported by PMD.

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

Line: 29

              
        Assert.assertEquals(2016, vo.date.getYear());
        Assert.assertEquals(5, vo.date.getMonthValue());
        Assert.assertEquals(6, vo.date.getDayOfMonth());
    }

    public void test_for_jp() throws Exception {
        VO vo = JSON.parseObject("{\"date\":\"2016年5月6日\"}", 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: 32

                      Assert.assertEquals(6, vo.date.getDayOfMonth());
    }

    public void test_for_jp() throws Exception {
        VO vo = JSON.parseObject("{\"date\":\"2016年5月6日\"}", VO.class);

        Assert.assertEquals(2016, vo.date.getYear());
        Assert.assertEquals(5, vo.date.getMonthValue());
        Assert.assertEquals(6, vo.date.getDayOfMonth());

            

Reported by PMD.

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

Line: 35

                  public void test_for_jp() throws Exception {
        VO vo = JSON.parseObject("{\"date\":\"2016年5月6日\"}", VO.class);

        Assert.assertEquals(2016, vo.date.getYear());
        Assert.assertEquals(5, vo.date.getMonthValue());
        Assert.assertEquals(6, vo.date.getDayOfMonth());
    }

    public void test_for_kr() throws Exception {

            

Reported by PMD.

src/test/java/com/alibaba/json/test/TestUtils.java
45 issues
Avoid throwing raw exception types.
Design

Line: 105

              
            return (Long) mbeanServer.getAttribute(objectName, "CollectionCount");
        } catch (Exception e) {
            throw new RuntimeException("error");
        }
    }
    
    public static long getYoungGCTime() {
        try {

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 125

              
            return (Long) mbeanServer.getAttribute(objectName, "CollectionTime");
        } catch (Exception e) {
            throw new RuntimeException("error", e);
        }
    }

    public static long getFullGC() {
        try {

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 146

              
            return (Long) mbeanServer.getAttribute(objectName, "CollectionCount");
        } catch (Exception e) {
            throw new RuntimeException("error");
        }
    }
}

            

Reported by PMD.

All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
Design

Line: 10

              
import com.alibaba.fastjson.util.IOUtils;

public class TestUtils {

    // ****************************************************************************************
    // * char[] version
    // ****************************************************************************************


            

Reported by PMD.

The method 'encodeToChar(byte, boolean)' has a cyclomatic complexity of 11.
Design

Line: 24

                   * No line separator will be in breach of RFC 2045 which specifies max 76 per line but will be a little faster.
     * @return A BASE64 encoded array. Never <code>null</code>.
     */
    private final static char[] encodeToChar(byte[] sArr, boolean lineSep) {
        char[] CA = IOUtils.CA;

        // Check special case
        int sLen = sArr != null ? sArr.length : 0;
        if (sLen == 0) return new char[0];

            

Reported by PMD.

The method 'encodeToChar(byte, boolean)' has an NPath complexity of 200, current threshold is 200
Design

Line: 24

                   * No line separator will be in breach of RFC 2045 which specifies max 76 per line but will be a little faster.
     * @return A BASE64 encoded array. Never <code>null</code>.
     */
    private final static char[] encodeToChar(byte[] sArr, boolean lineSep) {
        char[] CA = IOUtils.CA;

        // Check special case
        int sLen = sArr != null ? sArr.length : 0;
        if (sLen == 0) return new char[0];

            

Reported by PMD.

Too many control variables in the for statement
Design

Line: 37

                      char[] dArr = new char[dLen];

        // Encode even 24-bits
        for (int s = 0, d = 0, cc = 0; s < eLen;) {
            // Copy next three bytes into lower 24 bits of int, paying attension to sign.
            int i = (sArr[s++] & 0xff) << 16 | (sArr[s++] & 0xff) << 8 | (sArr[s++] & 0xff);

            // Encode the int into four chars
            dArr[d++] = CA[(i >>> 18) & 0x3f];

            

Reported by PMD.

Avoid reassigning the loop control variable 's'
Design

Line: 39

                      // Encode even 24-bits
        for (int s = 0, d = 0, cc = 0; s < eLen;) {
            // Copy next three bytes into lower 24 bits of int, paying attension to sign.
            int i = (sArr[s++] & 0xff) << 16 | (sArr[s++] & 0xff) << 8 | (sArr[s++] & 0xff);

            // Encode the int into four chars
            dArr[d++] = CA[(i >>> 18) & 0x3f];
            dArr[d++] = CA[(i >>> 12) & 0x3f];
            dArr[d++] = CA[(i >>> 6) & 0x3f];

            

Reported by PMD.

Avoid reassigning the loop control variable 's'
Design

Line: 39

                      // Encode even 24-bits
        for (int s = 0, d = 0, cc = 0; s < eLen;) {
            // Copy next three bytes into lower 24 bits of int, paying attension to sign.
            int i = (sArr[s++] & 0xff) << 16 | (sArr[s++] & 0xff) << 8 | (sArr[s++] & 0xff);

            // Encode the int into four chars
            dArr[d++] = CA[(i >>> 18) & 0x3f];
            dArr[d++] = CA[(i >>> 12) & 0x3f];
            dArr[d++] = CA[(i >>> 6) & 0x3f];

            

Reported by PMD.

Avoid reassigning the loop control variable 's'
Design

Line: 39

                      // Encode even 24-bits
        for (int s = 0, d = 0, cc = 0; s < eLen;) {
            // Copy next three bytes into lower 24 bits of int, paying attension to sign.
            int i = (sArr[s++] & 0xff) << 16 | (sArr[s++] & 0xff) << 8 | (sArr[s++] & 0xff);

            // Encode the int into four chars
            dArr[d++] = CA[(i >>> 18) & 0x3f];
            dArr[d++] = CA[(i >>> 12) & 0x3f];
            dArr[d++] = CA[(i >>> 6) & 0x3f];

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/parser/deserializer/AbstractDateDeserializer.java
45 issues
Avoid reassigning parameters such as 'clazz'
Design

Line: 21

                  
    @Override
    @SuppressWarnings("unchecked")
    public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName, String format, int features) {
        JSONLexer lexer = parser.lexer;

        Object val;
        if (lexer.token() == JSONToken.LITERAL_INT) {
            long millis = lexer.longValue();

            

Reported by PMD.

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

Line: 13

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

public abstract class AbstractDateDeserializer extends ContextObjectDeserializer implements ObjectDeserializer {

    public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
        return deserialze(parser, clazz, fieldName, null, 0);
    }
    

            

Reported by PMD.

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

Line: 13

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

public abstract class AbstractDateDeserializer extends ContextObjectDeserializer implements ObjectDeserializer {

    public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
        return deserialze(parser, clazz, fieldName, null, 0);
    }
    

            

Reported by PMD.

The method 'deserialze' has a Standard Cyclomatic Complexity of 31.
Design

Line: 21

                  
    @Override
    @SuppressWarnings("unchecked")
    public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName, String format, int features) {
        JSONLexer lexer = parser.lexer;

        Object val;
        if (lexer.token() == JSONToken.LITERAL_INT) {
            long millis = lexer.longValue();

            

Reported by PMD.

The method 'deserialze(DefaultJSONParser, Type, Object, String, int)' has an NPath complexity of 12819, current threshold is 200
Design

Line: 21

                  
    @Override
    @SuppressWarnings("unchecked")
    public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName, String format, int features) {
        JSONLexer lexer = parser.lexer;

        Object val;
        if (lexer.token() == JSONToken.LITERAL_INT) {
            long millis = lexer.longValue();

            

Reported by PMD.

The method 'deserialze(DefaultJSONParser, Type, Object, String, int)' has a cyclomatic complexity of 41.
Design

Line: 21

                  
    @Override
    @SuppressWarnings("unchecked")
    public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName, String format, int features) {
        JSONLexer lexer = parser.lexer;

        Object val;
        if (lexer.token() == JSONToken.LITERAL_INT) {
            long millis = lexer.longValue();

            

Reported by PMD.

Avoid really long methods.
Design

Line: 21

                  
    @Override
    @SuppressWarnings("unchecked")
    public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName, String format, int features) {
        JSONLexer lexer = parser.lexer;

        Object val;
        if (lexer.token() == JSONToken.LITERAL_INT) {
            long millis = lexer.longValue();

            

Reported by PMD.

The method 'deserialze' has a Modified Cyclomatic Complexity of 31.
Design

Line: 21

                  
    @Override
    @SuppressWarnings("unchecked")
    public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName, String format, int features) {
        JSONLexer lexer = parser.lexer;

        Object val;
        if (lexer.token() == JSONToken.LITERAL_INT) {
            long millis = lexer.longValue();

            

Reported by PMD.

The method 'deserialze(DefaultJSONParser, Type, Object, String, int)' has a NCSS line count of 105.
Design

Line: 21

                  
    @Override
    @SuppressWarnings("unchecked")
    public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName, String format, int features) {
        JSONLexer lexer = parser.lexer;

        Object val;
        if (lexer.token() == JSONToken.LITERAL_INT) {
            long millis = lexer.longValue();

            

Reported by PMD.

The method deserialze() has an NCSS line count of 105
Design

Line: 21

                  
    @Override
    @SuppressWarnings("unchecked")
    public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName, String format, int features) {
        JSONLexer lexer = parser.lexer;

        Object val;
        if (lexer.token() == JSONToken.LITERAL_INT) {
            long millis = lexer.longValue();

            

Reported by PMD.