The following issues were found

src/test/java/com/alibaba/json/bvt/parser/array/BeanToArrayTest_enum_private.java
7 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

              
public class BeanToArrayTest_enum_private extends TestCase {

    public void test_enum() throws Exception {
        Model model = JSON.parseObject("[\"A\",\"B\"]", Model.class, Feature.SupportArrayToBean);
        Assert.assertEquals(Type.A, model.v1);
        Assert.assertEquals(Type.B, model.v2);
    }
    

            

Reported by PMD.

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

Line: 19

                      Assert.assertEquals(Type.B, model.v2);
    }
    
    public void test_enum_space() throws Exception {
        Model model = JSON.parseObject("[\"A\" ,\"B\" ]", Model.class, Feature.SupportArrayToBean);
        Assert.assertEquals(Type.A, model.v1);
        Assert.assertEquals(Type.B, model.v2);
    }


            

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

                      Assert.assertEquals(Type.B, model.v2);
    }

    public void test_enum_num() throws Exception {
        Model model = JSON.parseObject("[1,0]", Model.class, Feature.SupportArrayToBean);
        Assert.assertEquals(Type.B, model.v1);
        Assert.assertEquals(Type.A, model.v2);
    }


            

Reported by PMD.

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

Line: 31

                      Assert.assertEquals(Type.A, model.v2);
    }

    public void test_enum_error() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[t,0]", Model.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

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

Line: 43

              
    private static class Model {

        public Type v1;
        public Type v2;
    }
    
    private static enum Type {
        A, B, C

            

Reported by PMD.

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

Line: 44

                  private static class Model {

        public Type v1;
        public Type v2;
    }
    
    private static enum Type {
        A, B, C
    }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '32'-'36').
Error

Line: 32

                  }

    public void test_enum_error() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[t,0]", Model.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/bug/Bug_for_dingzhu.java
7 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: 12

              import java.util.Map;

public class Bug_for_dingzhu extends TestCase {
    public void test_0() throws Exception {
        HashMap<String, Object> params = new HashMap<String, Object>();
        params.put("notExitAfterVid", false);
        params.put("VIData", "{\"config\":{\"noTokens\":\"Y\",\"stopReport\":\"Y\"}");
        StupidObject so = new StupidObject();
        so.setParams(params);

            

Reported by PMD.

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

Line: 12

              import java.util.Map;

public class Bug_for_dingzhu extends TestCase {
    public void test_0() throws Exception {
        HashMap<String, Object> params = new HashMap<String, Object>();
        params.put("notExitAfterVid", false);
        params.put("VIData", "{\"config\":{\"noTokens\":\"Y\",\"stopReport\":\"Y\"}");
        StupidObject so = new StupidObject();
        so.setParams(params);

            

Reported by PMD.

Avoid unused local variables such as 'jsonString'.
Design

Line: 19

                      StupidObject so = new StupidObject();
        so.setParams(params);
        SerializeFilter[] filters = new SerializeFilter[] { new DumbValueFilter()};
        String jsonString = JSON.toJSONString(so, new SerializeConfig(), filters,
                SerializerFeature.NotWriteDefaultValue, SerializerFeature.IgnoreErrorGetter,
                SerializerFeature.QuoteFieldNames);
    }

    private class DumbValueFilter implements ContextValueFilter {

            

Reported by PMD.

Avoid unused local variables such as 'field'.
Design

Line: 30

                              return object;
            }

            Field field = context.getField();
            return value;
        }
    }

    private class StupidObject {

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.serializer'
Design

Line: 4

              package com.alibaba.json.bvt.parser.bug;

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

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'jsonString' (lines '19'-'22').
Error

Line: 19

                      StupidObject so = new StupidObject();
        so.setParams(params);
        SerializeFilter[] filters = new SerializeFilter[] { new DumbValueFilter()};
        String jsonString = JSON.toJSONString(so, new SerializeConfig(), filters,
                SerializerFeature.NotWriteDefaultValue, SerializerFeature.IgnoreErrorGetter,
                SerializerFeature.QuoteFieldNames);
    }

    private class DumbValueFilter implements ContextValueFilter {

            

Reported by PMD.

Found 'DU'-anomaly for variable 'field' (lines '30'-'32').
Error

Line: 30

                              return object;
            }

            Field field = context.getField();
            return value;
        }
    }

    private class StupidObject {

            

Reported by PMD.

src/test/java/com/alibaba/json/test/codec/JsonSmartCodec.java
7 issues
Return an empty array rather than null.
Error

Line: 44

                  }

    @Override
    public byte[] encodeToBytes(Object object) throws Exception {
        // TODO Auto-generated method stub
        return null;
    }

    @Override

            

