The following issues were found

src/test/java/com/alibaba/json/bvt/IncomingDataPointTest.java
10 issues
System.out.println is used
Design

Line: 30

                      IncomingDataPoint[] array = new IncomingDataPoint[] {point};

        String json = JSON.toJSONString(array);
        System.out.println(json);

        JSON.parseArray(json, IncomingDataPoint.class);

        IncomingDataPoint p2 = JSON.parseObject("[\"mem.usage.GB\",1501833776283,\"58.41\",{\"site\":\"et2\",\"appname\":\"histore\",\"ip\":\"1.1.1.1\"}]", IncomingDataPoint.class);
        IncomingDataPoint p3 = JSON.parseObject("[\"mem.usage.GB\",1501833776283,\"58.41\",{\"site\":\"et2\",\"appname\":\"histore\",\"ip\":\"1.1.1.1\"},null]", IncomingDataPoint.class);

            

Reported by PMD.

System.out.println is used
Design

Line: 36

              
        IncomingDataPoint p2 = JSON.parseObject("[\"mem.usage.GB\",1501833776283,\"58.41\",{\"site\":\"et2\",\"appname\":\"histore\",\"ip\":\"1.1.1.1\"}]", IncomingDataPoint.class);
        IncomingDataPoint p3 = JSON.parseObject("[\"mem.usage.GB\",1501833776283,\"58.41\",{\"site\":\"et2\",\"appname\":\"histore\",\"ip\":\"1.1.1.1\"},null]", IncomingDataPoint.class);
        System.out.println(JSON.toJSONString(p2));
