The following issues were found

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

Line: 10

              import junit.framework.TestCase;

public class JSONPath_containsValue_double extends TestCase {
    public void test_root() throws Exception {
        Model model = new Model();
        model.value = 1001D;
        
        Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001));
        Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001L));

            

Reported by PMD.

The String literal '/value' appears 10 times in this file; the first occurrence is on line 14
Error

Line: 14

                      Model model = new Model();
        model.value = 1001D;
        
        Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001));
        Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001L));
        Assert.assertTrue(JSONPath.containsValue(model, "/value", (short) 1001));
        Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001F));
        Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001D));
        

            

Reported by PMD.

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

Line: 28

                  }
    
    public static class Model {
        public double value;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/path/JSONPath_containsValue_biginteger.java
3 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 junit.framework.TestCase;

public class JSONPath_containsValue_biginteger extends TestCase {
    public void test_root() throws Exception {
        Model model = new Model();
        model.value = new BigInteger("1001");
        
        Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001));
        Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001L));

            

Reported by PMD.

The String literal '/value' appears 6 times in this file; the first occurrence is on line 16
Error

Line: 16

                      Model model = new Model();
        model.value = new BigInteger("1001");
        
        Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001));
        Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001L));
        Assert.assertTrue(JSONPath.containsValue(model, "/value", (short) 1001));
        
        Assert.assertFalse(JSONPath.containsValue(model, "/value", 1002));
        Assert.assertFalse(JSONPath.containsValue(model, "/value", 1002L));

            

Reported by PMD.

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

Line: 26

                  }
    
    public static class Model {
        public BigInteger value;
    }
}

            

Reported by PMD.

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

    public void test_boolean() throws Exception {
        Assert.assertEquals(Boolean.TRUE, JSON.parseObject("true", Boolean.class));
        Assert.assertEquals(Boolean.FALSE, JSON.parseObject("false", Boolean.class));

        Assert.assertEquals(Boolean.TRUE, JSON.parseObject("'true'", Boolean.class));
        Assert.assertEquals(Boolean.FALSE, JSON.parseObject("'false'", Boolean.class));

            

Reported by PMD.

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

Line: 30

                      {
            DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(),
                                                             JSON.DEFAULT_PARSER_FEATURE);
            Assert.assertEquals(null, BooleanCodec.instance.deserialze(parser, null, null));
            parser.close();
        }
        Assert.assertEquals(JSONToken.TRUE, BooleanCodec.instance.getFastMatchToken());
    }
}

            

Reported by PMD.

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

Line: 33

                          Assert.assertEquals(null, BooleanCodec.instance.deserialze(parser, null, null));
            parser.close();
        }
        Assert.assertEquals(JSONToken.TRUE, BooleanCodec.instance.getFastMatchToken());
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/enum_/EnumTest3.java
3 issues
Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
Design

Line: 40

                      try {
            JSON.parseObject(json, Pojo.class);
            Assert.assertTrue(true);
        } catch (Exception e) {
            Assert.fail("枚举默认序列化name值,可以反序列化成功");
        }

		Map<String, Pojo> map = new HashMap<String, Pojo>();
		map.put("a", pojo);

            

Reported by PMD.

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

Line: 71

                      
        try {
            Pojo pojo1 = JSON.parseObject(json, Pojo.class);
            Assert.assertNull(pojo1.getSex());
        } catch (Exception e) {
            Assert.assertTrue(true);
        }

        Map<String, Pojo> map = new HashMap<String, Pojo>();

            

Reported by PMD.

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

Line: 72

                      try {
            Pojo pojo1 = JSON.parseObject(json, Pojo.class);
            Assert.assertNull(pojo1.getSex());
        } catch (Exception e) {
            Assert.assertTrue(true);
        }

        Map<String, Pojo> map = new HashMap<String, Pojo>();
        map.put("a", pojo);

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/TransientTest.java
3 issues
System.out.println is used
Design

Line: 28

                      parent.addChild(child);

        String text = JSON.toJSONString(parent);
        System.out.println(text);
        Map</**fieldName*/String , Field> fieldCacheMap =new HashMap<String, Field>();
        ParserConfig.parserAllFieldToCache(Category.class, fieldCacheMap);  
        Assert.assertNotNull(ParserConfig.getFieldFromCache("name", fieldCacheMap));
        Assert.assertNull(ParserConfig.getFieldFromCache("abc",fieldCacheMap));
    }

            

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

              
public class TransientTest extends TestCase {

    public void test_transient() throws Exception {
        Category parent = new Category();
        parent.setName("Parent");

        Category child = new Category();
        child.setName("child");

            

Reported by PMD.

The class 'Category' is suspected to be a Data Class (WOC=14.286%, NOPA=0, NOAM=6, WMC=7)
Design

Line: 35

                      Assert.assertNull(ParserConfig.getFieldFromCache("abc",fieldCacheMap));
    }

