The following issues were found

src/test/java/com/alibaba/json/test/benchmark/basic/BigDecimalBenchmark.java
5 issues
System.out.println is used
Design

Line: 39

                          JSON.parseObject(json, Model.class);
        }
        long millis = System.currentTimeMillis() - start;
        System.out.println("millis : " + millis);
    }

    public static void perf2() {
        long start = System.currentTimeMillis();
        for (int i = 0; i < 1000 * 1000 * 10; ++i) {

            

Reported by PMD.

System.out.println is used
Design

Line: 48

                          JSON.parseObject(json2, Model.class);
        }
        long millis = System.currentTimeMillis() - start;
        System.out.println("millis : " + millis);
    }

    public static void perf3() {
        long start = System.currentTimeMillis();
        for (int i = 0; i < 1000 * 1000 * 10; ++i) {

            

Reported by PMD.

System.out.println is used
Design

Line: 57

                          JSON.parseObject(json3, Model.class, Feature.SupportArrayToBean);
        }
        long millis = System.currentTimeMillis() - start;
        System.out.println("millis : " + millis);
    }

    public static class Model {
        public BigDecimal v1;
        public BigDecimal v2;

            

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

              /**
 * Created by wenshao on 04/08/2017.
 */
public class BigDecimalBenchmark {
    static String json = "{\"v1\":0.4430165316544028,\"v2\":0.22676692048907365,\"v3\":0.9766986818812096,\"v4\":0.3423751102308744,\"v5\":0.4262177938610565}";
    static String json2 = "{\"v1\":\"0.4430165316544028\",\"v2\":\"0.22676692048907365\",\"v3\":\"0.9766986818812096\",\"v4\":\"0.3423751102308744\",\"v5\":\"0.4262177938610565\"}";
    static String json3 = "[0.4430165316544028,0.22676692048907365,0.9766986818812096,0.3423751102308744,0.4262177938610565]";

    public static void main(String[] args) throws Exception {

            

Reported by PMD.

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

Line: 16

                  static String json2 = "{\"v1\":\"0.4430165316544028\",\"v2\":\"0.22676692048907365\",\"v3\":\"0.9766986818812096\",\"v4\":\"0.3423751102308744\",\"v5\":\"0.4262177938610565\"}";
    static String json3 = "[0.4430165316544028,0.22676692048907365,0.9766986818812096,0.3423751102308744,0.4262177938610565]";

    public static void main(String[] args) throws Exception {
//        Model model = new Model();
//        model.v1 = new Random().nextDouble();
//        model.v2 = new Random().nextDouble();
//        model.v3 = new Random().nextDouble();
//        model.v4 = new Random().nextDouble();

            

Reported by PMD.

src/test/java/com/alibaba/json/bvtVO/alipay/PlatformDepartmentVO.java
5 issues
Too many fields
Design

Line: 8

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

public class PlatformDepartmentVO {
    @JSONField(ordinal=1)
    private String id ;
    @JSONField(ordinal=2)
    private String label ;
    @JSONField(ordinal=3)

            

Reported by PMD.

The class 'PlatformDepartmentVO' is suspected to be a Data Class (WOC=2.941%, NOPA=0, NOAM=32, WMC=39)
Design

Line: 8

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

public class PlatformDepartmentVO {
    @JSONField(ordinal=1)
    private String id ;
    @JSONField(ordinal=2)
    private String label ;
    @JSONField(ordinal=3)

            

Reported by PMD.

Ensure you override both equals() and hashCode()
Error

Line: 237

              //    }


    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;

            

Reported by PMD.

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

Line: 251

                          return false;
        }
        final PlatformDepartmentVO other = (PlatformDepartmentVO) obj;
        if(!this.getId().equals(other.getId())) {
            return false;
        }
        return true;
    }


            

Reported by PMD.

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

Line: 251

                          return false;
        }
        final PlatformDepartmentVO other = (PlatformDepartmentVO) obj;
        if(!this.getId().equals(other.getId())) {
            return false;
        }
        return true;
    }


            

Reported by PMD.

src/test/java/com/alibaba/json/test/benchmark/basic/DoubleBenchmark_obj.java
5 issues
System.out.println is used
Design

Line: 34

                          JSON.parseObject(json, Model.class);
        }
        long millis = System.currentTimeMillis() - start;
        System.out.println("millis : " + millis);
    }

    public static void perf2() {
        long start = System.currentTimeMillis();
        for (int i = 0; i < 1000 * 1000 * 10; ++i) {

            

Reported by PMD.

System.out.println is used
Design

Line: 43

                          JSON.parseObject(json2, Model.class);
        }
        long millis = System.currentTimeMillis() - start;
        System.out.println("millis : " + millis);
    }

    public static class Model {
        public Model() {


            

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

              /**
 * Created by wenshao on 04/08/2017.
 */
public class DoubleBenchmark_obj {
    static String json = "{\"v1\":0.4430165316544028,\"v2\":0.22676692048907365,\"v3\":0.9766986818812096,\"v4\":0.3423751102308744,\"v5\":0.4262177938610565}";
    static String json2 = "{\"v1\":\"0.4430165316544028\",\"v2\":\"0.22676692048907365\",\"v3\":\"0.9766986818812096\",\"v4\":\"0.3423751102308744\",\"v5\":\"0.4262177938610565\"}";

    public static void main(String[] args) throws Exception {
//        Model model = new Model();

            

Reported by PMD.

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

Line: 12

                  static String json = "{\"v1\":0.4430165316544028,\"v2\":0.22676692048907365,\"v3\":0.9766986818812096,\"v4\":0.3423751102308744,\"v5\":0.4262177938610565}";
    static String json2 = "{\"v1\":\"0.4430165316544028\",\"v2\":\"0.22676692048907365\",\"v3\":\"0.9766986818812096\",\"v4\":\"0.3423751102308744\",\"v5\":\"0.4262177938610565\"}";

    public static void main(String[] args) throws Exception {
//        Model model = new Model();
//        model.v1 = new Random().nextDouble();
//        model.v2 = new Random().nextDouble();
//        model.v3 = new Random().nextDouble();
//        model.v4 = new Random().nextDouble();

            

Reported by PMD.

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

Line: 46

                      System.out.println("millis : " + millis);
    }

    public static class Model {
        public Model() {

        }
        public Double v1;
        public Double v2;

            

Reported by PMD.

src/test/java/com/alibaba/json/test/entity/TestEntity.java
5 issues
Do not use the short type
Performance

Line: 17

                  private Boolean       f2;
    private byte          f3;
    private Byte          f4;
    private short         f5;
    private Short         f6;
    private int           f7;
    private Integer       f8;
    private long          f9;
    private Long          f10;

            

Reported by PMD.

Do not use the short type
Performance

Line: 110

                      this.f4 = f4;
    }

    public short getF5() {
        return f5;
    }

    public void setF5(short f5) {
        this.f5 = f5;

            

Reported by PMD.

Do not use the short type
Performance

Line: 114

                      return f5;
    }

    public void setF5(short f5) {
        this.f5 = f5;
    }

    public Short getF6() {
        return f6;

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 1

              package com.alibaba.json.test.entity;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.alibaba.fastjson.annotation.JSONField;

            

Reported by PMD.

Too many fields
Design

Line: 11

              
import com.alibaba.fastjson.annotation.JSONField;

public class TestEntity {

    private boolean       f1;
    private Boolean       f2;
    private byte          f3;
    private Byte          f4;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvtVO/VirtualTopic.java
5 issues
The class 'VirtualTopic' is suspected to be a Data Class (WOC=25.000%, NOPA=0, NOAM=8, WMC=21)
Design

Line: 6

              import java.util.HashMap;
import java.util.Map;

public class VirtualTopic {

    private static final long         serialVersionUID = 1115397330651723322L;

    private Map<Integer, QueueEntity> queueMap         = new HashMap<Integer, QueueEntity>();
    private Integer                   queueCount;

            

Reported by PMD.

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

Line: 67

                      }
        VirtualTopic vt = (VirtualTopic) other;
        int size = queueMap.size();
        if (size != vt.queueMap.size()) {
            return true;
        }
        for (Integer id : queueMap.keySet()) {
            if (!vt.queueMap.containsKey(id)) {
                return true;

            

Reported by PMD.

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

Line: 71

                          return true;
        }
        for (Integer id : queueMap.keySet()) {
            if (!vt.queueMap.containsKey(id)) {
                return true;
            }
        }
        return false;
    }

            

Reported by PMD.

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

Line: 84

                      }
        VirtualTopic vt = (VirtualTopic) other;
        int size = queueMap.size();
        if (size != vt.queueMap.size()) {
            return true;
        }
        for (Integer id : queueMap.keySet()) {
            if (!vt.queueMap.containsKey(id)) {
                return true;

            

Reported by PMD.

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

Line: 88

                          return true;
        }
        for (Integer id : queueMap.keySet()) {
            if (!vt.queueMap.containsKey(id)) {
                return true;
            }
        }
        return false;
    }

            

Reported by PMD.

src/test/java/data/media/writeAsArray/MediaContentDeserializer.java
5 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 18

              
public class MediaContentDeserializer implements ObjectDeserializer {

    MediaDeserializer mediaDeser = new MediaDeserializer();
    ImageDeserializer imageDesc  = new ImageDeserializer();

    @SuppressWarnings("unchecked")
    public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
        JSONLexer lexer = parser.getLexer();

            

Reported by PMD.

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

Line: 19

              public class MediaContentDeserializer implements ObjectDeserializer {

    MediaDeserializer mediaDeser = new MediaDeserializer();
    ImageDeserializer imageDesc  = new ImageDeserializer();

    @SuppressWarnings("unchecked")
    public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
        JSONLexer lexer = parser.getLexer();


            

Reported by PMD.

Found 'DU'-anomaly for variable 'lexer' (lines '23'-'50').
Error

Line: 23

              
    @SuppressWarnings("unchecked")
    public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
        JSONLexer lexer = parser.getLexer();

        parser.accept(JSONToken.LBRACKET, JSONToken.LBRACKET);
        Media media = mediaDeser.deserialze(parser, Media.class, "media");
        parser.accept(JSONToken.COMMA, JSONToken.LBRACKET);
        

            

Reported by PMD.

Found 'DU'-anomaly for variable 'index' (lines '31'-'50').
Error

Line: 31

                      
        parser.accept(JSONToken.LBRACKET, JSONToken.LBRACKET);
        List<Image> images = new ArrayList<Image>();
        int index = 0;
        for (;;) {
            Image image = imageDesc.deserialze(parser, Image.class, index);
            images.add(image);
            index++;
            if (lexer.token() == JSONToken.COMMA) {

            

Reported by PMD.

Found 'DU'-anomaly for variable 'index' (lines '35'-'50').
Error

Line: 35

                      for (;;) {
            Image image = imageDesc.deserialze(parser, Image.class, index);
            images.add(image);
            index++;
            if (lexer.token() == JSONToken.COMMA) {
                lexer.nextToken(JSONToken.LBRACKET);
            } else {
                break;
            }

            

Reported by PMD.

src/test/java/com/alibaba/json/test/benchmark/decode/EishayDecode.java
5 issues
Avoid throwing raw exception types.
Design

Line: 28

                  public void execute(Codec codec) throws Exception {
        MediaContent content = codec.decodeObject(text, MediaContent.class);
        if (content == null) {
            throw new Exception();
        }
    }

}

            

Reported by PMD.

System.out.println is used
Design

Line: 21

              
    public void init(Codec codec) throws Exception {
        this.text = codec.encode(EishayDecodeBytes.instance.getContent());
        System.out.println(text);
    }

    @Override
    public void execute(Codec codec) throws Exception {
        MediaContent content = codec.decodeObject(text, MediaContent.class);

            

Reported by PMD.

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

Line: 10

              
public class EishayDecode extends BenchmarkCase {

    private String text;

    public EishayDecode(){
        super("EishayDecode");

        // JavaBeanMapping.getGlobalInstance().putDeserializer(Image.class, new ImageDeserializer());

            

Reported by PMD.

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

Line: 19

                      // JavaBeanMapping.getGlobalInstance().putDeserializer(Media.class, new MediaDeserializer());
    }

    public void init(Codec codec) throws Exception {
        this.text = codec.encode(EishayDecodeBytes.instance.getContent());
        System.out.println(text);
    }

    @Override

            

Reported by PMD.

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

Line: 20

                  }

    public void init(Codec codec) throws Exception {
        this.text = codec.encode(EishayDecodeBytes.instance.getContent());
        System.out.println(text);
    }

    @Override
    public void execute(Codec codec) throws Exception {

            

Reported by PMD.

src/test/java/com/alibaba/json/test/benchmark/decode/EishayDecodeBytes.java
5 issues
Avoid throwing raw exception types.
Design

Line: 91

                          chars = (text + " ").toCharArray();
            bytes = text.getBytes("UTF-8");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException();
        }
    }

    @Override
    public void execute(Codec codec) throws Exception {

            

Reported by PMD.

The class 'EishayDecodeBytes' is suspected to be a Data Class (WOC=16.667%, NOPA=1, NOAM=4, WMC=8)
Design

Line: 19

              import data.media.Media.Player;
import data.media.MediaContent;

public class EishayDecodeBytes extends BenchmarkCase {

    public final static EishayDecodeBytes instance = new EishayDecodeBytes();

    private final byte[]                  bytes;
    private final char[]                  chars;

            

Reported by PMD.

Returning 'bytes' may expose an internal array.
Design

Line: 30

                  private final MediaContent                  content;

    public byte[] getBytes() {
        return bytes;
    }

    public char[] getChars() {
        return chars;
    }

            

Reported by PMD.

Returning 'chars' may expose an internal array.
Design

Line: 34

                  }

    public char[] getChars() {
        return chars;
    }

    public String getText() {
        return text;
    }

            

Reported by PMD.

New exception is thrown in catch block, original stack trace may be lost
Design

Line: 91

                          chars = (text + " ").toCharArray();
            bytes = text.getBytes("UTF-8");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException();
        }
    }

    @Override
    public void execute(Codec codec) throws Exception {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/writeAsArray/WriteAsArray_short_public.java
5 issues
Do not use the short type
Performance

Line: 21

                  }
    
    public static class VO {
        private short id;
        private String name;

        public short getId() {
            return id;
        }

            

Reported by PMD.

Do not use the short type
Performance

Line: 24

                      private short id;
        private String name;

        public short getId() {
            return id;
        }

        public void setId(short id) {
            this.id = id;

            

Reported by PMD.

Do not use the short type
Performance

Line: 28

                          return id;
        }

        public void setId(short id) {
            this.id = id;
        }

        public String getName() {
            return 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: 11

              import com.alibaba.fastjson.serializer.SerializerFeature;

public class WriteAsArray_short_public extends TestCase {
    public void test_0 () throws Exception {
        VO vo = new VO();
        vo.setId((short)123);
        vo.setName("wenshao");
        
        String text = JSON.toJSONString(vo, SerializerFeature.BeanToArray);

            

Reported by PMD.

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

Line: 20

                      Assert.assertEquals("[123,\"wenshao\"]", text);
    }
    
    public static class VO {
        private short id;
        private String name;

        public short getId() {
            return id;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvtVO/BigClass.java
5 issues
This class has a bunch of public methods and attributes
Design

Line: 1

              package com.alibaba.json.bvtVO;

public class BigClass {
    public  String  field1  ;
    public  String  field2  ;
    public  String  field3  ;
    public  String  field4  ;
    public  String  field5  ;
    public  String  field6  ;

            

Reported by PMD.

Avoid really long classes.
Design

Line: 3

              package com.alibaba.json.bvtVO;

public class BigClass {
    public  String  field1  ;
    public  String  field2  ;
    public  String  field3  ;
    public  String  field4  ;
    public  String  field5  ;
    public  String  field6  ;

            

Reported by PMD.

The type has an NCSS line count of 6665
Design

Line: 3

              package com.alibaba.json.bvtVO;

public class BigClass {
    public  String  field1  ;
    public  String  field2  ;
    public  String  field3  ;
    public  String  field4  ;
    public  String  field5  ;
    public  String  field6  ;

            

Reported by PMD.

Too many fields
Design

Line: 3

              package com.alibaba.json.bvtVO;

public class BigClass {
    public  String  field1  ;
    public  String  field2  ;
    public  String  field3  ;
    public  String  field4  ;
    public  String  field5  ;
    public  String  field6  ;

            

Reported by PMD.

The class 'BigClass' has a NCSS line count of 6665 (Highest = 0).
Design

Line: 3

              package com.alibaba.json.bvtVO;

public class BigClass {
    public  String  field1  ;
    public  String  field2  ;
    public  String  field3  ;
    public  String  field4  ;
    public  String  field5  ;
    public  String  field6  ;

            

Reported by PMD.