//        JSON.parseObject(json, IncomingDataPoint[].class);
    }
    public void test_for_IncomingDataPoint() throws Exception {
        // "metric", "timestamp", "value", "tags", "tsuid", "granularity", "aggregator"
        String text = "[[\"DataAdaptor.LbMultiGroupPersonalityDataAdaptor.stddev.aggregate_sum\",\"1501812639932\",\"95.52667633256902\",{\"appName\":\"aladdin\",\"hostIdc\":\"et2\",\"hostunit\":\"CENTER\",\"nodegroup\":\"aladdin_prehost\",\"idc\":\"ET2\",\"agg_version\":\"100\",\"group\":\"DEFAULT\"},\"\",\"\",\"\"]]";

            

Reported by PMD.

System.out.println is used
Design

Line: 42

                  public void test_for_IncomingDataPoint() throws Exception {
        // "metric", "timestamp", "value", "tags", "tsuid", "granularity", "aggregator"
        String text = "[[\"DataAdaptor.LbMultiGroupPersonalityDataAdaptor.stddev.aggregate_sum\",\"1501812639932\",\"95.52667633256902\",{\"appName\":\"aladdin\",\"hostIdc\":\"et2\",\"hostunit\":\"CENTER\",\"nodegroup\":\"aladdin_prehost\",\"idc\":\"ET2\",\"agg_version\":\"100\",\"group\":\"DEFAULT\"},\"\",\"\",\"\"]]";
        System.out.println(text);
        JSON.parseArray(text, IncomingDataPoint.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: 14

               * Created by wenshao on 03/08/2017.
 */
public class IncomingDataPointTest extends TestCase {
    public void test_0() throws Exception {
        Map<String, String> tags = new LinkedHashMap<String, String>();
        tags.put("site", "et2");
        tags.put("appname", "histore");
        tags.put("ip", "1.1.1.1");


            

Reported by PMD.

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

Line: 14

               * Created by wenshao on 03/08/2017.
 */
public class IncomingDataPointTest extends TestCase {
    public void test_0() throws Exception {
        Map<String, String> tags = new LinkedHashMap<String, String>();
        tags.put("site", "et2");
        tags.put("appname", "histore");
        tags.put("ip", "1.1.1.1");


            

Reported by PMD.

Do not hard code the IP address
Design

Line: 18

                      Map<String, String> tags = new LinkedHashMap<String, String>();
        tags.put("site", "et2");
        tags.put("appname", "histore");
        tags.put("ip", "1.1.1.1");

        IncomingDataPoint point = new IncomingDataPoint();
        point.setMetric("mem.usage.GB");
        point.setTimestamp(1501760861298L);
        point.setTags(tags);

            

Reported by PMD.

Avoid unused local variables such as 'p3'.
Design

Line: 35

                      JSON.parseArray(json, IncomingDataPoint.class);

        IncomingDataPoint p2 = JSON.parseObject("[\"mem.usage.GB\",1501833776283,\"58.41\",{\"site\":\"et2\",\"appname\":\"histore\",\"ip\":\"1.1.1.1\"}]", IncomingDataPoint.class);
        IncomingDataPoint p3 = JSON.parseObject("[\"mem.usage.GB\",1501833776283,\"58.41\",{\"site\":\"et2\",\"appname\":\"histore\",\"ip\":\"1.1.1.1\"},null]", IncomingDataPoint.class);
        System.out.println(JSON.toJSONString(p2));
//        JSON.parseObject(json, IncomingDataPoint[].class);
    }
    public void test_for_IncomingDataPoint() throws Exception {
        // "metric", "timestamp", "value", "tags", "tsuid", "granularity", "aggregator"

            

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

                      System.out.println(JSON.toJSONString(p2));
//        JSON.parseObject(json, IncomingDataPoint[].class);
    }
    public void test_for_IncomingDataPoint() throws Exception {
        // "metric", "timestamp", "value", "tags", "tsuid", "granularity", "aggregator"
        String text = "[[\"DataAdaptor.LbMultiGroupPersonalityDataAdaptor.stddev.aggregate_sum\",\"1501812639932\",\"95.52667633256902\",{\"appName\":\"aladdin\",\"hostIdc\":\"et2\",\"hostunit\":\"CENTER\",\"nodegroup\":\"aladdin_prehost\",\"idc\":\"ET2\",\"agg_version\":\"100\",\"group\":\"DEFAULT\"},\"\",\"\",\"\"]]";
        System.out.println(text);
        JSON.parseArray(text, IncomingDataPoint.class);
    }

            

Reported by PMD.

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

Line: 39

                      System.out.println(JSON.toJSONString(p2));
//        JSON.parseObject(json, IncomingDataPoint[].class);
    }
    public void test_for_IncomingDataPoint() throws Exception {
        // "metric", "timestamp", "value", "tags", "tsuid", "granularity", "aggregator"
        String text = "[[\"DataAdaptor.LbMultiGroupPersonalityDataAdaptor.stddev.aggregate_sum\",\"1501812639932\",\"95.52667633256902\",{\"appName\":\"aladdin\",\"hostIdc\":\"et2\",\"hostunit\":\"CENTER\",\"nodegroup\":\"aladdin_prehost\",\"idc\":\"ET2\",\"agg_version\":\"100\",\"group\":\"DEFAULT\"},\"\",\"\",\"\"]]";
        System.out.println(text);
        JSON.parseArray(text, IncomingDataPoint.class);
    }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'p3' (lines '35'-'38').
Error

Line: 35

                      JSON.parseArray(json, IncomingDataPoint.class);

        IncomingDataPoint p2 = JSON.parseObject("[\"mem.usage.GB\",1501833776283,\"58.41\",{\"site\":\"et2\",\"appname\":\"histore\",\"ip\":\"1.1.1.1\"}]", IncomingDataPoint.class);
        IncomingDataPoint p3 = JSON.parseObject("[\"mem.usage.GB\",1501833776283,\"58.41\",{\"site\":\"et2\",\"appname\":\"histore\",\"ip\":\"1.1.1.1\"},null]", IncomingDataPoint.class);
        System.out.println(JSON.toJSONString(p2));
//        JSON.parseObject(json, IncomingDataPoint[].class);
    }
    public void test_for_IncomingDataPoint() throws Exception {
        // "metric", "timestamp", "value", "tags", "tsuid", "granularity", "aggregator"

            

Reported by PMD.

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

Line: 14

               * Created by wenshao on 01/07/2017.
 */
public class Issue1300 extends TestCase {
    public void testFullJSON() {
        JSONObject data = new JSONObject();
        data.put("name", "string");
        data.put("code", 1);
        data.put("pinyin", "pinyin");
        City object = TypeUtils.castToJavaBean(data, City.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: 14

               * Created by wenshao on 01/07/2017.
 */
public class Issue1300 extends TestCase {
    public void testFullJSON() {
        JSONObject data = new JSONObject();
        data.put("name", "string");
        data.put("code", 1);
        data.put("pinyin", "pinyin");
        City object = TypeUtils.castToJavaBean(data, City.class);

            

Reported by PMD.

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

Line: 18

                      JSONObject data = new JSONObject();
        data.put("name", "string");
        data.put("code", 1);
        data.put("pinyin", "pinyin");
        City object = TypeUtils.castToJavaBean(data, City.class);
        assertEquals("string", object.name);
        assertEquals(1, object.code);
        assertEquals("pinyin", object.pinyin);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

                      data.put("code", 1);
        data.put("pinyin", "pinyin");
        City object = TypeUtils.castToJavaBean(data, City.class);
        assertEquals("string", object.name);
        assertEquals(1, object.code);
        assertEquals("pinyin", object.pinyin);
    }

    public void testEmptyJSON() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 21

                      data.put("pinyin", "pinyin");
        City object = TypeUtils.castToJavaBean(data, City.class);
        assertEquals("string", object.name);
        assertEquals(1, object.code);
        assertEquals("pinyin", object.pinyin);
    }

    public void testEmptyJSON() {
        City object = TypeUtils.castToJavaBean(new JSONObject(), City.class);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

                      City object = TypeUtils.castToJavaBean(data, City.class);
        assertEquals("string", object.name);
        assertEquals(1, object.code);
        assertEquals("pinyin", object.pinyin);
    }

    public void testEmptyJSON() {
        City object = TypeUtils.castToJavaBean(new JSONObject(), City.class);
        Assert.assertEquals(null, object.name);

            

Reported by PMD.

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

Line: 25

                      assertEquals("pinyin", object.pinyin);
    }

    public void testEmptyJSON() {
        City object = TypeUtils.castToJavaBean(new JSONObject(), City.class);
        Assert.assertEquals(null, object.name);
        Assert.assertEquals(0, object.code);
    }


            

Reported by PMD.

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

Line: 33

              

    public static class City implements Parcelable {
        public final int code;
        public final String name;
        public final String pinyin;

        @JSONCreator
        public City(@JSONField(name = "code") int code,

            

Reported by PMD.

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

Line: 34

              
    public static class City implements Parcelable {
        public final int code;
        public final String name;
        public final String pinyin;

        @JSONCreator
        public City(@JSONField(name = "code") int code,
                    @JSONField(name = "name") String name,

            

Reported by PMD.

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

Line: 35

                  public static class City implements Parcelable {
        public final int code;
        public final String name;
        public final String pinyin;

        @JSONCreator
        public City(@JSONField(name = "code") int code,
                    @JSONField(name = "name") String name,
                    @JSONField(name = "pinyin") String pinyin) {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/SpecialTest.java
10 issues
System.out.println is used
Design

Line: 16

                              count++;
            }
        }
        System.out.println(count);
    }
    
    final static long flags;
    static {
        long val = 0L;

            

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

              
import com.alibaba.fastjson.serializer.SerializerFeature;

public class SpecialTest {
    
    public static void main(String[] args) throws Exception {
        
        int count = 0;
        for (int i = 0; i < 1000; ++i) {

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 7

              
public class SpecialTest {
    
    public static void main(String[] args) throws Exception {
        
        int count = 0;
        for (int i = 0; i < 1000; ++i) {
            char ch = (char) i;
            if(isSpecial(ch)) {

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 28

                  }
    
    static boolean isSpecial(char ch) {
        if (ch <= 31) {
            return true;
        }
        
        if (ch > '\\') { // 92
            return false;

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 32

                          return true;
        }
        
        if (ch > '\\') { // 92
            return false;
        }
        
        return ((1L << (ch - 31)) & flags) != 0;
    }

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 44

                      // return false;
        // }
        
        if (ch == ' ') { // 32
            return false;
        }

        if (ch == '/') { // 47
            return SerializerFeature.isEnabled(features, SerializerFeature.WriteSlashAsSpecial);

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 48

                          return false;
        }

        if (ch == '/') { // 47
            return SerializerFeature.isEnabled(features, SerializerFeature.WriteSlashAsSpecial);
        }

        if (ch > '#' // 35
            && ch != '\\' // 92

            

Reported by PMD.

Avoid unnecessary if..then..else statements when returning booleans
Design

Line: 58

                          return false;
        }

        if (ch <= 0x1F // 31
                || ch == '\\' // 92
                || ch == '"' // 34
                ) {
            return true;
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'count' (lines '9'-'13').
Error

Line: 9

                  
    public static void main(String[] args) throws Exception {
        
        int count = 0;
        for (int i = 0; i < 1000; ++i) {
            char ch = (char) i;
            if(isSpecial(ch)) {
                count++;
            }

            

Reported by PMD.

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

Line: 13

                      for (int i = 0; i < 1000; ++i) {
            char ch = (char) i;
            if(isSpecial(ch)) {
                count++;
            }
        }
        System.out.println(count);
    }
    

            

Reported by PMD.

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

Line: 16

               * Created by kimmking on 02/07/2017.
 */
public class Issue1303 extends TestCase {
    public void test_for_issue() {
        String jsonString = "[{\"author\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"a876c49c18\"},\"createdAt\":\"2017-07-02 20:06:13\",\"imgurl\":\"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=11075891,34401011&fm=117&gp=0.jpg\",\"name\":\"衣架\",\"objectId\":\"029d5493cd\",\"prices\":\"1\",\"updatedAt\":\"2017-07-02 20:06:13\"}]";
        JSONArray jsonArray = JSON.parseArray(jsonString);
        //jsonArray = new JSONArray(jsonArray);//这一句打开也一样是正确的
        double total = 0;
        for (int i = 0; i <jsonArray.size() ; i++) {

            

Reported by PMD.

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

Line: 16

               * Created by kimmking on 02/07/2017.
 */
public class Issue1303 extends TestCase {
    public void test_for_issue() {
        String jsonString = "[{\"author\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"a876c49c18\"},\"createdAt\":\"2017-07-02 20:06:13\",\"imgurl\":\"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=11075891,34401011&fm=117&gp=0.jpg\",\"name\":\"衣架\",\"objectId\":\"029d5493cd\",\"prices\":\"1\",\"updatedAt\":\"2017-07-02 20:06:13\"}]";
        JSONArray jsonArray = JSON.parseArray(jsonString);
        //jsonArray = new JSONArray(jsonArray);//这一句打开也一样是正确的
        double total = 0;
        for (int i = 0; i <jsonArray.size() ; i++) {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 23

                      double total = 0;
        for (int i = 0; i <jsonArray.size() ; i++) {
            JSONObject object=jsonArray.getJSONObject(i);
            assertEquals("衣架",object.getString("name"));
            total=total+ Double.valueOf(object.getString("prices"));
        }
        assertEquals(1.0d,total);
    }
}

            

Reported by PMD.

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

Line: 23

                      double total = 0;
        for (int i = 0; i <jsonArray.size() ; i++) {
            JSONObject object=jsonArray.getJSONObject(i);
            assertEquals("衣架",object.getString("name"));
            total=total+ Double.valueOf(object.getString("prices"));
        }
        assertEquals(1.0d,total);
    }
}

            

Reported by PMD.

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

Line: 24

                      for (int i = 0; i <jsonArray.size() ; i++) {
            JSONObject object=jsonArray.getJSONObject(i);
            assertEquals("衣架",object.getString("name"));
            total=total+ Double.valueOf(object.getString("prices"));
        }
        assertEquals(1.0d,total);
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 26

                          assertEquals("衣架",object.getString("name"));
            total=total+ Double.valueOf(object.getString("prices"));
        }
        assertEquals(1.0d,total);
    }
}

            

Reported by PMD.

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

Line: 6

              import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.util.TypeUtils;
import junit.framework.TestCase;
import org.junit.Assert;


            

Reported by PMD.

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

Line: 7

              import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.util.TypeUtils;
import junit.framework.TestCase;
import org.junit.Assert;

/**

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.util.TypeUtils'
Design

Line: 8

              import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.util.TypeUtils;
import junit.framework.TestCase;
import org.junit.Assert;

/**
 * Created by kimmking on 02/07/2017.

            

Reported by PMD.

Avoid unused imports such as 'org.junit.Assert'
Design

Line: 10

              import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.util.TypeUtils;
import junit.framework.TestCase;
import org.junit.Assert;

/**
 * Created by kimmking on 02/07/2017.
 */
public class Issue1303 extends TestCase {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1200/Issue1271.java
10 issues
System.out.println is used
Design

Line: 19

                      final AtomicInteger count = new AtomicInteger(0);
        ExtraProcessor extraProcessor = new ExtraProcessor() {
            public void processExtra(Object object, String key, Object value) {
                System.out.println("setter not found, class " + object.getClass().getName() + ", property " + key);
                count.incrementAndGet();
            }
        };



            

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

               * Created by kimmking on 15/06/2017.
 */
public class Issue1271 extends TestCase {
    public void test_for_issue() throws Exception {

        String json = "{\"a\":1,\"b\":2}";

        final AtomicInteger count = new AtomicInteger(0);
        ExtraProcessor extraProcessor = new ExtraProcessor() {

            

Reported by PMD.

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

Line: 12

               * Created by kimmking on 15/06/2017.
 */
public class Issue1271 extends TestCase {
    public void test_for_issue() throws Exception {

        String json = "{\"a\":1,\"b\":2}";

        final AtomicInteger count = new AtomicInteger(0);
        ExtraProcessor extraProcessor = new ExtraProcessor() {

            

Reported by PMD.

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

Line: 19

                      final AtomicInteger count = new AtomicInteger(0);
        ExtraProcessor extraProcessor = new ExtraProcessor() {
            public void processExtra(Object object, String key, Object value) {
                System.out.println("setter not found, class " + object.getClass().getName() + ", property " + key);
                count.incrementAndGet();
            }
        };



            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 26

              

        A a = JSON.parseObject(json,A.class,extraProcessor);
        assertEquals(1,a.a);
        assertEquals(1, count.intValue());

        B b = JSON.parseObject(json,B.class,extraProcessor);
        assertEquals(1,b.a);
        assertEquals(2, count.intValue());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 27

              
        A a = JSON.parseObject(json,A.class,extraProcessor);
        assertEquals(1,a.a);
        assertEquals(1, count.intValue());

        B b = JSON.parseObject(json,B.class,extraProcessor);
        assertEquals(1,b.a);
        assertEquals(2, count.intValue());


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

                      assertEquals(1, count.intValue());

        B b = JSON.parseObject(json,B.class,extraProcessor);
        assertEquals(1,b.a);
        assertEquals(2, count.intValue());

    }

    public static class A {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 31

              
        B b = JSON.parseObject(json,B.class,extraProcessor);
        assertEquals(1,b.a);
        assertEquals(2, count.intValue());

    }

    public static class A {
        public int a;

            

Reported by PMD.

It is somewhat confusing to have a field name matching the declaring class name
Error

Line: 36

                  }

    public static class A {
        public int a;
    }

    public static class B {
        private int a;


            

Reported by PMD.

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

Line: 36

                  }

    public static class A {
        public int a;
    }

    public static class B {
        private int a;


            

Reported by PMD.

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

Line: 16

               * Created by wenshao on 16/8/11.
 */
public class Bug_for_issue_569_1 extends TestCase {
    public void test_for_issue() throws Exception {
        String str = "{\"bList\":[{\"data\":[0,1]},{\"data\":[1,2]},{\"data\":[2,3]},{\"data\":[3,4]},{\"data\":[4,5]},{\"data\":[5,6]},{\"data\":[6,7]},{\"data\":[7,8]},{\"data\":[8,9]},{\"data\":[9,10]}]}";
        A<Integer> aInteger;
        A<Long> aLong;

//        aInteger = JSON.parseObject(str, new TypeReference<A<Integer>>() {

            

Reported by PMD.

Avoid unused local variables such as 'aInteger'.
Design

Line: 18

              public class Bug_for_issue_569_1 extends TestCase {
    public void test_for_issue() throws Exception {
        String str = "{\"bList\":[{\"data\":[0,1]},{\"data\":[1,2]},{\"data\":[2,3]},{\"data\":[3,4]},{\"data\":[4,5]},{\"data\":[5,6]},{\"data\":[6,7]},{\"data\":[7,8]},{\"data\":[8,9]},{\"data\":[9,10]}]}";
        A<Integer> aInteger;
        A<Long> aLong;

//        aInteger = JSON.parseObject(str, new TypeReference<A<Integer>>() {
//        });
//        Assert.assertEquals(aInteger.getbList().get(0).getData().get(0).getClass().getName(), Integer.class.getName());

            

Reported by PMD.

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

Line: 27

              //
        aLong = JSON.parseObject(str, new TypeReference<A<Long>>() {
        });
        Assert.assertEquals(aLong.getbList().get(0).getData().get(0).getClass().getName(), Long.class.getName());

    }




            

Reported by PMD.

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

Line: 27

              //
        aLong = JSON.parseObject(str, new TypeReference<A<Long>>() {
        });
        Assert.assertEquals(aLong.getbList().get(0).getData().get(0).getClass().getName(), Long.class.getName());

    }




            

Reported by PMD.

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

Line: 27

              //
        aLong = JSON.parseObject(str, new TypeReference<A<Long>>() {
        });
        Assert.assertEquals(aLong.getbList().get(0).getData().get(0).getClass().getName(), Long.class.getName());

    }




            

Reported by PMD.

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

Line: 27

              //
        aLong = JSON.parseObject(str, new TypeReference<A<Long>>() {
        });
        Assert.assertEquals(aLong.getbList().get(0).getData().get(0).getClass().getName(), Long.class.getName());

    }




            

Reported by PMD.

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

Line: 27

              //
        aLong = JSON.parseObject(str, new TypeReference<A<Long>>() {
        });
        Assert.assertEquals(aLong.getbList().get(0).getData().get(0).getClass().getName(), Long.class.getName());

    }




            

Reported by PMD.

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

Line: 34

              

    public static class A<T> {
        private List<B<T>> bList;

        public List<B<T>> getbList() {
            return bList;
        }


            

Reported by PMD.

Avoid unused imports such as 'com.google.gson.Gson'
Design

Line: 5

              
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import junit.framework.TestCase;
import org.junit.Assert;

import java.util.List;

            

Reported by PMD.

Avoid unused imports such as 'com.google.gson.reflect.TypeToken'
Design

Line: 6

              import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import junit.framework.TestCase;
import org.junit.Assert;

import java.util.List;


            

Reported by PMD.

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

Line: 13

              import junit.framework.TestCase;

public class Bug_for_issue_465 extends TestCase {
    public void test_for_issue() throws Exception {
        String json = "[\"abc\",\"efg\",\"sss\",[1,2]]";
        
        TestBean testBean = JSON.parseObject(json, TestBean.class);
        Assert.assertEquals("abc", testBean.name);
        Assert.assertEquals("efg", testBean.country);

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 25

                      Assert.assertEquals(2, testBean.location[1]);
    }
    
    public void f_test_for_issue_private() throws Exception {
        String json = "[\"abc\",\"efg\",\"sss\",[1,2]]";
        
        TestBean1 testBean = JSON.parseObject(json, TestBean1.class);
        Assert.assertEquals("abc", testBean.name);
        Assert.assertEquals("efg", testBean.country);

            

Reported by PMD.

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

Line: 38

                  }
    
    @JSONType(parseFeatures = Feature.SupportArrayToBean)
    public static class TestBean {
      private String name;

      private String password;

      private String country;

            

Reported by PMD.

Returning 'location' may expose an internal array.
Design

Line: 75

                    }

      public int[] getLocation() {
        return location;
      }

      @JSONField(ordinal = 3)
      public void setLocation(int[] location) {
        this.location = location;

            

Reported by PMD.

The user-supplied array 'location' is stored directly.
Design

Line: 79

                    }

      @JSONField(ordinal = 3)
      public void setLocation(int[] location) {
        this.location = location;
      }
    }
    
    @JSONType(parseFeatures = Feature.SupportArrayToBean)

            

Reported by PMD.

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

Line: 85

                  }
    
    @JSONType(parseFeatures = Feature.SupportArrayToBean)
    private static class TestBean1 {
      private String name;

      private String password;

      private String country;

            

Reported by PMD.

Returning 'location' may expose an internal array.
Design

Line: 122

                    }

      public int[] getLocation() {
        return location;
      }

      @JSONField(ordinal = 3)
      public void setLocation(int[] location) {
        this.location = location;

            

Reported by PMD.

The user-supplied array 'location' is stored directly.
Design

Line: 126

                    }

      @JSONField(ordinal = 3)
      public void setLocation(int[] location) {
        this.location = location;
      }
    }
}

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 79

                    }

      @JSONField(ordinal = 3)
      public void setLocation(int[] location) {
        this.location = location;
      }
    }
    
    @JSONType(parseFeatures = Feature.SupportArrayToBean)

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 126

                    }

      @JSONField(ordinal = 3)
      public void setLocation(int[] location) {
        this.location = location;
      }
    }
}

            

Reported by PMD.

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

Line: 10

              import java.util.List;

public class Issue2132 extends TestCase {
    public void test_for_issue() throws Exception {
        Cpu cpu = new Cpu("intel", 3.3);
        Screen screen = new Screen(16, 9, "samsung");
        Student student = new Student();
        Computer computer = student.assembling(cpu,screen);
        cpu.setName("intell");

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 27

                      list1.add(computer);
        String s = JSON.toJSONString(list1);

        assertEquals("[[{\"name\":\"intell\",\"speed\":3.3},{\"height\":9,\"name\":\"samsung\",\"width\":16},\"2\",\"3\"],{\"cpu\":{\"$ref\":\"$[0][0]\"},\"screen\":{\"$ref\":\"$[0][1]\"}}]", s);
    }

    public static class Cpu {
        private String name;
        private double speed;

            

Reported by PMD.

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

Line: 30

                      assertEquals("[[{\"name\":\"intell\",\"speed\":3.3},{\"height\":9,\"name\":\"samsung\",\"width\":16},\"2\",\"3\"],{\"cpu\":{\"$ref\":\"$[0][0]\"},\"screen\":{\"$ref\":\"$[0][1]\"}}]", s);
    }

    public static class Cpu {
        private String name;
        private double speed;

        public Cpu(String name, double speed) {
            this.name = name;

            

Reported by PMD.

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

Line: 56

                      }
    }

    public static class Screen {
        private int width;
        private int height;
        private String name;

        public Screen(int width, int height, String name) {

            

Reported by PMD.

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

Line: 92

                      }
    }

    public static class Computer {
        Cpu cpu;
        Screen screen;

        public Computer(Cpu cpu, Screen screen) {
            this.cpu = cpu;

            

Reported by PMD.

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

Line: 118

                      }
    }

    public static class Student {
        private Cpu cpu;
        private Screen screen;

        public Computer assembling(Cpu cpu, Screen screen) {
            this.cpu = cpu;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'objectArray' (lines '17'-'18').
Error

Line: 17

                      Computer computer = student.assembling(cpu,screen);
        cpu.setName("intell");

        Object[] objectArray = new Object[4];
        objectArray[0] = cpu;
        objectArray[1] = screen;
        objectArray[2] = "2";
        objectArray[3] = "3";
        List<Object> list1 = new ArrayList<Object>();

            

Reported by PMD.

Found 'DD'-anomaly for variable 'objectArray' (lines '18'-'19').
Error

Line: 18

                      cpu.setName("intell");

        Object[] objectArray = new Object[4];
        objectArray[0] = cpu;
        objectArray[1] = screen;
        objectArray[2] = "2";
        objectArray[3] = "3";
        List<Object> list1 = new ArrayList<Object>();
        list1.add(objectArray);

            

Reported by PMD.

Found 'DD'-anomaly for variable 'objectArray' (lines '19'-'20').
Error

Line: 19

              
        Object[] objectArray = new Object[4];
        objectArray[0] = cpu;
        objectArray[1] = screen;
        objectArray[2] = "2";
        objectArray[3] = "3";
        List<Object> list1 = new ArrayList<Object>();
        list1.add(objectArray);
        list1.add(computer);

            

Reported by PMD.

Found 'DD'-anomaly for variable 'objectArray' (lines '20'-'21').
Error

Line: 20

                      Object[] objectArray = new Object[4];
        objectArray[0] = cpu;
        objectArray[1] = screen;
        objectArray[2] = "2";
        objectArray[3] = "3";
        List<Object> list1 = new ArrayList<Object>();
        list1.add(objectArray);
        list1.add(computer);
        String s = JSON.toJSONString(list1);

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/CurrencyTest5.java
10 issues
System.out.println is used
Design

Line: 21

                      jsonObject.put("value", Currency.getInstance("CNY"));

        String text = JSON.toJSONString(jsonObject, config);
        System.out.println(text);
        String str1 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"Chinese Yuan\",\"symbol\":\"CNY\"}}";
        String str2 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"symbol\":\"¥\"}}";
        String str3 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"Chinese Yuan\",\"numericCodeAsString\":\"156\",\"symbol\":\"CN¥\"}}";
        String str4 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"numericCodeAsString\":\"156\",\"symbol\":\"¥\"}}";
        assertTrue(text.equals(str1)

            

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

              
public class CurrencyTest5 extends TestCase {

    public void test_0() throws Exception {
        SerializeConfig config = new SerializeConfig();
        config.put(Currency.class
                , config.createJavaBeanSerializer(Currency.class));

        JSONObject jsonObject = new JSONObject();

            

Reported by PMD.

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

Line: 12

              
public class CurrencyTest5 extends TestCase {

    public void test_0() throws Exception {
        SerializeConfig config = new SerializeConfig();
        config.put(Currency.class
                , config.createJavaBeanSerializer(Currency.class));

        JSONObject jsonObject = new JSONObject();

            

Reported by PMD.

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

Line: 26

                      String str2 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"symbol\":\"¥\"}}";
        String str3 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"Chinese Yuan\",\"numericCodeAsString\":\"156\",\"symbol\":\"CN¥\"}}";
        String str4 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"numericCodeAsString\":\"156\",\"symbol\":\"¥\"}}";
        assertTrue(text.equals(str1)
                || text.equals(str2)
                || text.equals(str3)
                || text.equals(str4));

        Currency currency = JSON.parseObject(text, VO.class).value;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 26

                      String str2 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"symbol\":\"¥\"}}";
        String str3 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"Chinese Yuan\",\"numericCodeAsString\":\"156\",\"symbol\":\"CN¥\"}}";
        String str4 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"numericCodeAsString\":\"156\",\"symbol\":\"¥\"}}";
        assertTrue(text.equals(str1)
                || text.equals(str2)
                || text.equals(str3)
                || text.equals(str4));

        Currency currency = JSON.parseObject(text, VO.class).value;

            

Reported by PMD.

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

Line: 27

                      String str3 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"Chinese Yuan\",\"numericCodeAsString\":\"156\",\"symbol\":\"CN¥\"}}";
        String str4 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"numericCodeAsString\":\"156\",\"symbol\":\"¥\"}}";
        assertTrue(text.equals(str1)
                || text.equals(str2)
                || text.equals(str3)
                || text.equals(str4));

        Currency currency = JSON.parseObject(text, VO.class).value;


            

Reported by PMD.

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

Line: 28

                      String str4 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"numericCodeAsString\":\"156\",\"symbol\":\"¥\"}}";
        assertTrue(text.equals(str1)
                || text.equals(str2)
                || text.equals(str3)
                || text.equals(str4));

        Currency currency = JSON.parseObject(text, VO.class).value;

        assertSame(Currency.getInstance("CNY"), currency);

            

Reported by PMD.

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

Line: 29

                      assertTrue(text.equals(str1)
                || text.equals(str2)
                || text.equals(str3)
                || text.equals(str4));

        Currency currency = JSON.parseObject(text, VO.class).value;

        assertSame(Currency.getInstance("CNY"), currency);
    }

            

Reported by PMD.

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

Line: 31

                              || text.equals(str3)
                || text.equals(str4));

        Currency currency = JSON.parseObject(text, VO.class).value;

        assertSame(Currency.getInstance("CNY"), currency);
    }

    public static class VO {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 33

              
        Currency currency = JSON.parseObject(text, VO.class).value;

        assertSame(Currency.getInstance("CNY"), currency);
    }

    public static class VO {
        public Currency value;


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/ProxyTest2.java
10 issues
System.out.println is used
Design

Line: 15

                  public void test_0() throws Exception {
        Model model = JSON.parseObject("{\"id\":1001}", Model.class);
        Model model2 = JSON.parseObject("{\"id\":1001}", Model.class);
        System.out.println(model.getId());

//        System.out.println(model.getClass());
//        System.out.println(model2.getClass());

        assertEquals("{\"id\":1001}", JSON.toJSONString(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: 12

               * Created by wenshao on 07/08/2017.
 */
public class ProxyTest2 extends TestCase {
    public void test_0() throws Exception {
        Model model = JSON.parseObject("{\"id\":1001}", Model.class);
        Model model2 = JSON.parseObject("{\"id\":1001}", Model.class);
        System.out.println(model.getId());

//        System.out.println(model.getClass());

            

Reported by PMD.

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

Line: 12

               * Created by wenshao on 07/08/2017.
 */
public class ProxyTest2 extends TestCase {
    public void test_0() throws Exception {
        Model model = JSON.parseObject("{\"id\":1001}", Model.class);
        Model model2 = JSON.parseObject("{\"id\":1001}", Model.class);
        System.out.println(model.getId());

//        System.out.println(model.getClass());

            

Reported by PMD.

The String literal '{\'id\':1001}' appears 4 times in this file; the first occurrence is on line 13
Error

Line: 13

               */
public class ProxyTest2 extends TestCase {
    public void test_0() throws Exception {
        Model model = JSON.parseObject("{\"id\":1001}", Model.class);
        Model model2 = JSON.parseObject("{\"id\":1001}", Model.class);
        System.out.println(model.getId());

//        System.out.println(model.getClass());
//        System.out.println(model2.getClass());

            

Reported by PMD.

Avoid unused local variables such as 'model2'.
Design

Line: 14

              public class ProxyTest2 extends TestCase {
    public void test_0() throws Exception {
        Model model = JSON.parseObject("{\"id\":1001}", Model.class);
        Model model2 = JSON.parseObject("{\"id\":1001}", Model.class);
        System.out.println(model.getId());

//        System.out.println(model.getClass());
//        System.out.println(model2.getClass());


            

Reported by PMD.

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

Line: 15

                  public void test_0() throws Exception {
        Model model = JSON.parseObject("{\"id\":1001}", Model.class);
        Model model2 = JSON.parseObject("{\"id\":1001}", Model.class);
        System.out.println(model.getId());

//        System.out.println(model.getClass());
//        System.out.println(model2.getClass());

        assertEquals("{\"id\":1001}", JSON.toJSONString(model));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

              //        System.out.println(model.getClass());
//        System.out.println(model2.getClass());

        assertEquals("{\"id\":1001}", JSON.toJSONString(model));
        assertEquals("{\"id\":1001}", JSON.toJSONString(model));

    }

    public static interface Model {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 21

              //        System.out.println(model2.getClass());

        assertEquals("{\"id\":1001}", JSON.toJSONString(model));
        assertEquals("{\"id\":1001}", JSON.toJSONString(model));

    }

    public static interface Model {
        int getId();

            

Reported by PMD.

Avoid unused imports such as 'java.lang.reflect.Proxy'
Design

Line: 6

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

import java.lang.reflect.Proxy;

/**
 * Created by wenshao on 07/08/2017.
 */
public class ProxyTest2 extends TestCase {

            

Reported by PMD.

Found 'DU'-anomaly for variable 'model2' (lines '14'-'23').
Error

Line: 14

              public class ProxyTest2 extends TestCase {
    public void test_0() throws Exception {
        Model model = JSON.parseObject("{\"id\":1001}", Model.class);
        Model model2 = JSON.parseObject("{\"id\":1001}", Model.class);
        System.out.println(model.getId());

//        System.out.println(model.getClass());
//        System.out.println(model2.getClass());


            

Reported by PMD.