    public static class Category {

        private String             name;
        private transient Category parent;

        private List<Category>     children = new ArrayList<Category>();

            

Reported by PMD.

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

Line: 9

              import org.junit.Assert;

public class JSONDirectTest_number extends TestCase {
    public void test_feature() throws Exception {
        Model model = new Model();
        model.id = 1001;
        model.value = "12.34";
        
        String json = JSON.toJSONString(model);

            

Reported by PMD.

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

Line: 20

                  }

    public static class Model {
        public int id;
        @JSONField(jsonDirect=true)
        public String value;
    }
}

            

Reported by PMD.

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

Line: 22

                  public static class Model {
        public int id;
        @JSONField(jsonDirect=true)
        public String value;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/path/JSONPath_array_length.java
3 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

              import java.util.Collections;

public class JSONPath_array_length extends TestCase {
    public void test_list_size() throws Exception {
        Assert.assertEquals(0, JSONPath.eval(new JSONArray(), "$.length"));
    }

    public void test_list_size1() throws Exception {
        Assert.assertEquals(0, JSONPath.eval(new Object[0], "$.length()"));

            

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

                      Assert.assertEquals(0, JSONPath.eval(new JSONArray(), "$.length"));
    }

    public void test_list_size1() throws Exception {
        Assert.assertEquals(0, JSONPath.eval(new Object[0], "$.length()"));
    }
}

            

Reported by PMD.

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

Line: 8

              import junit.framework.TestCase;
import org.junit.Assert;

import java.util.Collections;

public class JSONPath_array_length extends TestCase {
    public void test_list_size() throws Exception {
        Assert.assertEquals(0, JSONPath.eval(new JSONArray(), "$.length"));
    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/filters/ArraySerializerTest.java
3 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 ArraySerializerTest extends TestCase {

    public void test_0() throws Exception {
        SerializeWriter out = new SerializeWriter(1);

        JSONSerializer.write(out, new A[] { new A(), null, null });

        Assert.assertEquals("[{},null,null]", 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: 21

                      Assert.assertEquals("[{},null,null]", out.toString());
    }

    public void test_1() throws Exception {
        SerializeWriter out = new SerializeWriter(1);

        JSONSerializer.write(out, new A[] {});

        Assert.assertEquals("[]", 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: 31

                      new IOUtils();
    }

    public void test_2() throws Exception {
        SerializeWriter out = new SerializeWriter(1);

        JSONSerializer.write(out, new A[] { new A() });

        Assert.assertEquals("[{}]", out.toString());

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/UUIDTest.java
3 issues
System.out.println is used
Design

Line: 17

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

        Assert.assertEquals(JSON.toJSONString(id.toString()), text);
     
        UUID id2 = JSON.parseObject(text,  UUID.class);
        Assert.assertEquals(id, id2);

            

Reported by PMD.

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

Line: 12

              
public class UUIDTest extends TestCase {

    public void test_timezone() throws Exception {
        UUID id = UUID.randomUUID();
        
        String text = JSON.toJSONString(id);
        
        System.out.println(text);

            

Reported by PMD.

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

Line: 19

                      
        System.out.println(text);

        Assert.assertEquals(JSON.toJSONString(id.toString()), text);
     
        UUID id2 = JSON.parseObject(text,  UUID.class);
        Assert.assertEquals(id, id2);
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/JSONSerializerTest3.java
3 issues
JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 15

              import junit.framework.TestCase;

public class JSONSerializerTest3 extends TestCase {
    protected void setUp() throws Exception {
        JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
        JSON.defaultLocale = Locale.CHINA;
    }
    
    public void test_0() throws Exception {

            

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

                      JSON.defaultLocale = Locale.CHINA;
    }
    
    public void test_0() throws Exception {
        JSONSerializer serializer = new JSONSerializer();

        serializer.setDateFormat("yyyy");
        Assert.assertEquals("yyyy", ((SimpleDateFormat) serializer.getDateFormat()).toPattern());
        Assert.assertEquals("yyyy",  serializer.getDateFormatPattern());

            

Reported by PMD.

When instantiating a SimpleDateFormat object, specify a Locale
Error

Line: 30

                      serializer.setDateFormat("yyyy-MM");
        Assert.assertEquals("yyyy-MM", ((SimpleDateFormat) serializer.getDateFormat()).toPattern());
        
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        format.setTimeZone(JSON.defaultTimeZone);
        serializer.setDateFormat(format);
        Assert.assertEquals("yyyy-MM-dd",  serializer.getDateFormatPattern());
        
        serializer.close();

            

Reported by PMD.