Reported by PMD.

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

Line: 14

                      return "json-smart";
    }

    public <T> T decodeObject(String text, Class<T> clazz) throws Exception {
        throw new UnsupportedOperationException();
    }

    public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {
        throw new UnsupportedOperationException();

            

Reported by PMD.

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

Line: 18

                      throw new UnsupportedOperationException();
    }

    public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {
        throw new UnsupportedOperationException();
    }

    public Object decodeObject(String text) throws Exception {
        Object value =  JSONValue.parse(text);

            

Reported by PMD.

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

Line: 22

                      throw new UnsupportedOperationException();
    }

    public Object decodeObject(String text) throws Exception {
        Object value =  JSONValue.parse(text);
        
        return value;
    }


            

Reported by PMD.

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

Line: 28

                      return value;
    }

    public Object decode(String text) throws Exception {
        Object value = JSONValue.parse(text);
        
        return value;
    }


            

Reported by PMD.

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

Line: 34

                      return value;
    }

    public String encode(Object object) throws Exception {
        return JSONValue.toJSONString(object);
    }


    public <T> T decodeObject(byte[] input, Class<T> clazz) throws Exception {

            

Reported by PMD.

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

Line: 39

                  }


    public <T> T decodeObject(byte[] input, Class<T> clazz) throws Exception {
        throw new UnsupportedOperationException();
    }

    @Override
    public byte[] encodeToBytes(Object object) throws Exception {

            

Reported by PMD.

src/test/java/com/alibaba/json/test/benchmark/RyuDoubleBenchmark.java
7 issues
System.out.println is used
Design

Line: 11

                      double v = 0.5390050566444644; //new java.util.Random().nextDouble();


        System.out.println(v);

        for (int i = 0; i < 10; ++i) {
            f0(v); // 2505, 1865
        }


            

Reported by PMD.

System.out.println is used
Design

Line: 30

                          Double.toString(v);
        }
        long millis = System.currentTimeMillis() - start;
        System.out.println("jdk : " + millis);
    }

    public static void f1(double v) throws Exception {
        long start = System.currentTimeMillis();
        for (int i = 0; i < COUNT; ++i) {

            

Reported by PMD.

System.out.println is used
Design

Line: 39

                          RyuDouble.toString(v);
        }
        long millis = System.currentTimeMillis() - start;
        System.out.println("ryu : " + millis);
    }
}

            

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.util.RyuDouble;

