The following issues were found

src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest.java
18 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: 18

              
public class NameFilterTest extends TestCase {

    public void test_namefilter() throws Exception {
        NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 22

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";
                }

                return name;
            }

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 22

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";
                }

                return name;
            }

            

Reported by PMD.

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

Line: 33

              
        SerializeWriter out = new SerializeWriter();
        JSONSerializer serializer = new JSONSerializer(out);
        serializer.getNameFilters().add(filter);

        Bean a = new Bean();
        serializer.write(a);

        String text = out.toString();

            

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

                      Assert.assertEquals("{\"ID\":0}", text);
    }

    public void test_namefilter_1() throws Exception {
        NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 46

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";
                }

                return name;
            }

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 46

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";
                }

                return name;
            }

            

Reported by PMD.

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

Line: 57

              
        SerializeWriter out = new SerializeWriter();
        JSONSerializer serializer = new JSONSerializer(out);
        serializer.getNameFilters().add(filter);

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", 0);
        serializer.write(map);


            

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

                      Assert.assertEquals("{\"ID\":0}", text);
    }
    
    public static void test_toJSONString() throws Exception {
        NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 71

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";
                }

                return name;
            }

            

Reported by PMD.

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

Line: 18

                      entity.setValue(3L);

        String text = JSON.toJSONString(entity, SerializerFeature.WriteClassName);
        System.out.println(text);
        Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_smoothrat4$Entity\",\"value\":3L}",
                            text);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertEquals(Long.valueOf(3), entity2.getValue());

            

Reported by PMD.

System.out.println is used
Design

Line: 33

                      entity.setValue(3);

        String text = JSON.toJSONString(entity, SerializerFeature.WriteClassName);
        System.out.println(text);
        Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_smoothrat4$Entity\",\"value\":3}", text);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertEquals(Integer.valueOf(3), entity2.getValue());
    }

            

Reported by PMD.

System.out.println is used
Design

Line: 47

                      entity.setValue((short) 3);

        String text = JSON.toJSONString(entity, SerializerFeature.WriteClassName);
        System.out.println(text);
        Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_smoothrat4$Entity\",\"value\":3S}",
                            text);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertEquals(Short.valueOf((short) 3), entity2.getValue());

            

Reported by PMD.

System.out.println is used
Design

Line: 62

                      entity.setValue((byte) 3);

        String text = JSON.toJSONString(entity, SerializerFeature.WriteClassName);
        System.out.println(text);
        Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_smoothrat4$Entity\",\"value\":3B}",
                            text);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertEquals(Byte.valueOf((byte) 3), entity2.getValue());

            

Reported by PMD.

System.out.println is used
Design

Line: 77

                      entity.setValue(3F);

        String text = JSON.toJSONString(entity, SerializerFeature.WriteClassName);
        System.out.println(text);
        Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_smoothrat4$Entity\",\"value\":3.0F}",
                            text);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertEquals(3F, entity2.getValue());

            

Reported by PMD.

System.out.println is used
Design

Line: 92

                      entity.setValue(3D);

        String text = JSON.toJSONString(entity, SerializerFeature.WriteClassName);
        System.out.println(text);
        Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_smoothrat4$Entity\",\"value\":3.0D}",
                            text);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertEquals(3D, entity2.getValue());

            

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

              
public class Bug_for_smoothrat4 extends TestCase {

