The following issues were found

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

Line: 14

              
public class EnumFieldTest3_private extends TestCase {

    public void test_1() throws Exception {
        Model[] array = new Model[2048];
        for (int i = 0; i < array.length; ++i) {
            array[i] = new Model();
            array[i].value = Type.A;
        }

            

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

                      }
    }
    
    public void test_1_writer() throws Exception {
        Model[] array = new Model[2048];
        for (int i = 0; i < array.length; ++i) {
            array[i] = new Model();
            array[i].value = Type.A;
        }

            

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

                      }
    }
    
    public void test_null() throws Exception {
        Model[] array = new Model[2048];
        for (int i = 0; i < array.length; ++i) {
            array[i] = new Model();
            array[i].value = null;
        }

            

Reported by PMD.

Assigning an Object to null is a code smell. Consider refactoring.
Error

Line: 54

                      Model[] array = new Model[2048];
        for (int i = 0; i < array.length; ++i) {
            array[i] = new Model();
            array[i].value = null;
        }

        String text = JSON.toJSONString(array, SerializerFeature.WriteMapNullValue);

        Model[] array2 = JSON.parseObject(text, Model[].class);

            

Reported by PMD.

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

Line: 69

              
    public static class Model {

        public Type value;

    }
    
    private static enum Type {
        A, B, C

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_jial10802.java
5 issues
System.out.println is used
Design

Line: 30

              
        Page<Bean> jsonPage = JSON.parseObject(json, new TypeReference<Page<Bean>>() {
        });
        System.out.println(jsonPage.getItems().get(0).getName());
    }
}

            

Reported by PMD.

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

Line: 16

              