public class RyuDoubleBenchmark {
    private final static int COUNT = 1000 * 1000 * 10;
    public static void main(String[] args) throws Exception {
        double v = 0.5390050566444644; //new java.util.Random().nextDouble();



            

Reported by PMD.

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

Line: 7

              
public class RyuDoubleBenchmark {
    private final static int COUNT = 1000 * 1000 * 10;
    public static void main(String[] args) throws Exception {
        double v = 0.5390050566444644; //new java.util.Random().nextDouble();


        System.out.println(v);


            

Reported by PMD.

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

Line: 24

              //        }
    }

    public static void f0(double v) throws Exception {
        long start = System.currentTimeMillis();
        for (int i = 0; i < COUNT; ++i) {
            Double.toString(v);
        }
        long millis = System.currentTimeMillis() - start;

            

Reported by PMD.

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

Line: 33

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

    public static void f1(double v) throws Exception {
        long start = System.currentTimeMillis();
        for (int i = 0; i < COUNT; ++i) {
            RyuDouble.toString(v);
        }
        long millis = System.currentTimeMillis() - start;

            

Reported by PMD.

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

Line: 44

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

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

            

Reported by PMD.

The class 'EishayDecode2Bytes' is suspected to be a Data Class (WOC=20.000%, NOPA=1, NOAM=3, WMC=7)
Design

Line: 12

              
import data.media.MediaContent;

public class EishayDecode2Bytes extends BenchmarkCase {

    public final static EishayDecode2Bytes instance = new EishayDecode2Bytes();

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

            

Reported by PMD.

Returning 'bytes' may expose an internal array.
Design

Line: 21

                  private final String text;

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

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

            

Reported by PMD.

Returning 'chars' may expose an internal array.
Design

Line: 25

                  }

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

            

Reported by PMD.

Ensure that resources like this InputStream object are closed after use
Error

Line: 37

              
        try {
            String resource = "data/media.2.json";
            InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
            text = IOUtils.toString(is);
            is.close();
            
            chars = (text + " ").toCharArray();
            bytes = text.getBytes("UTF-8");

            

Reported by PMD.

Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
Design

Line: 43

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

    @Override

            

Reported by PMD.

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

Line: 44

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

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

            

Reported by PMD.

src/test/java/com/alibaba/json/demo/hibernate/data/OrderDetailId.java
7 issues
The class 'OrderDetailId' is suspected to be a Data Class (WOC=25.000%, NOPA=0, NOAM=4, WMC=13)
Design

Line: 9

              
@SuppressWarnings("serial")
@Embeddable
public class OrderDetailId  implements java.io.Serializable {


     private Integer orderNumber;
     private String productCode;


            

Reported by PMD.

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

Line: 49

                      if ( !(other instanceof OrderDetailId) ) return false;
        OrderDetailId castOther = ( OrderDetailId ) other; 

        return ( (this.getOrderNumber()==castOther.getOrderNumber()) || ( this.getOrderNumber()!=null && castOther.getOrderNumber()!=null && this.getOrderNumber().equals(castOther.getOrderNumber()) ) )
                && ( (this.getProductCode()==castOther.getProductCode()) || ( this.getProductCode()!=null && castOther.getProductCode()!=null && this.getProductCode().equals(castOther.getProductCode()) ) );
    }
   
    @Override
    public int hashCode() {

            

Reported by PMD.

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

Line: 49

                      if ( !(other instanceof OrderDetailId) ) return false;
        OrderDetailId castOther = ( OrderDetailId ) other; 

        return ( (this.getOrderNumber()==castOther.getOrderNumber()) || ( this.getOrderNumber()!=null && castOther.getOrderNumber()!=null && this.getOrderNumber().equals(castOther.getOrderNumber()) ) )
                && ( (this.getProductCode()==castOther.getProductCode()) || ( this.getProductCode()!=null && castOther.getProductCode()!=null && this.getProductCode().equals(castOther.getProductCode()) ) );
    }
   
    @Override
    public int hashCode() {

            

Reported by PMD.

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

Line: 49

                      if ( !(other instanceof OrderDetailId) ) return false;
        OrderDetailId castOther = ( OrderDetailId ) other; 

        return ( (this.getOrderNumber()==castOther.getOrderNumber()) || ( this.getOrderNumber()!=null && castOther.getOrderNumber()!=null && this.getOrderNumber().equals(castOther.getOrderNumber()) ) )
                && ( (this.getProductCode()==castOther.getProductCode()) || ( this.getProductCode()!=null && castOther.getProductCode()!=null && this.getProductCode().equals(castOther.getProductCode()) ) );
    }
   
    @Override
    public int hashCode() {

            

Reported by PMD.

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

Line: 50

                      OrderDetailId castOther = ( OrderDetailId ) other; 

        return ( (this.getOrderNumber()==castOther.getOrderNumber()) || ( this.getOrderNumber()!=null && castOther.getOrderNumber()!=null && this.getOrderNumber().equals(castOther.getOrderNumber()) ) )
                && ( (this.getProductCode()==castOther.getProductCode()) || ( this.getProductCode()!=null && castOther.getProductCode()!=null && this.getProductCode().equals(castOther.getProductCode()) ) );
    }
   
    @Override
    public int hashCode() {
        int result = 17;

            

Reported by PMD.

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

Line: 50

                      OrderDetailId castOther = ( OrderDetailId ) other; 

        return ( (this.getOrderNumber()==castOther.getOrderNumber()) || ( this.getOrderNumber()!=null && castOther.getOrderNumber()!=null && this.getOrderNumber().equals(castOther.getOrderNumber()) ) )
                && ( (this.getProductCode()==castOther.getProductCode()) || ( this.getProductCode()!=null && castOther.getProductCode()!=null && this.getProductCode().equals(castOther.getProductCode()) ) );
    }
   
    @Override
    public int hashCode() {
        int result = 17;

            

Reported by PMD.

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

Line: 50

                      OrderDetailId castOther = ( OrderDetailId ) other; 

        return ( (this.getOrderNumber()==castOther.getOrderNumber()) || ( this.getOrderNumber()!=null && castOther.getOrderNumber()!=null && this.getOrderNumber().equals(castOther.getOrderNumber()) ) )
                && ( (this.getProductCode()==castOther.getProductCode()) || ( this.getProductCode()!=null && castOther.getProductCode()!=null && this.getProductCode().equals(castOther.getProductCode()) ) );
    }
   
    @Override
    public int hashCode() {
        int result = 17;

            

Reported by PMD.

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

Line: 22

                          "}";

    public static void main(String[] args) throws Exception {
        System.out.println(System.getProperty("java.vm.name") + " " + System.getProperty("java.runtime.version"));
//        Model model = new Model();
//        model.v1 = new Random().nextInt();
//        model.v2 = new Random().nextInt();
//        model.v3 = new Random().nextInt();
//        model.v4 = new Random().nextInt();

            

Reported by PMD.

System.out.println is used
Design

Line: 46

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

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

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

    public static class Model {
        public int v1;
        public int 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: 10

              /**
 * Created by wenshao on 04/08/2017.
 */
public class IntBenchmark {
    static String json = "{\"v1\":-1224609302,\"v2\":379420556,\"v3\":-1098099527,\"v4\":-2018662,\"v5\":422842162}";
    static String json2 = "{\"v1\":\"-1224609302\",\"v2\":\"379420556\",\"v3\":\"-1098099527\",\"v4\":\"-2018662\",\"v5\":\"422842162\"}";
    static String json3 = "{\n" +
            "\t\"v1\":\"-1224609302\",\n" +
            "\t\"v2\":\"379420556\",\n" +

            

Reported by PMD.

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

Line: 21

                          "\t\"v5\":\"422842162\"\n" +
            "}";

    public static void main(String[] args) throws Exception {
        System.out.println(System.getProperty("java.vm.name") + " " + System.getProperty("java.runtime.version"));
//        Model model = new Model();
//        model.v1 = new Random().nextInt();
//        model.v2 = new Random().nextInt();
//        model.v3 = new Random().nextInt();

            

Reported by PMD.

Avoid unused imports such as 'java.util.Random'
Design

Line: 5

              
import com.alibaba.fastjson.JSON;

import java.util.Random;

/**
 * Created by wenshao on 04/08/2017.
 */
public class IntBenchmark {

            

Reported by PMD.

src/test/java/com/alibaba/json/demo/hibernate/data/PaymentId.java
7 issues
The class 'PaymentId' is suspected to be a Data Class (WOC=25.000%, NOPA=0, NOAM=4, WMC=13)
Design

Line: 9

              
@SuppressWarnings("serial")
@Embeddable
public class PaymentId  implements java.io.Serializable
{
    private Integer customerNumber;
    private String checkNumber;

    public PaymentId() { }

            

Reported by PMD.

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

Line: 47

              		 if ( !(other instanceof PaymentId) ) return false;
		 PaymentId castOther = ( PaymentId ) other; 
         
		 return ( (this.getCustomerNumber()==castOther.getCustomerNumber()) || ( this.getCustomerNumber()!=null && castOther.getCustomerNumber()!=null && this.getCustomerNumber().equals(castOther.getCustomerNumber()) ) )
		         && ( (this.getCheckNumber()==castOther.getCheckNumber()) || ( this.getCheckNumber()!=null && castOther.getCheckNumber()!=null && this.getCheckNumber().equals(castOther.getCheckNumber()) ) );
    }

    @Override
    public int hashCode() {

            

Reported by PMD.

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

Line: 47

              		 if ( !(other instanceof PaymentId) ) return false;
		 PaymentId castOther = ( PaymentId ) other; 
         
		 return ( (this.getCustomerNumber()==castOther.getCustomerNumber()) || ( this.getCustomerNumber()!=null && castOther.getCustomerNumber()!=null && this.getCustomerNumber().equals(castOther.getCustomerNumber()) ) )
		         && ( (this.getCheckNumber()==castOther.getCheckNumber()) || ( this.getCheckNumber()!=null && castOther.getCheckNumber()!=null && this.getCheckNumber().equals(castOther.getCheckNumber()) ) );
    }

    @Override
    public int hashCode() {

            

Reported by PMD.

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

Line: 47

              		 if ( !(other instanceof PaymentId) ) return false;
		 PaymentId castOther = ( PaymentId ) other; 
         
		 return ( (this.getCustomerNumber()==castOther.getCustomerNumber()) || ( this.getCustomerNumber()!=null && castOther.getCustomerNumber()!=null && this.getCustomerNumber().equals(castOther.getCustomerNumber()) ) )
		         && ( (this.getCheckNumber()==castOther.getCheckNumber()) || ( this.getCheckNumber()!=null && castOther.getCheckNumber()!=null && this.getCheckNumber().equals(castOther.getCheckNumber()) ) );
    }

    @Override
    public int hashCode() {

            

Reported by PMD.

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

Line: 48

              		 PaymentId castOther = ( PaymentId ) other; 
         
		 return ( (this.getCustomerNumber()==castOther.getCustomerNumber()) || ( this.getCustomerNumber()!=null && castOther.getCustomerNumber()!=null && this.getCustomerNumber().equals(castOther.getCustomerNumber()) ) )
		         && ( (this.getCheckNumber()==castOther.getCheckNumber()) || ( this.getCheckNumber()!=null && castOther.getCheckNumber()!=null && this.getCheckNumber().equals(castOther.getCheckNumber()) ) );
    }

    @Override
    public int hashCode() {
        int result = 17;

            

Reported by PMD.

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

Line: 48

              		 PaymentId castOther = ( PaymentId ) other; 
         
		 return ( (this.getCustomerNumber()==castOther.getCustomerNumber()) || ( this.getCustomerNumber()!=null && castOther.getCustomerNumber()!=null && this.getCustomerNumber().equals(castOther.getCustomerNumber()) ) )
		         && ( (this.getCheckNumber()==castOther.getCheckNumber()) || ( this.getCheckNumber()!=null && castOther.getCheckNumber()!=null && this.getCheckNumber().equals(castOther.getCheckNumber()) ) );
    }

    @Override
    public int hashCode() {
        int result = 17;

            

Reported by PMD.

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

Line: 48

              		 PaymentId castOther = ( PaymentId ) other; 
         
		 return ( (this.getCustomerNumber()==castOther.getCustomerNumber()) || ( this.getCustomerNumber()!=null && castOther.getCustomerNumber()!=null && this.getCustomerNumber().equals(castOther.getCustomerNumber()) ) )
		         && ( (this.getCheckNumber()==castOther.getCheckNumber()) || ( this.getCheckNumber()!=null && castOther.getCheckNumber()!=null && this.getCheckNumber().equals(castOther.getCheckNumber()) ) );
    }

    @Override
    public int hashCode() {
        int result = 17;

            

Reported by PMD.

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

Line: 47

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

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

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

    public static class Model {
        public double v1;
        public double 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 DoubleBenchmark {
    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 = "{\n" +
            "\t\"v1\":0.4430165316544028,\n" +
            "\t\"v2\":0.22676692048907365,\n" +

            

Reported by PMD.

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

Line: 22

                          "\t\"v5\":0.4262177938610565\n" +
            "}";

    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.

Avoid unused imports such as 'com.alibaba.json.bvtVO.IncomingDataPoint'
Design

Line: 4

              package com.alibaba.json.test.benchmark.basic;

import com.alibaba.fastjson.JSON;
import com.alibaba.json.bvtVO.IncomingDataPoint;

import java.util.Random;

/**
 * Created by wenshao on 04/08/2017.

            

Reported by PMD.

Avoid unused imports such as 'java.util.Random'
Design

Line: 6

              import com.alibaba.fastjson.JSON;
import com.alibaba.json.bvtVO.IncomingDataPoint;

import java.util.Random;

/**
 * Created by wenshao on 04/08/2017.
 */
public class DoubleBenchmark {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/writeClassName/WriteClassNameTest_Set.java
7 issues
System.out.println is used
Design

Line: 26

                      set.add(new B1());
        a.setList(set);
        String text = JSON.toJSONString(a, SerializerFeature.WriteClassName);
        System.out.println(text);
        Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set$A\",\"list\":Set[{},{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set$B1\"}]}",
                            text);

        A a1 = (A) JSON.parse(text);


            

Reported by PMD.

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

Line: 15

              import com.alibaba.fastjson.serializer.SerializerFeature;

public class WriteClassNameTest_Set extends TestCase {
    protected void setUp() throws Exception {
        ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set");
    }

    public void test_list() throws Exception {
        A a = new A();

            

Reported by PMD.

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

Line: 16

              
public class WriteClassNameTest_Set extends TestCase {
    protected void setUp() throws Exception {
        ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set");
    }

    public void test_list() throws Exception {
        A a = new A();
        Set<B> set = new LinkedHashSet<B>();

            

Reported by PMD.

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

Line: 19

                      ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set");
    }

    public void test_list() throws Exception {
        A a = new A();
        Set<B> set = new LinkedHashSet<B>();
        set.add(new B());
        set.add(new B1());
        a.setList(set);

            

Reported by PMD.

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

Line: 32

              
        A a1 = (A) JSON.parse(text);

        Assert.assertEquals(2, a1.getList().size());
    }

    public static class A {

        private Set<B> list;

            

Reported by PMD.

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

Line: 32

              
        A a1 = (A) JSON.parse(text);

        Assert.assertEquals(2, a1.getList().size());
    }

    public static class A {

        private Set<B> list;

            

Reported by PMD.

Avoid unused imports such as 'java.util.ArrayList'
Design

Line: 3

              package com.alibaba.json.bvt.writeClassName;

import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.Set;

import com.alibaba.fastjson.parser.ParserConfig;
import org.junit.Assert;
import junit.framework.TestCase;

            

Reported by PMD.