    public void test_long() throws Exception {

        Entity entity = new Entity();

        entity.setValue(3L);


            

Reported by PMD.

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

Line: 23

                                          text);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertEquals(Long.valueOf(3), entity2.getValue());
    }

    public void test_int() throws Exception {

        Entity entity = new Entity();

            

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

                      Assert.assertEquals(Long.valueOf(3), entity2.getValue());
    }

    public void test_int() throws Exception {

        Entity entity = new Entity();

        entity.setValue(3);


            

Reported by PMD.

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

Line: 37

                      Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_smoothrat4$Entity\",\"value\":3}", text);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertEquals(Integer.valueOf(3), entity2.getValue());
    }

    public void test_short() throws Exception {

        Entity entity = new Entity();

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/jdk8/LocalDateTimeTest.java
18 issues
System.out.println is used
Design

Line: 44

                      VO vo1 = JSON.parseObject("{\"date\":1511334591189}", VO.class);

        String text2 = JSON.toJSONString(vo, SerializerFeature.WriteDateUseDateFormat);
        System.out.println(text2);//{"date":"2017-11-22 15:09:51"}
        VO vo2 = JSON.parseObject(text2, VO.class);

        String text3 = JSON.toJSONString(vo, SerializerFeature.UseISO8601DateFormat);
        System.out.println(text3);//{"date":"2017-11-22T15:09:51"}
        VO vo3 = JSON.parseObject(text3, VO.class);

            

Reported by PMD.

System.out.println is used
Design

Line: 48

                      VO vo2 = JSON.parseObject(text2, VO.class);

        String text3 = JSON.toJSONString(vo, SerializerFeature.UseISO8601DateFormat);
        System.out.println(text3);//{"date":"2017-11-22T15:09:51"}
        VO vo3 = JSON.parseObject(text3, VO.class);

        String text4 = JSON.toJSONString(vo, SerializerFeature.UseISO8601DateFormat, SerializerFeature.WriteDateUseDateFormat);
        System.out.println(text4);//{"date":"2017-11-22T15:09:51"}
        VO vo4 = JSON.parseObject(text4, VO.class);

            

Reported by PMD.

System.out.println is used
Design

Line: 52

                      VO vo3 = JSON.parseObject(text3, VO.class);

        String text4 = JSON.toJSONString(vo, SerializerFeature.UseISO8601DateFormat, SerializerFeature.WriteDateUseDateFormat);
        System.out.println(text4);//{"date":"2017-11-22T15:09:51"}
        VO vo4 = JSON.parseObject(text4, VO.class);
    }

    public  void test_for_issue_1() throws Exception {
        String text = "{\"date\":\"2018-08-03 22:38:33.145\"}";

            

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 LocalDateTimeTest extends TestCase {

    public void test_for_issue() throws Exception {
        VO vo = new VO();
        vo.setDate(LocalDateTime.now().minusNanos(10L));
        
        String text = JSON.toJSONString(vo);
        

            

Reported by PMD.

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

Line: 16

              
    public void test_for_issue() throws Exception {
        VO vo = new VO();
        vo.setDate(LocalDateTime.now().minusNanos(10L));
        
        String text = JSON.toJSONString(vo);
        
        VO vo1 = JSON.parseObject(text, VO.class);
        

            

Reported by PMD.

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

Line: 22

                      
        VO vo1 = JSON.parseObject(text, VO.class);
        
        Assert.assertEquals(JSON.toJSONString(vo.getDate()), JSON.toJSONString(vo1.getDate()));
    }

    /**
     * 方法描述: 测试LocalDateTime 转化时间戳等 操作
     *  问题点1、 LocalDateTime 进来的值无法确定其时区,所以此处统一按着系统时区走。

            

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

                   *      4)如设置WriteDateUseDateFormat、UseISO8601DateFormat 同时设置,则按ISO8601的标准 "yyyy-MM-dd'T'HH:mm:ss"进行格式化
     * @author wuqiong  2017/11/22 15:08
     */
    public void test_toJsonString_ofLong()throws Exception {
        VO vo = new VO();
        vo.setDate(LocalDateTime.now());

        VO vo1 = JSON.parseObject("{\"date\":1511334591189}", VO.class);


            

Reported by PMD.

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

Line: 37

                   *      4)如设置WriteDateUseDateFormat、UseISO8601DateFormat 同时设置,则按ISO8601的标准 "yyyy-MM-dd'T'HH:mm:ss"进行格式化
     * @author wuqiong  2017/11/22 15:08
     */
    public void test_toJsonString_ofLong()throws Exception {
        VO vo = new VO();
        vo.setDate(LocalDateTime.now());

        VO vo1 = JSON.parseObject("{\"date\":1511334591189}", VO.class);


            

Reported by PMD.

Avoid unused local variables such as 'vo1'.
Design

Line: 41

                      VO vo = new VO();
        vo.setDate(LocalDateTime.now());

        VO vo1 = JSON.parseObject("{\"date\":1511334591189}", VO.class);

        String text2 = JSON.toJSONString(vo, SerializerFeature.WriteDateUseDateFormat);
        System.out.println(text2);//{"date":"2017-11-22 15:09:51"}
        VO vo2 = JSON.parseObject(text2, VO.class);


            

Reported by PMD.

Avoid unused local variables such as 'vo2'.
Design

Line: 45

              
        String text2 = JSON.toJSONString(vo, SerializerFeature.WriteDateUseDateFormat);
        System.out.println(text2);//{"date":"2017-11-22 15:09:51"}
        VO vo2 = JSON.parseObject(text2, VO.class);

        String text3 = JSON.toJSONString(vo, SerializerFeature.UseISO8601DateFormat);
        System.out.println(text3);//{"date":"2017-11-22T15:09:51"}
        VO vo3 = JSON.parseObject(text3, VO.class);


            

Reported by PMD.

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

Line: 37

              
        {
            String text = JSON.toJSONString(obj);
            System.out.println(text);
        }

        String text = JSON.toJSONString(obj, SerializerFeature.WriteClassName, SerializerFeature.WriteMapNullValue);
        System.out.println(text);
        JSON.parseObject(text, clazz, confg);

            

Reported by PMD.

System.out.println is used
Design

Line: 41

                      }

        String text = JSON.toJSONString(obj, SerializerFeature.WriteClassName, SerializerFeature.WriteMapNullValue);
        System.out.println(text);
        JSON.parseObject(text, clazz, confg);
        String clazzName = JSON.parse(text, confg).getClass().getName();
        Assert.assertEquals(clazz.getName(), clazzName);
    }


            

Reported by PMD.

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

Line: 20

              import com.alibaba.fastjson.serializer.SerializerFeature;

public class TestExternal6 extends TestCase {
    ParserConfig confg = ParserConfig.global;

    protected void setUp() throws Exception {
        confg.addAccept("org.mule.esb.model");
    }


            

Reported by PMD.

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

Line: 22

              public class TestExternal6 extends TestCase {
    ParserConfig confg = ParserConfig.global;

    protected void setUp() throws Exception {
        confg.addAccept("org.mule.esb.model");
    }

    public void test_0() throws Exception {
        ExtClassLoader classLoader = new ExtClassLoader();

            

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

                      confg.addAccept("org.mule.esb.model");
    }

    public void test_0() throws Exception {
        ExtClassLoader classLoader = new ExtClassLoader();
        Class<?> clazz = classLoader.loadClass("org.mule.esb.model.tcc.result.EsbResultModel");
        Method[] methods = clazz.getMethods();
        Method method = clazz.getMethod("setReturnValue", new Class[] { Serializable.class });


            

Reported by PMD.

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

Line: 29

                  public void test_0() throws Exception {
        ExtClassLoader classLoader = new ExtClassLoader();
        Class<?> clazz = classLoader.loadClass("org.mule.esb.model.tcc.result.EsbResultModel");
        Method[] methods = clazz.getMethods();
        Method method = clazz.getMethod("setReturnValue", new Class[] { Serializable.class });

        Object obj = clazz.newInstance();
//        method.invoke(obj, "AAAA");


            

Reported by PMD.

Avoid unused local variables such as 'method'.
Design

Line: 30

                      ExtClassLoader classLoader = new ExtClassLoader();
        Class<?> clazz = classLoader.loadClass("org.mule.esb.model.tcc.result.EsbResultModel");
        Method[] methods = clazz.getMethods();
        Method method = clazz.getMethod("setReturnValue", new Class[] { Serializable.class });

        Object obj = clazz.newInstance();
//        method.invoke(obj, "AAAA");

        {

            

Reported by PMD.

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

Line: 32

                      Method[] methods = clazz.getMethods();
        Method method = clazz.getMethod("setReturnValue", new Class[] { Serializable.class });

        Object obj = clazz.newInstance();
//        method.invoke(obj, "AAAA");

        {
            String text = JSON.toJSONString(obj);
            System.out.println(text);

            

Reported by PMD.

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

Line: 43

                      String text = JSON.toJSONString(obj, SerializerFeature.WriteClassName, SerializerFeature.WriteMapNullValue);
        System.out.println(text);
        JSON.parseObject(text, clazz, confg);
        String clazzName = JSON.parse(text, confg).getClass().getName();
        Assert.assertEquals(clazz.getName(), clazzName);
    }

    public static class ExtClassLoader extends ClassLoader {


            

Reported by PMD.

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

Line: 43

                      String text = JSON.toJSONString(obj, SerializerFeature.WriteClassName, SerializerFeature.WriteMapNullValue);
        System.out.println(text);
        JSON.parseObject(text, clazz, confg);
        String clazzName = JSON.parse(text, confg).getClass().getName();
        Assert.assertEquals(clazz.getName(), clazzName);
    }

    public static class ExtClassLoader extends ClassLoader {


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/list/ArrayListTypeFieldTest.java
18 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 ArrayListTypeFieldTest extends TestCase {

    public void test_0() throws Exception {
        Entity entity = JSON.parseObject("{,,,list:[,,,{value:3}]}", Entity.class);
        Assert.assertEquals(3, entity.getList().get(0).getValue());
    }

    public void test_1() throws Exception {

            

Reported by PMD.

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

Line: 16

              
    public void test_0() throws Exception {
        Entity entity = JSON.parseObject("{,,,list:[,,,{value:3}]}", Entity.class);
        Assert.assertEquals(3, entity.getList().get(0).getValue());
    }

    public void test_1() throws Exception {
        Entity entity = JSON.parseObject("{list:[{value:3}]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(3, entity.getList().get(0).getValue());

            

Reported by PMD.

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

Line: 16

              
    public void test_0() throws Exception {
        Entity entity = JSON.parseObject("{,,,list:[,,,{value:3}]}", Entity.class);
        Assert.assertEquals(3, entity.getList().get(0).getValue());
    }

    public void test_1() throws Exception {
        Entity entity = JSON.parseObject("{list:[{value:3}]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(3, entity.getList().get(0).getValue());

            

Reported by PMD.

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

Line: 16

              
    public void test_0() throws Exception {
        Entity entity = JSON.parseObject("{,,,list:[,,,{value:3}]}", Entity.class);
        Assert.assertEquals(3, entity.getList().get(0).getValue());
    }

    public void test_1() throws Exception {
        Entity entity = JSON.parseObject("{list:[{value:3}]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(3, entity.getList().get(0).getValue());

            

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(3, entity.getList().get(0).getValue());
    }

    public void test_1() throws Exception {
        Entity entity = JSON.parseObject("{list:[{value:3}]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(3, entity.getList().get(0).getValue());
    }
    
    public void test_null() throws Exception {

            

Reported by PMD.

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

Line: 21

              
    public void test_1() throws Exception {
        Entity entity = JSON.parseObject("{list:[{value:3}]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(3, entity.getList().get(0).getValue());
    }
    
    public void test_null() throws Exception {
        Entity entity = JSON.parseObject("{list:null}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(null, entity.getList());

            

Reported by PMD.

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

Line: 21

              
    public void test_1() throws Exception {
        Entity entity = JSON.parseObject("{list:[{value:3}]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(3, entity.getList().get(0).getValue());
    }
    
    public void test_null() throws Exception {
        Entity entity = JSON.parseObject("{list:null}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(null, entity.getList());

            

Reported by PMD.

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

Line: 21

              
    public void test_1() throws Exception {
        Entity entity = JSON.parseObject("{list:[{value:3}]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(3, entity.getList().get(0).getValue());
    }
    
    public void test_null() throws Exception {
        Entity entity = JSON.parseObject("{list:null}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(null, entity.getList());

            

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

                      Assert.assertEquals(3, entity.getList().get(0).getValue());
    }
    
    public void test_null() throws Exception {
        Entity entity = JSON.parseObject("{list:null}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(null, entity.getList());
    }
    public void test_null2() throws Exception {
        Entity entity = JSON.parseObject("{list:[null]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);

            

Reported by PMD.

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

Line: 26

                  
    public void test_null() throws Exception {
        Entity entity = JSON.parseObject("{list:null}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(null, entity.getList());
    }
    public void test_null2() throws Exception {
        Entity entity = JSON.parseObject("{list:[null]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(null, entity.getList().get(0));
    }

            

Reported by PMD.

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

Line: 32

              
//        ParserConfig.getGlobalInstance().putDeserializer(MediaContent.class, new MediaContentDeserializer());
        
        System.out.println(System.getProperty("java.vm.name") + " " + System.getProperty("java.runtime.version"));
        List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
        System.out.println(arguments);

        String text = JSON.toJSONString(EishayDecodeBytes.instance.getContent(), SerializerFeature.BeanToArray);
        System.out.println(text);

            

Reported by PMD.

System.out.println is used
Design

Line: 34

                      
        System.out.println(System.getProperty("java.vm.name") + " " + System.getProperty("java.runtime.version"));
        List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
        System.out.println(arguments);

        String text = JSON.toJSONString(EishayDecodeBytes.instance.getContent(), SerializerFeature.BeanToArray);
        System.out.println(text);
        
        for (int i = 0; i < 10; ++i) {

            

Reported by PMD.

System.out.println is used
Design

Line: 37

                      System.out.println(arguments);

        String text = JSON.toJSONString(EishayDecodeBytes.instance.getContent(), SerializerFeature.BeanToArray);
        System.out.println(text);
        
        for (int i = 0; i < 10; ++i) {
            perf(text);
        }
    }

            

Reported by PMD.

System.out.println is used
Design

Line: 59

                      long ygct = TestUtils.getYoungGCTime() - startYGCTime;
        long fgc = TestUtils.getFullGC() - startFGC;

        System.out.println("decode\t" + millis + ", ygc " + ygc + ", ygct " + ygct + ", fgc " + fgc);
        return millis;
    }

    static void decode(String text) {
        MediaContent content = JSON.parseObject(text, MediaContent.class, Feature.SupportArrayToBean);

            

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

              import data.media.writeAsArray.MediaContentSerializer;
import data.media.writeAsArray.MediaSerializer;

public class BenchmarkMain_EishayDecode_WriteAsArray {

    public static void main(String[] args) throws Exception {
//        SerializeConfig config = SerializeConfig.getGlobalInstance();
//        config.put(MediaContent.class, new MediaContentSerializer());
//        config.put(Media.class, new MediaSerializer());

            

Reported by PMD.

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

Line: 24

              
public class BenchmarkMain_EishayDecode_WriteAsArray {

    public static void main(String[] args) throws Exception {
//        SerializeConfig config = SerializeConfig.getGlobalInstance();
//        config.put(MediaContent.class, new MediaContentSerializer());
//        config.put(Media.class, new MediaSerializer());
//        config.put(Image.class, new ImageSerializer());


            

Reported by PMD.

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

Line: 33

              //        ParserConfig.getGlobalInstance().putDeserializer(MediaContent.class, new MediaContentDeserializer());
        
        System.out.println(System.getProperty("java.vm.name") + " " + System.getProperty("java.runtime.version"));
        List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
        System.out.println(arguments);

        String text = JSON.toJSONString(EishayDecodeBytes.instance.getContent(), SerializerFeature.BeanToArray);
        System.out.println(text);
        

            

Reported by PMD.

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

Line: 36

                      List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
        System.out.println(arguments);

        String text = JSON.toJSONString(EishayDecodeBytes.instance.getContent(), SerializerFeature.BeanToArray);
        System.out.println(text);
        
        for (int i = 0; i < 10; ++i) {
            perf(text);
        }

            

Reported by PMD.

Avoid unused local variables such as 'content'.
Design

Line: 64

                  }

    static void decode(String text) {
        MediaContent content = JSON.parseObject(text, MediaContent.class, Feature.SupportArrayToBean);
        
//        JSON.parseObject(text);
    }
}

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.parser.ParserConfig'
Design

Line: 8

              
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.json.test.TestUtils;
import com.alibaba.json.test.benchmark.decode.EishayDecodeBytes;


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/StringBuilderFieldTest.java
18 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 StringBuilderFieldTest extends TestCase {

    public void test_codec_null() throws Exception {
        V0 v = new V0();

        SerializeConfig mapping = new SerializeConfig();
        mapping.setAsmEnable(false);


            

Reported by PMD.

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

Line: 28

              
        V0 v1 = JSON.parseObject(text, V0.class, config, JSON.DEFAULT_PARSER_FEATURE);

        Assert.assertEquals(v1.getValue(), v.getValue());
    }

    public void test_codec_null_1() throws Exception {
        V0 v = new V0();


            

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(v1.getValue(), v.getValue());
    }

    public void test_codec_null_1() throws Exception {
        V0 v = new V0();

        SerializeConfig mapping = new SerializeConfig();
        mapping.setAsmEnable(false);


            

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

                      Assert.assertEquals("{\"value\":\"\"}", text);
    }

    public void test_deserialize_1() throws Exception {
        String json = "{\"value\":\"\"}";

        V0 vo = JSON.parseObject(json, V0.class);
        Assert.assertNotNull(vo.getValue());
        Assert.assertEquals("", vo.getValue().toString());

            

Reported by PMD.

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

Line: 46

                      String json = "{\"value\":\"\"}";

        V0 vo = JSON.parseObject(json, V0.class);
        Assert.assertNotNull(vo.getValue());
        Assert.assertEquals("", vo.getValue().toString());
    }
    
    public void test_deserialize_2() throws Exception {
        String json = "{\"value\":null}";

            

Reported by PMD.

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

Line: 47

              
        V0 vo = JSON.parseObject(json, V0.class);
        Assert.assertNotNull(vo.getValue());
        Assert.assertEquals("", vo.getValue().toString());
    }
    
    public void test_deserialize_2() throws Exception {
        String json = "{\"value\":null}";


            

Reported by PMD.

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

Line: 47

              
        V0 vo = JSON.parseObject(json, V0.class);
        Assert.assertNotNull(vo.getValue());
        Assert.assertEquals("", vo.getValue().toString());
    }
    
    public void test_deserialize_2() throws Exception {
        String json = "{\"value\":null}";


            

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

                      Assert.assertEquals("", vo.getValue().toString());
    }
    
    public void test_deserialize_2() throws Exception {
        String json = "{\"value\":null}";

        V0 vo = JSON.parseObject(json, V0.class);
        Assert.assertNull(vo.getValue());
    }

            

Reported by PMD.

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

Line: 54

                      String json = "{\"value\":null}";

        V0 vo = JSON.parseObject(json, V0.class);
        Assert.assertNull(vo.getValue());
    }
    
    public void test_deserialize_3() throws Exception {
        String json = "{\"value\":\"true\"}";


            

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

                      Assert.assertNull(vo.getValue());
    }
    
    public void test_deserialize_3() throws Exception {
        String json = "{\"value\":\"true\"}";

        V0 vo = JSON.parseObject(json, V0.class);
        Assert.assertNotNull(vo.getValue());
        Assert.assertEquals("true", vo.getValue().toString());

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_2100/Issue2165.java
18 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 10

              
public class Issue2165 extends TestCase {

    public void test_for_issue() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("9295260120", Integer.class);
        } catch (JSONException ex) {
            error = ex;

            

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

              
public class Issue2165 extends TestCase {

    public void test_for_issue() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("9295260120", Integer.class);
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                      } catch (JSONException ex) {
            error = ex;
        }
        assertNotNull(error);
        assertEquals("parseInt error", error.getMessage());
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;

            

Reported by PMD.

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

Line: 18

                          error = ex;
        }
        assertNotNull(error);
        assertEquals("parseInt error", error.getMessage());
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                          error = ex;
        }
        assertNotNull(error);
        assertEquals("parseInt error", error.getMessage());
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

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

Line: 21

                      assertEquals("parseInt error", error.getMessage());
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":9295260120}", Model.class);
        } catch (JSONException ex) {
            error = ex;

            

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

                      assertEquals("parseInt error", error.getMessage());
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":9295260120}", Model.class);
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 28

                      } catch (JSONException ex) {
            error = ex;
        }
        assertNotNull(error);
        assertEquals("parseInt error, field : value", error.getMessage());
    }

    public void test_for_issue_2() throws Exception {
        Exception error = null;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

                          error = ex;
        }
        assertNotNull(error);
        assertEquals("parseInt error, field : value", error.getMessage());
    }

    public void test_for_issue_2() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

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

Line: 29

                          error = ex;
        }
        assertNotNull(error);
        assertEquals("parseInt error, field : value", error.getMessage());
    }

    public void test_for_issue_2() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/date/DateParseTest14.java
18 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 DateParseTest14 extends TestCase {

    public void test_0_lt() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"date\":\"19790714130723#56\"}", VO.class);
        } catch (Exception ex) {
            error = ex;

            

Reported by PMD.

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

Line: 17

                      Exception error = null;
        try {
            JSON.parseObject("{\"date\":\"19790714130723#56\"}", VO.class);
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    

            

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

                      Assert.assertNotNull(error);
    }
    
    public void test_0_gt() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"date\":\"19790714130723A56\"}", VO.class);
        } catch (Exception ex) {
            error = ex;

            

Reported by PMD.

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

Line: 27

                      Exception error = null;
        try {
            JSON.parseObject("{\"date\":\"19790714130723A56\"}", VO.class);
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    

            

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

                      Assert.assertNotNull(error);
    }
    
    public void test_1_lt() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"date\":\"197907141307231#6\"}", VO.class);
        } catch (Exception ex) {
            error = ex;

            

Reported by PMD.

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

Line: 37

                      Exception error = null;
        try {
            JSON.parseObject("{\"date\":\"197907141307231#6\"}", VO.class);
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    

            

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

                      Assert.assertNotNull(error);
    }
    
    public void test_1_gt() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"date\":\"197907141307231A6\"}", VO.class);
        } catch (Exception ex) {
            error = ex;

            

Reported by PMD.

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

Line: 47

                      Exception error = null;
        try {
            JSON.parseObject("{\"date\":\"197907141307231A6\"}", VO.class);
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    

            

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

                      Assert.assertNotNull(error);
    }
    
    public void test_2_lt() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"date\":\"1979071413072315#\"}", VO.class);
        } catch (Exception ex) {
            error = ex;

            

Reported by PMD.

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

Line: 57

                      Exception error = null;
        try {
            JSON.parseObject("{\"date\":\"1979071413072315#\"}", VO.class);
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/StringBufferFieldTest.java
18 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 StringBufferFieldTest extends TestCase {

    public void test_codec_null() throws Exception {
        V0 v = new V0();

        SerializeConfig mapping = new SerializeConfig();
        mapping.setAsmEnable(false);


            

Reported by PMD.

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

Line: 28

              
        V0 v1 = JSON.parseObject(text, V0.class, config, JSON.DEFAULT_PARSER_FEATURE);

        Assert.assertEquals(v1.getValue(), v.getValue());
    }

    public void test_codec_null_1() throws Exception {
        V0 v = new V0();


            

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(v1.getValue(), v.getValue());
    }

    public void test_codec_null_1() throws Exception {
        V0 v = new V0();

        SerializeConfig mapping = new SerializeConfig();
        mapping.setAsmEnable(false);


            

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

                      Assert.assertEquals("{\"value\":\"\"}", text);
    }

    public void test_deserialize_1() throws Exception {
        String json = "{\"value\":\"\"}";

        V0 vo = JSON.parseObject(json, V0.class);
        Assert.assertNotNull(vo.getValue());
        Assert.assertEquals("", vo.getValue().toString());

            

Reported by PMD.

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

Line: 46

                      String json = "{\"value\":\"\"}";

        V0 vo = JSON.parseObject(json, V0.class);
        Assert.assertNotNull(vo.getValue());
        Assert.assertEquals("", vo.getValue().toString());
    }
    
    public void test_deserialize_2() throws Exception {
        String json = "{\"value\":null}";

            

Reported by PMD.

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

Line: 47

              
        V0 vo = JSON.parseObject(json, V0.class);
        Assert.assertNotNull(vo.getValue());
        Assert.assertEquals("", vo.getValue().toString());
    }
    
    public void test_deserialize_2() throws Exception {
        String json = "{\"value\":null}";


            

Reported by PMD.

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

Line: 47

              
        V0 vo = JSON.parseObject(json, V0.class);
        Assert.assertNotNull(vo.getValue());
        Assert.assertEquals("", vo.getValue().toString());
    }
    
    public void test_deserialize_2() throws Exception {
        String json = "{\"value\":null}";


            

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

                      Assert.assertEquals("", vo.getValue().toString());
    }
    
    public void test_deserialize_2() throws Exception {
        String json = "{\"value\":null}";

        V0 vo = JSON.parseObject(json, V0.class);
        Assert.assertNull(vo.getValue());
    }

            

Reported by PMD.

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

Line: 54

                      String json = "{\"value\":null}";

        V0 vo = JSON.parseObject(json, V0.class);
        Assert.assertNull(vo.getValue());
    }
    
    public void test_deserialize_3() throws Exception {
        String json = "{\"value\":\"true\"}";


            

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

                      Assert.assertNull(vo.getValue());
    }
    
    public void test_deserialize_3() throws Exception {
        String json = "{\"value\":\"true\"}";

        V0 vo = JSON.parseObject(json, V0.class);
        Assert.assertNotNull(vo.getValue());
        Assert.assertEquals("true", vo.getValue().toString());

            

Reported by PMD.