public class Bug_for_jial10802 extends TestCase {
    public void test_for_jial10802() throws Exception {
        Page<Bean> page = new Page<Bean>();
        page.setCount(1);
        List<Bean> items = new ArrayList<Bean>();
        Bean item = new Bean();
        item.setId(1);

            

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

              

public class Bug_for_jial10802 extends TestCase {
    public void test_for_jial10802() throws Exception {
        Page<Bean> page = new Page<Bean>();
        page.setCount(1);
        List<Bean> items = new ArrayList<Bean>();
        Bean item = new Bean();
        item.setId(1);

            

Reported by PMD.

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

Line: 30

              
        Page<Bean> jsonPage = JSON.parseObject(json, new TypeReference<Page<Bean>>() {
        });
        System.out.println(jsonPage.getItems().get(0).getName());
    }
}

            

Reported by PMD.

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

Line: 30

              
        Page<Bean> jsonPage = JSON.parseObject(json, new TypeReference<Page<Bean>>() {
        });
        System.out.println(jsonPage.getItems().get(0).getName());
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_729.java
5 issues
JUnit tests should include assert() or fail()
Design

Line: 14

              
public class Bug_for_issue_729 extends TestCase {

    public void test_for_issue() throws Exception {
        Person person = new Person();
        person.setName("bob");
        person.startTime = new Date();

        String result = JSON.toJSONString(person);

            

Reported by PMD.

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

Line: 14

              
public class Bug_for_issue_729 extends TestCase {

    public void test_for_issue() throws Exception {
        Person person = new Person();
        person.setName("bob");
        person.startTime = new Date();

        String result = JSON.toJSONString(person);

            

Reported by PMD.

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

Line: 21

              
        String result = JSON.toJSONString(person);
        Person person2 = JSON.parseObject(result, Person.class);
        person2.toString();
    }

    public static class Person implements Serializable {

        public String name;

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 24

                      person2.toString();
    }

    public static class Person implements Serializable {

        public String name;

        @JSONField(format = "yyyy-MM-dd HH:mm")
        public Date   startTime;

            

Reported by PMD.

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

Line: 24

                      person2.toString();
    }

    public static class Person implements Serializable {

        public String name;

        @JSONField(format = "yyyy-MM-dd HH:mm")
        public Date   startTime;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvtVO/vip_com/QueryLoanOrderRsp.java
5 issues
System.out.println is used
Design

Line: 84

                  rsp.setTxn_list(txn_list);
    
    String txt = JSON.toJSONString(rsp);
    System.out.println(txt);
    
    String txt2 = JSON.toJSONString(txn_list);
    System.out.println(txt2);
    
    List<TxnListItsm> itsms = JSON.parseObject(txt2, 

            

Reported by PMD.

System.out.println is used
Design

Line: 87

                  System.out.println(txt);
    
    String txt2 = JSON.toJSONString(txn_list);
    System.out.println(txt2);
    
    List<TxnListItsm> itsms = JSON.parseObject(txt2, 
        new TypeReference<List<TxnListItsm>>(){});
    System.out.println(itsms);


            

Reported by PMD.

System.out.println is used
Design

Line: 91

                  
    List<TxnListItsm> itsms = JSON.parseObject(txt2, 
        new TypeReference<List<TxnListItsm>>(){});
    System.out.println(itsms);

    rsp = JSON.parseObject(txt, 
        new TypeReference<QueryLoanOrderRsp>(){});
    
    System.out.println(rsp);

            

Reported by PMD.

System.out.println is used
Design

Line: 96

                  rsp = JSON.parseObject(txt, 
        new TypeReference<QueryLoanOrderRsp>(){});
    
    System.out.println(rsp);
  }
}

            

Reported by PMD.

The class 'QueryLoanOrderRsp' is suspected to be a Data Class (WOC=7.143%, NOPA=0, NOAM=12, WMC=14)
Design

Line: 10

              import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;

public class QueryLoanOrderRsp {
  private String loan_card_no;
  private String loan_prod_code;
  private String last_row_type;//最后一条记录类型
  private String last_row_key;//最后一条记录键值
  private String nextpage_flag;//是否有下一页标志

            

Reported by PMD.

src/test/java/com/alibaba/json/demo/EncodeDemo.java
5 issues
System.out.println is used
Design

Line: 27

              
        String jsonString = JSON.toJSONString(group);

        System.out.println(jsonString);
        
        JSON.parseObject(jsonString, Group.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 EncodeDemo extends TestCase {

    public void test_encode() throws Exception {
        Group group = new Group();
        group.setId(0L);
        group.setName("admin");

        User guestUser = new User();

            

Reported by PMD.

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

Line: 9

              
public class EncodeDemo extends TestCase {

    public void test_encode() throws Exception {
        Group group = new Group();
        group.setId(0L);
        group.setName("admin");

        User guestUser = new User();

            

Reported by PMD.

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

Line: 22

                      rootUser.setId(3L);
        rootUser.setName("root");

        group.getUsers().add(guestUser);
        group.getUsers().add(rootUser);

        String jsonString = JSON.toJSONString(group);

        System.out.println(jsonString);

            

Reported by PMD.

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

Line: 23

                      rootUser.setName("root");

        group.getUsers().add(guestUser);
        group.getUsers().add(rootUser);

        String jsonString = JSON.toJSONString(group);

        System.out.println(jsonString);
        

            

Reported by PMD.

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

Line: 11

               * Created by wenshao on 06/02/2017.
 */
public class AlipayJSONPathReplace extends TestCase {
    public void test_jsonpath() throws Exception {
        Model model = new Model();
        JSONPath path = JSONPath.compile("/value/id");
        path.set(model, 123);
        assertNotNull(model.value);
    }

            

Reported by PMD.

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

Line: 14

                  public void test_jsonpath() throws Exception {
        Model model = new Model();
        JSONPath path = JSONPath.compile("/value/id");
        path.set(model, 123);
        assertNotNull(model.value);
    }

    public static class Model {
        public Value value;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 15

                      Model model = new Model();
        JSONPath path = JSONPath.compile("/value/id");
        path.set(model, 123);
        assertNotNull(model.value);
    }

    public static class Model {
        public Value value;
    }

            

Reported by PMD.

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

Line: 19

                  }

    public static class Model {
        public Value value;
    }

    public static class Value {
        public int id;
    }

            

Reported by PMD.

Avoid unused imports such as 'com.fasterxml.jackson.jaxrs.json.annotation.JSONP'
Design

Line: 4

              package com.alibaba.json.test.a;

import com.alibaba.fastjson.JSONPath;
import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
import junit.framework.TestCase;

/**
 * Created by wenshao on 06/02/2017.
 */

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/writeAsArray/WriteAsArray_jsonType.java
5 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: 15

              
public class WriteAsArray_jsonType extends TestCase {

    public void test_0() throws Exception {
        VO vo = new VO();
        vo.setId(123);
        vo.setName("wenshao");
        
        Parent parent = new Parent();

            

Reported by PMD.

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

Line: 25

              
        String text = JSON.toJSONString(parent);
        Assert.assertEquals("{\"vo\":[123,\"wenshao\"]}", text);
        VO vo2 = JSON.parseObject(text, Parent.class).getVo();
        Assert.assertEquals(vo.getId(), vo2.getId());
        Assert.assertEquals(vo.getName(), vo2.getName());
    }

    public static class Parent {

            

Reported by PMD.

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

Line: 26

                      String text = JSON.toJSONString(parent);
        Assert.assertEquals("{\"vo\":[123,\"wenshao\"]}", text);
        VO vo2 = JSON.parseObject(text, Parent.class).getVo();
        Assert.assertEquals(vo.getId(), vo2.getId());
        Assert.assertEquals(vo.getName(), vo2.getName());
    }

    public static class Parent {
        private VO vo;

            

Reported by PMD.

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

Line: 27

                      Assert.assertEquals("{\"vo\":[123,\"wenshao\"]}", text);
        VO vo2 = JSON.parseObject(text, Parent.class).getVo();
        Assert.assertEquals(vo.getId(), vo2.getId());
        Assert.assertEquals(vo.getName(), vo2.getName());
    }

    public static class Parent {
        private VO vo;


            

Reported by PMD.

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

Line: 44

                  }

    @JSONType(serialzeFeatures=SerializerFeature.BeanToArray, parseFeatures=Feature.SupportArrayToBean)
    public static class VO {
        @JSONField(ordinal=1)
        private int    id;
        
        @JSONField(ordinal=2)
        private String name;

            

Reported by PMD.

src/test/java/com/alibaba/json/test/tmall/TmallTest.java
5 issues
Avoid instantiating FileInputStream, FileOutputStream, FileReader, or FileWriter
Performance

Line: 18

                  @SuppressWarnings("deprecation")
    public void test_for_tmall() throws Exception {
        File file = new File("/Users/wenshao/Downloads/tmall_perf/searchjson.json");
        String text = IOUtils.readAll(new FileReader(file));

        for (int i = 0; i < 10; ++i) {
            long start = System.currentTimeMillis();
            perf(text);
            long millis = System.currentTimeMillis() - start;

            

Reported by PMD.

System.out.println is used
Design

Line: 24

                          long start = System.currentTimeMillis();
            perf(text);
            long millis = System.currentTimeMillis() - start;
            System.out.println("millis : " + millis);
        }
    }

    private void perf(String text) {
        for (int i = 0; i < 1000; ++i) {

            

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

               * Created by wenshao on 17/03/2017.
 */
public class TmallTest extends TestCase {
    @SuppressWarnings("deprecation")
    public void test_for_tmall() throws Exception {
        File file = new File("/Users/wenshao/Downloads/tmall_perf/searchjson.json");
        String text = IOUtils.readAll(new FileReader(file));

        for (int i = 0; i < 10; ++i) {

            

Reported by PMD.

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

Line: 16

               */
public class TmallTest extends TestCase {
    @SuppressWarnings("deprecation")
    public void test_for_tmall() throws Exception {
        File file = new File("/Users/wenshao/Downloads/tmall_perf/searchjson.json");
        String text = IOUtils.readAll(new FileReader(file));

        for (int i = 0; i < 10; ++i) {
            long start = System.currentTimeMillis();

            

Reported by PMD.

Found 'DU'-anomaly for variable 'text' (lines '18'-'26').
Error

Line: 18

                  @SuppressWarnings("deprecation")
    public void test_for_tmall() throws Exception {
        File file = new File("/Users/wenshao/Downloads/tmall_perf/searchjson.json");
        String text = IOUtils.readAll(new FileReader(file));

        for (int i = 0; i < 10; ++i) {
            long start = System.currentTimeMillis();
            perf(text);
            long millis = System.currentTimeMillis() - start;

            

Reported by PMD.

src/test/java/com/alibaba/json/test/vans/VansData.java
5 issues
Classes implementing Serializable should set a serialVersionUID
Error

Line: 10

              /**
 * Created by xiaolin_kxl on 16/12/28.
 */
public class VansData implements Serializable{

    public int[] textures;
    public ArrayList<String> images;
    public VansObject object;
    public VansMetaData metadata;

            

Reported by PMD.

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

Line: 13

              public class VansData implements Serializable{

    public int[] textures;
    public ArrayList<String> images;
    public VansObject object;
    public VansMetaData metadata;
    public ArrayList<VansGeometry> geometries;
    public ArrayList<VansAnimation> animations;
    public Object materials;

            

Reported by PMD.

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

Line: 16

                  public ArrayList<String> images;
    public VansObject object;
    public VansMetaData metadata;
    public ArrayList<VansGeometry> geometries;
    public ArrayList<VansAnimation> animations;
    public Object materials;

}
            

Reported by PMD.

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

Line: 17

                  public VansObject object;
    public VansMetaData metadata;
    public ArrayList<VansGeometry> geometries;
    public ArrayList<VansAnimation> animations;
    public Object materials;

}
            

Reported by PMD.

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

Line: 5

              
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by xiaolin_kxl on 16/12/28.
 */
public class VansData implements Serializable{

            

Reported by PMD.

src/test/java/com/alibaba/json/test/benchmark/BenchmarkMain.java
5 issues
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: 7

              import com.alibaba.json.test.benchmark.decode.*;
import com.alibaba.json.test.codec.*;

public class BenchmarkMain {
    public static void main(String[] args) throws Exception {
         // 注意,byte[]在jackson中是使用base64编码的,不正确的。

        BenchmarkExecutor executor = new BenchmarkExecutor();
        executor.setExecuteCount(10);

            

Reported by PMD.

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

Line: 8

              import com.alibaba.json.test.codec.*;

public class BenchmarkMain {
    public static void main(String[] args) throws Exception {
         // 注意,byte[]在jackson中是使用base64编码的,不正确的。

        BenchmarkExecutor executor = new BenchmarkExecutor();
        executor.setExecuteCount(10);
//        executor.getCodecList().add(new FastjsonManualCodec());

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.json.test.benchmark.encode'
Design

Line: 3

              package com.alibaba.json.test.benchmark;

import com.alibaba.json.test.benchmark.encode.*;
import com.alibaba.json.test.benchmark.decode.*;
import com.alibaba.json.test.codec.*;

public class BenchmarkMain {
    public static void main(String[] args) throws Exception {
         // 注意,byte[]在jackson中是使用base64编码的,不正确的。

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.json.test.benchmark.decode'
Design

Line: 4

              package com.alibaba.json.test.benchmark;

import com.alibaba.json.test.benchmark.encode.*;
import com.alibaba.json.test.benchmark.decode.*;
import com.alibaba.json.test.codec.*;

public class BenchmarkMain {
    public static void main(String[] args) throws Exception {
         // 注意,byte[]在jackson中是使用base64编码的,不正确的。

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.json.test.codec'
Design

Line: 5

              
import com.alibaba.json.test.benchmark.encode.*;
import com.alibaba.json.test.benchmark.decode.*;
import com.alibaba.json.test.codec.*;

public class BenchmarkMain {
    public static void main(String[] args) throws Exception {
         // 注意,byte[]在jackson中是使用base64编码的,不正确的。


            

Reported by PMD.