The following issues were found

src/test/java/com/alibaba/json/bvtVO/IncomingDataPoint.java
10 issues
The class 'IncomingDataPoint' is suspected to be a Data Class (WOC=5.556%, NOPA=0, NOAM=14, WMC=20)
Design

Line: 19

                      orders = {"metric", "timestamp", "value", "tags", "tsuid", "granularity", "aggregator"},
        asm = true
        )
public class IncomingDataPoint {
    /** The incoming metric name */
    private String metric;

    /** The incoming timestamp in Unix epoch seconds or milliseconds */
    private long timestamp;

            

Reported by PMD.

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

Line: 33

                  private Map<String, String> tags;

    /** TSUID for the data point */
    private String tsuid;

    private String granularity;

    private String aggregator;


            

Reported by PMD.

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

Line: 56

                  public IncomingDataPoint(final String metric,
                             final long timestamp,
                             final String value,
                             final HashMap<String, String> tags,
                             final String granularity,
                             final String aggregator) {
        this.metric = metric;
        this.granularity = granularity;
        this.timestamp = timestamp;

            

Reported by PMD.

StringBuffer constructor is initialized with size 16, but has at least 44 characters appended.
Performance

Line: 88

                   */
    @Override
    public String toString() {
        final StringBuilder buf = new StringBuilder();
        buf.append(" metric=").append(this.metric);
        buf.append(" granularity=").append(this.granularity);
        buf.append(" aggregator=").append(this.aggregator);
        buf.append(" ts=").append(this.timestamp);
        buf.append(" value=").append(this.value);

            

Reported by PMD.

StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
Performance

Line: 89

                  @Override
    public String toString() {
        final StringBuilder buf = new StringBuilder();
        buf.append(" metric=").append(this.metric);
        buf.append(" granularity=").append(this.granularity);
        buf.append(" aggregator=").append(this.aggregator);
        buf.append(" ts=").append(this.timestamp);
        buf.append(" value=").append(this.value);
        if (this.tags != null) {

            

Reported by PMD.

StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
Performance

Line: 90

                  public String toString() {
        final StringBuilder buf = new StringBuilder();
        buf.append(" metric=").append(this.metric);
        buf.append(" granularity=").append(this.granularity);
        buf.append(" aggregator=").append(this.aggregator);
        buf.append(" ts=").append(this.timestamp);
        buf.append(" value=").append(this.value);
        if (this.tags != null) {
            for (Map.Entry<String, String> entry : this.tags.entrySet()) {

            

Reported by PMD.

StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
Performance

Line: 91

                      final StringBuilder buf = new StringBuilder();
        buf.append(" metric=").append(this.metric);
        buf.append(" granularity=").append(this.granularity);
        buf.append(" aggregator=").append(this.aggregator);
        buf.append(" ts=").append(this.timestamp);
        buf.append(" value=").append(this.value);
        if (this.tags != null) {
            for (Map.Entry<String, String> entry : this.tags.entrySet()) {
                buf.append(" ").append(entry.getKey()).append("=").append(entry.getValue());

            

Reported by PMD.

StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
Performance

Line: 92

                      buf.append(" metric=").append(this.metric);
        buf.append(" granularity=").append(this.granularity);
        buf.append(" aggregator=").append(this.aggregator);
        buf.append(" ts=").append(this.timestamp);
        buf.append(" value=").append(this.value);
        if (this.tags != null) {
            for (Map.Entry<String, String> entry : this.tags.entrySet()) {
                buf.append(" ").append(entry.getKey()).append("=").append(entry.getValue());
            }

            

Reported by PMD.

Avoid appending characters as strings in StringBuffer.append.
Performance

Line: 96

                      buf.append(" value=").append(this.value);
        if (this.tags != null) {
            for (Map.Entry<String, String> entry : this.tags.entrySet()) {
                buf.append(" ").append(entry.getKey()).append("=").append(entry.getValue());
            }
        }
        return buf.toString();
    }


            

Reported by PMD.

Avoid appending characters as strings in StringBuffer.append.
Performance

Line: 96

                      buf.append(" value=").append(this.value);
        if (this.tags != null) {
            for (Map.Entry<String, String> entry : this.tags.entrySet()) {
                buf.append(" ").append(entry.getKey()).append("=").append(entry.getValue());
            }
        }
        return buf.toString();
    }


            

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_2300/Issue2343.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: 9

              import junit.framework.TestCase;

public class Issue2343 extends TestCase {
    public void test_for_issue() throws Exception {
        A a = new A();
        a.f1 = 101;
        a.f2 = 102;
        a.f3 = 103;


            

Reported by PMD.

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

Line: 9

              import junit.framework.TestCase;

public class Issue2343 extends TestCase {
    public void test_for_issue() throws Exception {
        A a = new A();
        a.f1 = 101;
        a.f2 = 102;
        a.f3 = 103;


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                      a.f3 = 103;

        String str = JSON.toJSONString(a);
        assertEquals("{\"f2\":102,\"f1\":101,\"f3\":103}", str);

        JSONObject object = JSON.parseObject(str);
        A a1 = object.toJavaObject(A.class);
        assertEquals(a.f1, a1.f1);
        assertEquals(a.f2, a1.f2);

            

Reported by PMD.

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

Line: 19

                      assertEquals("{\"f2\":102,\"f1\":101,\"f3\":103}", str);

        JSONObject object = JSON.parseObject(str);
        A a1 = object.toJavaObject(A.class);
        assertEquals(a.f1, a1.f1);
        assertEquals(a.f2, a1.f2);
        assertEquals(a.f3, a1.f3);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

              
        JSONObject object = JSON.parseObject(str);
        A a1 = object.toJavaObject(A.class);
        assertEquals(a.f1, a1.f1);
        assertEquals(a.f2, a1.f2);
        assertEquals(a.f3, a1.f3);
    }

    public static class A {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 21

                      JSONObject object = JSON.parseObject(str);
        A a1 = object.toJavaObject(A.class);
        assertEquals(a.f1, a1.f1);
        assertEquals(a.f2, a1.f2);
        assertEquals(a.f3, a1.f3);
    }

    public static class A {
        @JSONField(ordinal = 1)

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

                      A a1 = object.toJavaObject(A.class);
        assertEquals(a.f1, a1.f1);
        assertEquals(a.f2, a1.f2);
        assertEquals(a.f3, a1.f3);
    }

    public static class A {
        @JSONField(ordinal = 1)
        public int f1;

            

Reported by PMD.

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

Line: 27

              
    public static class A {
        @JSONField(ordinal = 1)
        public int f1;

        @JSONField(ordinal = 0)
        public int f2;

        @JSONField(ordinal = 2)

            

Reported by PMD.

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

Line: 30

                      public int f1;

        @JSONField(ordinal = 0)
        public int f2;

        @JSONField(ordinal = 2)
        public int f3;
    }
}

            

Reported by PMD.

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

Line: 33

                      public int f2;

        @JSONField(ordinal = 2)
        public int f3;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvtVO/IncomingDataPoint_double.java
10 issues
The class 'IncomingDataPoint_double' is suspected to be a Data Class (WOC=5.556%, NOPA=0, NOAM=14, WMC=20)
Design

Line: 19

                      orders = {"metric", "timestamp", "value", "tags", "tsuid", "granularity", "aggregator"},
        asm = true
        )
public class IncomingDataPoint_double {
    /** The incoming metric name */
    private String metric;

    /** The incoming timestamp in Unix epoch seconds or milliseconds */
    private long timestamp;

            

Reported by PMD.

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

Line: 33

                  private Map<String, String> tags;

    /** TSUID for the data point */
    private String tsuid;

    private String granularity;

    private String aggregator;


            

Reported by PMD.

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

Line: 56

                  public IncomingDataPoint_double(final String metric,
                                    final long timestamp,
                                    final double value,
                                    final HashMap<String, String> tags,
                                    final String granularity,
                                    final String aggregator) {
        this.metric = metric;
        this.granularity = granularity;
        this.timestamp = timestamp;

            

Reported by PMD.

StringBuffer constructor is initialized with size 16, but has at least 44 characters appended.
Performance

Line: 88

                   */
    @Override
    public String toString() {
        final StringBuilder buf = new StringBuilder();
        buf.append(" metric=").append(this.metric);
        buf.append(" granularity=").append(this.granularity);
        buf.append(" aggregator=").append(this.aggregator);
        buf.append(" ts=").append(this.timestamp);
        buf.append(" value=").append(this.value);

            

Reported by PMD.

StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
Performance

Line: 89

                  @Override
    public String toString() {
        final StringBuilder buf = new StringBuilder();
        buf.append(" metric=").append(this.metric);
        buf.append(" granularity=").append(this.granularity);
        buf.append(" aggregator=").append(this.aggregator);
        buf.append(" ts=").append(this.timestamp);
        buf.append(" value=").append(this.value);
        if (this.tags != null) {

            

Reported by PMD.

StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
Performance

Line: 90

                  public String toString() {
        final StringBuilder buf = new StringBuilder();
        buf.append(" metric=").append(this.metric);
        buf.append(" granularity=").append(this.granularity);
        buf.append(" aggregator=").append(this.aggregator);
        buf.append(" ts=").append(this.timestamp);
        buf.append(" value=").append(this.value);
        if (this.tags != null) {
            for (Map.Entry<String, String> entry : this.tags.entrySet()) {

            

Reported by PMD.

StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
Performance

Line: 91

                      final StringBuilder buf = new StringBuilder();
        buf.append(" metric=").append(this.metric);
        buf.append(" granularity=").append(this.granularity);
        buf.append(" aggregator=").append(this.aggregator);
        buf.append(" ts=").append(this.timestamp);
        buf.append(" value=").append(this.value);
        if (this.tags != null) {
            for (Map.Entry<String, String> entry : this.tags.entrySet()) {
                buf.append(" ").append(entry.getKey()).append("=").append(entry.getValue());

            

Reported by PMD.

StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
Performance

Line: 92

                      buf.append(" metric=").append(this.metric);
        buf.append(" granularity=").append(this.granularity);
        buf.append(" aggregator=").append(this.aggregator);
        buf.append(" ts=").append(this.timestamp);
        buf.append(" value=").append(this.value);
        if (this.tags != null) {
            for (Map.Entry<String, String> entry : this.tags.entrySet()) {
                buf.append(" ").append(entry.getKey()).append("=").append(entry.getValue());
            }

            

Reported by PMD.

Avoid appending characters as strings in StringBuffer.append.
Performance

Line: 96

                      buf.append(" value=").append(this.value);
        if (this.tags != null) {
            for (Map.Entry<String, String> entry : this.tags.entrySet()) {
                buf.append(" ").append(entry.getKey()).append("=").append(entry.getValue());
            }
        }
        return buf.toString();
    }


            

Reported by PMD.

Avoid appending characters as strings in StringBuffer.append.
Performance

Line: 96

                      buf.append(" value=").append(this.value);
        if (this.tags != null) {
            for (Map.Entry<String, String> entry : this.tags.entrySet()) {
                buf.append(" ").append(entry.getKey()).append("=").append(entry.getValue());
            }
        }
        return buf.toString();
    }


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/basicType/BigDecimal_type.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 static com.alibaba.fastjson.serializer.SerializerFeature.BrowserCompatible;

public class BigDecimal_type extends TestCase {
    public void test_for_issue() throws Exception {
        assertEquals("{\"value\":\"9007199254741992\"}"
                , JSON.toJSONString(
                        new Model(9007199254741992L)));

        assertEquals("{\"value\":\"-9007199254741992\"}"

            

Reported by PMD.

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

Line: 13

              import static com.alibaba.fastjson.serializer.SerializerFeature.BrowserCompatible;

public class BigDecimal_type extends TestCase {
    public void test_for_issue() throws Exception {
        assertEquals("{\"value\":\"9007199254741992\"}"
                , JSON.toJSONString(
                        new Model(9007199254741992L)));

        assertEquals("{\"value\":\"-9007199254741992\"}"

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

              
public class BigDecimal_type extends TestCase {
    public void test_for_issue() throws Exception {
        assertEquals("{\"value\":\"9007199254741992\"}"
                , JSON.toJSONString(
                        new Model(9007199254741992L)));

        assertEquals("{\"value\":\"-9007199254741992\"}"
                , JSON.toJSONString(

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                              , JSON.toJSONString(
                        new Model(9007199254741992L)));

        assertEquals("{\"value\":\"-9007199254741992\"}"
                , JSON.toJSONString(
                        new Model(-9007199254741992L)));

        assertEquals("{\"value\":9007199254740990}"
                , JSON.toJSONString(

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

                              , JSON.toJSONString(
                        new Model(-9007199254741992L)));

        assertEquals("{\"value\":9007199254740990}"
                , JSON.toJSONString(
                        new Model(9007199254740990L)));

        assertEquals("{\"value\":-9007199254740990}"
                , JSON.toJSONString(

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 26

                              , JSON.toJSONString(
                        new Model(9007199254740990L)));

        assertEquals("{\"value\":-9007199254740990}"
                , JSON.toJSONString(
                        new Model(-9007199254740990L)));

        assertEquals("{\"value\":100}"
                , JSON.toJSONString(

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

                              , JSON.toJSONString(
                        new Model(-9007199254740990L)));

        assertEquals("{\"value\":100}"
                , JSON.toJSONString(
                        new Model(100)));

        assertEquals("{\"value\":-100}"
                , JSON.toJSONString(

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 34

                              , JSON.toJSONString(
                        new Model(100)));

        assertEquals("{\"value\":-100}"
                , JSON.toJSONString(
                        new Model(-100)));
    }



            

Reported by PMD.

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

Line: 43

              
    @JSONType(serialzeFeatures = BrowserCompatible)
    public static class Model {
        public BigDecimal value;

        public Model() {

        }


            

Reported by PMD.

Avoid unused imports such as 'java.math.BigInteger'
Design

Line: 8

              import junit.framework.TestCase;

import java.math.BigDecimal;
import java.math.BigInteger;

import static com.alibaba.fastjson.serializer.SerializerFeature.BrowserCompatible;

public class BigDecimal_type extends TestCase {
    public void test_for_issue() throws Exception {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/basicType/BigDecimal_field.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 static com.alibaba.fastjson.serializer.SerializerFeature.BrowserCompatible;

public class BigDecimal_field extends TestCase {
    public void test_for_issue() throws Exception {
        assertEquals("{\"value\":\"9007199254741992\"}"
                , JSON.toJSONString(
                        new Model(9007199254741992L)));

        assertEquals("{\"value\":\"-9007199254741992\"}"

            

Reported by PMD.

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

Line: 13

              import static com.alibaba.fastjson.serializer.SerializerFeature.BrowserCompatible;

public class BigDecimal_field extends TestCase {
    public void test_for_issue() throws Exception {
        assertEquals("{\"value\":\"9007199254741992\"}"
                , JSON.toJSONString(
                        new Model(9007199254741992L)));

        assertEquals("{\"value\":\"-9007199254741992\"}"

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

              
public class BigDecimal_field extends TestCase {
    public void test_for_issue() throws Exception {
        assertEquals("{\"value\":\"9007199254741992\"}"
                , JSON.toJSONString(
                        new Model(9007199254741992L)));

        assertEquals("{\"value\":\"-9007199254741992\"}"
                , JSON.toJSONString(

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                              , JSON.toJSONString(
                        new Model(9007199254741992L)));

        assertEquals("{\"value\":\"-9007199254741992\"}"
                , JSON.toJSONString(
                        new Model(-9007199254741992L)));

        assertEquals("{\"value\":9007199254740990}"
                , JSON.toJSONString(

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

                              , JSON.toJSONString(
                        new Model(-9007199254741992L)));

        assertEquals("{\"value\":9007199254740990}"
                , JSON.toJSONString(
                        new Model(9007199254740990L)));

        assertEquals("{\"value\":-9007199254740990}"
                , JSON.toJSONString(

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 26

                              , JSON.toJSONString(
                        new Model(9007199254740990L)));

        assertEquals("{\"value\":-9007199254740990}"
                , JSON.toJSONString(
                        new Model(-9007199254740990L)));

        assertEquals("{\"value\":100}"
                , JSON.toJSONString(

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

                              , JSON.toJSONString(
                        new Model(-9007199254740990L)));

        assertEquals("{\"value\":100}"
                , JSON.toJSONString(
                        new Model(100)));

        assertEquals("{\"value\":-100}"
                , JSON.toJSONString(

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 34

                              , JSON.toJSONString(
                        new Model(100)));

        assertEquals("{\"value\":-100}"
                , JSON.toJSONString(
                        new Model(-100)));
    }



            

Reported by PMD.

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

Line: 44

              
    public static class Model {
        @JSONField(serialzeFeatures = BrowserCompatible)
        public BigDecimal value;

        public Model() {

        }


            

Reported by PMD.

Avoid unused imports such as 'java.math.BigInteger'
Design

Line: 8

              import junit.framework.TestCase;

import java.math.BigDecimal;
import java.math.BigInteger;

import static com.alibaba.fastjson.serializer.SerializerFeature.BrowserCompatible;

public class BigDecimal_field extends TestCase {
    public void test_for_issue() throws Exception {

            

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/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.

src/test/java/com/alibaba/json/bvt/asm/Huge_300_ClassTest.java
10 issues
This class has a bunch of public methods and attributes
Design

Line: 1

              package com.alibaba.json.bvt.asm;

import com.alibaba.fastjson.JSON;

import junit.framework.TestCase;

public class Huge_300_ClassTest extends TestCase {

    public void test_huge() {

            

Reported by PMD.

The type has an NCSS line count of 1504
Design

Line: 7

              
import junit.framework.TestCase;

public class Huge_300_ClassTest extends TestCase {

    public void test_huge() {
        JSON.parseObject("{}", VO.class);
    }


            

Reported by PMD.

Avoid really long classes.
Design

Line: 7

              
import junit.framework.TestCase;

public class Huge_300_ClassTest extends TestCase {

    public void test_huge() {
        JSON.parseObject("{}", VO.class);
    }


            

Reported by PMD.

The class 'Huge_300_ClassTest' has a NCSS line count of 1504 (Highest = 2).
Design

Line: 7

              
import junit.framework.TestCase;

public class Huge_300_ClassTest extends TestCase {

    public void test_huge() {
        JSON.parseObject("{}", 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: 9

              
public class Huge_300_ClassTest extends TestCase {

    public void test_huge() {
        JSON.parseObject("{}", VO.class);
    }

    public static class VO {


            

Reported by PMD.

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

Line: 9

              
public class Huge_300_ClassTest extends TestCase {

    public void test_huge() {
        JSON.parseObject("{}", VO.class);
    }

    public static class VO {


            

Reported by PMD.

Avoid really long classes.
Design

Line: 13

                      JSON.parseObject("{}", VO.class);
    }

    public static class VO {

        private Integer f000;
        private Integer f001;
        private Integer f002;
        private Integer f003;

            

Reported by PMD.

The class 'VO' has a NCSS line count of 1501 (Highest = 2).
Design

Line: 13

                      JSON.parseObject("{}", VO.class);
    }

    public static class VO {

        private Integer f000;
        private Integer f001;
        private Integer f002;
        private Integer f003;

            

Reported by PMD.

The class 'VO' has a total cyclomatic complexity of 600 (highest 1).
Design

Line: 13

                      JSON.parseObject("{}", VO.class);
    }

    public static class VO {

        private Integer f000;
        private Integer f001;
        private Integer f002;
        private Integer f003;

            

Reported by PMD.

Too many fields
Design

Line: 13

                      JSON.parseObject("{}", VO.class);
    }

    public static class VO {

        private Integer f000;
        private Integer f001;
        private Integer f002;
        private Integer f003;

            

Reported by PMD.

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

Line: 13

               * Created by wenshao on 11/02/2017.
 */
public class Issue1017 extends TestCase {
    public void test_for_issue() throws Exception {
        String json = "{\"pictureList\":[\"http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000\",\"http://common.cnblogs.com/images/icon_weibo_24.png\"]}";

        User user = JSON.parseObject(json, User.class);
        assertNotNull(user.pictureList);
        assertEquals(2, user.pictureList.size());

            

Reported by PMD.

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

Line: 13

               * Created by wenshao on 11/02/2017.
 */
public class Issue1017 extends TestCase {
    public void test_for_issue() throws Exception {
        String json = "{\"pictureList\":[\"http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000\",\"http://common.cnblogs.com/images/icon_weibo_24.png\"]}";

        User user = JSON.parseObject(json, User.class);
        assertNotNull(user.pictureList);
        assertEquals(2, user.pictureList.size());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                      String json = "{\"pictureList\":[\"http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000\",\"http://common.cnblogs.com/images/icon_weibo_24.png\"]}";

        User user = JSON.parseObject(json, User.class);
        assertNotNull(user.pictureList);
        assertEquals(2, user.pictureList.size());
        assertEquals("http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000", user.pictureList.get(0));
        assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

              
        User user = JSON.parseObject(json, User.class);
        assertNotNull(user.pictureList);
        assertEquals(2, user.pictureList.size());
        assertEquals("http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000", user.pictureList.get(0));
        assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
    }

    public static class User implements Serializable {

            

Reported by PMD.

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

Line: 18

              
        User user = JSON.parseObject(json, User.class);
        assertNotNull(user.pictureList);
        assertEquals(2, user.pictureList.size());
        assertEquals("http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000", user.pictureList.get(0));
        assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
    }

    public static class User implements Serializable {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                      User user = JSON.parseObject(json, User.class);
        assertNotNull(user.pictureList);
        assertEquals(2, user.pictureList.size());
        assertEquals("http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000", user.pictureList.get(0));
        assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
    }

    public static class User implements Serializable {
        private List<String> pictureList;

            

Reported by PMD.

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

Line: 19

                      User user = JSON.parseObject(json, User.class);
        assertNotNull(user.pictureList);
        assertEquals(2, user.pictureList.size());
        assertEquals("http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000", user.pictureList.get(0));
        assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
    }

    public static class User implements Serializable {
        private List<String> pictureList;

            

Reported by PMD.

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

Line: 20

                      assertNotNull(user.pictureList);
        assertEquals(2, user.pictureList.size());
        assertEquals("http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000", user.pictureList.get(0));
        assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
    }

    public static class User implements Serializable {
        private List<String> pictureList;
        public List<String> getPictureList() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

                      assertNotNull(user.pictureList);
        assertEquals(2, user.pictureList.size());
        assertEquals("http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000", user.pictureList.get(0));
        assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
    }

    public static class User implements Serializable {
        private List<String> pictureList;
        public List<String> getPictureList() {

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 23

                      assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
    }

    public static class User implements Serializable {
        private List<String> pictureList;
        public List<String> getPictureList() {
            return pictureList;
        }
        public User setPictureList(List<String> pictureList) {

            

Reported by PMD.