The following issues were found

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

Line: 22

                      image.setTitle("xx");
        
        String text = JSON.toJSONString(image, SerializerFeature.BeanToArray);
        System.out.println(text);
        
        Image image2 = JSON.parseObject(text, Image.class, Feature.SupportArrayToBean);
        Assert.assertEquals(image.getHeight(), image2.getHeight());
        Assert.assertEquals(image.getWidth(), image2.getWidth());
        Assert.assertEquals(image.getSize(), image2.getSize());

            

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

              import data.media.Image.Size;

public class WriteAsArray_Eishay_Image extends TestCase {
    public void test_0 () throws Exception {
        Image image = new Image();
        image.setHeight(123);
        image.setSize(Size.LARGE);
        image.setTitle("xx");
        

            

Reported by PMD.

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

Line: 25

                      System.out.println(text);
        
        Image image2 = JSON.parseObject(text, Image.class, Feature.SupportArrayToBean);
        Assert.assertEquals(image.getHeight(), image2.getHeight());
        Assert.assertEquals(image.getWidth(), image2.getWidth());
        Assert.assertEquals(image.getSize(), image2.getSize());
        Assert.assertEquals(image.getTitle(), image2.getTitle());
        Assert.assertEquals(image.getUri(), image2.getUri());
    }

            

Reported by PMD.

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

Line: 26

                      
        Image image2 = JSON.parseObject(text, Image.class, Feature.SupportArrayToBean);
        Assert.assertEquals(image.getHeight(), image2.getHeight());
        Assert.assertEquals(image.getWidth(), image2.getWidth());
        Assert.assertEquals(image.getSize(), image2.getSize());
        Assert.assertEquals(image.getTitle(), image2.getTitle());
        Assert.assertEquals(image.getUri(), image2.getUri());
    }
    

            

Reported by PMD.

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

Line: 27

                      Image image2 = JSON.parseObject(text, Image.class, Feature.SupportArrayToBean);
        Assert.assertEquals(image.getHeight(), image2.getHeight());
        Assert.assertEquals(image.getWidth(), image2.getWidth());
        Assert.assertEquals(image.getSize(), image2.getSize());
        Assert.assertEquals(image.getTitle(), image2.getTitle());
        Assert.assertEquals(image.getUri(), image2.getUri());
    }
    
}

            

Reported by PMD.

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

Line: 28

                      Assert.assertEquals(image.getHeight(), image2.getHeight());
        Assert.assertEquals(image.getWidth(), image2.getWidth());
        Assert.assertEquals(image.getSize(), image2.getSize());
        Assert.assertEquals(image.getTitle(), image2.getTitle());
        Assert.assertEquals(image.getUri(), image2.getUri());
    }
    
}

            

Reported by PMD.

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

Line: 29

                      Assert.assertEquals(image.getWidth(), image2.getWidth());
        Assert.assertEquals(image.getSize(), image2.getSize());
        Assert.assertEquals(image.getTitle(), image2.getTitle());
        Assert.assertEquals(image.getUri(), image2.getUri());
    }
    
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/ClobSerializerTest.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: 19

              import com.alibaba.fastjson.serializer.SerializerFeature;

public class ClobSerializerTest extends TestCase {
	public void test_clob() throws Exception {
		Assert.assertEquals("\"abcdefg中国\"",
				JSON.toJSONString(new MockClob("abcdefg中国")));
	}

	public void test_clob_null() 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: 24

              				JSON.toJSONString(new MockClob("abcdefg中国")));
	}

	public void test_clob_null() throws Exception {
		Assert.assertEquals("{\"value\":null}", JSON.toJSONString(new VO(),
				SerializerFeature.WriteMapNullValue));
	}

	public void test_clob_error() 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: 29

              				SerializerFeature.WriteMapNullValue));
	}

	public void test_clob_error() throws Exception {
		Exception error = null;
		try {
			JSON.toJSONString(new MockClob(new SQLException()));
		} catch (Exception ex) {
			error = ex;

            

Reported by PMD.

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

Line: 33

              		Exception error = null;
		try {
			JSON.toJSONString(new MockClob(new SQLException()));
		} catch (Exception ex) {
			error = ex;
		}
		Assert.assertNotNull(error);
	}


            

Reported by PMD.

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

Line: 53

              	}

	public static class MockClob implements Clob {
		private final String text;

		private SQLException error;

		public MockClob(String text) {
			this.text = text;

            

Reported by PMD.

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

Line: 62

              		}

		public MockClob(SQLException error) {
			this.text = null;
			this.error = error;
		}

		public SQLException getError() {
			return error;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '30'-'34').
Error

Line: 30

              	}

	public void test_clob_error() throws Exception {
		Exception error = null;
		try {
			JSON.toJSONString(new MockClob(new SQLException()));
		} catch (Exception ex) {
			error = ex;
		}

            

Reported by PMD.

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

Line: 20

                      map.put("b", "1");

        String x = JSON.toJSONString(map, SerializerFeature.WriteMapNullValue);
        System.out.println(x);

        JSONObject jsonObject = JSON.parseObject(x);
        System.out.println(JSONPath.contains(jsonObject, "$.a") + "\t" + jsonObject.containsKey("a"));
        System.out.println(JSONPath.contains(jsonObject, "$.b") + "\t" + jsonObject.containsKey("b"));
    }

            

Reported by PMD.

System.out.println is used
Design

Line: 23

                      System.out.println(x);

        JSONObject jsonObject = JSON.parseObject(x);
        System.out.println(JSONPath.contains(jsonObject, "$.a") + "\t" + jsonObject.containsKey("a"));
        System.out.println(JSONPath.contains(jsonObject, "$.b") + "\t" + jsonObject.containsKey("b"));
    }
}

            

Reported by PMD.

System.out.println is used
Design

Line: 24

              
        JSONObject jsonObject = JSON.parseObject(x);
        System.out.println(JSONPath.contains(jsonObject, "$.a") + "\t" + jsonObject.containsKey("a"));
        System.out.println(JSONPath.contains(jsonObject, "$.b") + "\t" + jsonObject.containsKey("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: 14

              import junit.framework.TestCase;

public class JSONPath_conatinas_null extends TestCase {
    public void test_null() throws Exception {
        Map<String, String> map = new HashMap<String, String>();
        map.put("a", null);
        map.put("b", "1");

        String x = JSON.toJSONString(map, SerializerFeature.WriteMapNullValue);

            

Reported by PMD.

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

Line: 14

              import junit.framework.TestCase;

public class JSONPath_conatinas_null extends TestCase {
    public void test_null() throws Exception {
        Map<String, String> map = new HashMap<String, String>();
        map.put("a", null);
        map.put("b", "1");

        String x = JSON.toJSONString(map, SerializerFeature.WriteMapNullValue);

            

Reported by PMD.

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

Line: 23

                      System.out.println(x);

        JSONObject jsonObject = JSON.parseObject(x);
        System.out.println(JSONPath.contains(jsonObject, "$.a") + "\t" + jsonObject.containsKey("a"));
        System.out.println(JSONPath.contains(jsonObject, "$.b") + "\t" + jsonObject.containsKey("b"));
    }
}

            

Reported by PMD.

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

Line: 24

              
        JSONObject jsonObject = JSON.parseObject(x);
        System.out.println(JSONPath.contains(jsonObject, "$.a") + "\t" + jsonObject.containsKey("a"));
        System.out.println(JSONPath.contains(jsonObject, "$.b") + "\t" + jsonObject.containsKey("b"));
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/TimeDeserializerTest.java
7 issues
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 TimeDeserializerTest extends TestCase {
    protected void setUp() throws Exception {
        JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
        JSON.defaultLocale = Locale.CHINA;
    }
    
    public void test_time() 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_time() throws Exception {
        long millis = System.currentTimeMillis();
        
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", JSON.defaultLocale);
        format.setTimeZone(JSON.defaultTimeZone);
        String text = format.format(new java.util.Date(millis));

            

Reported by PMD.

Prefer StringBuilder (non-synchronized) or StringBuffer (synchronized) over += for concatenating strings
Performance

Line: 30

                      
        SimpleDateFormat format2 = new SimpleDateFormat("HH:mm:ss.SSS", JSON.defaultLocale);
        format2.setTimeZone(JSON.defaultTimeZone);
        text += format2.format(new java.util.Date(millis));
        
        Assert.assertNull(JSON.parseObject("null", Time.class));
        Assert.assertNull(JSON.parseObject("\"\"", Time.class));
        Assert.assertNull(JSON.parseArray("null", Time.class));
        Assert.assertNull(JSON.parseArray("[null]", Time.class).get(0));

            

Reported by PMD.

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

Line: 35

                      Assert.assertNull(JSON.parseObject("null", Time.class));
        Assert.assertNull(JSON.parseObject("\"\"", Time.class));
        Assert.assertNull(JSON.parseArray("null", Time.class));
        Assert.assertNull(JSON.parseArray("[null]", Time.class).get(0));
        Assert.assertNull(JSON.parseObject("{\"value\":null}", VO.class).getValue());
        
        Assert.assertEquals(new Time(millis), JSON.parseObject("" + millis, Time.class));
        Assert.assertEquals(new Time(millis), JSON.parseObject("{\"@type\":\"java.sql.Time\",\"val\":" + millis + "}", Time.class));
        Assert.assertEquals(new Time(millis), JSON.parseObject("\"" + millis + "\"", Time.class));

            

Reported by PMD.

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

Line: 36

                      Assert.assertNull(JSON.parseObject("\"\"", Time.class));
        Assert.assertNull(JSON.parseArray("null", Time.class));
        Assert.assertNull(JSON.parseArray("[null]", Time.class).get(0));
        Assert.assertNull(JSON.parseObject("{\"value\":null}", VO.class).getValue());
        
        Assert.assertEquals(new Time(millis), JSON.parseObject("" + millis, Time.class));
        Assert.assertEquals(new Time(millis), JSON.parseObject("{\"@type\":\"java.sql.Time\",\"val\":" + millis + "}", Time.class));
        Assert.assertEquals(new Time(millis), JSON.parseObject("\"" + millis + "\"", Time.class));
        Assert.assertEquals(new Time(millis), JSON.parseObject("\"" + text + "\"", Time.class));

            

Reported by PMD.

Do not add empty strings
Performance

Line: 38

                      Assert.assertNull(JSON.parseArray("[null]", Time.class).get(0));
        Assert.assertNull(JSON.parseObject("{\"value\":null}", VO.class).getValue());
        
        Assert.assertEquals(new Time(millis), JSON.parseObject("" + millis, Time.class));
        Assert.assertEquals(new Time(millis), JSON.parseObject("{\"@type\":\"java.sql.Time\",\"val\":" + millis + "}", Time.class));
        Assert.assertEquals(new Time(millis), JSON.parseObject("\"" + millis + "\"", Time.class));
        Assert.assertEquals(new Time(millis), JSON.parseObject("\"" + text + "\"", Time.class));
        
        //System.out.println(JSON.toJSONString(new Time(millis), SerializerFeature.WriteClassName));

            

Reported by PMD.

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

Line: 12

              import junit.framework.TestCase;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;

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

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/DoubleDeserializerTest.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: 15

              
public class DoubleDeserializerTest extends TestCase {

    public void test_bigdecimal() throws Exception {
        Assert.assertEquals(0, JSON.parseObject("0", Double.class).intValue());
        Assert.assertEquals(0, JSON.parseObject("0.0", Double.class).intValue());
        Assert.assertEquals(0, JSON.parseObject("'0'", Double.class).intValue());
        Assert.assertEquals(0, JSON.parseObject("'0'", double.class).intValue());
        Assert.assertEquals(null, JSON.parseObject("null", Double.class));

            

Reported by PMD.

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

Line: 16

              public class DoubleDeserializerTest extends TestCase {

    public void test_bigdecimal() throws Exception {
        Assert.assertEquals(0, JSON.parseObject("0", Double.class).intValue());
        Assert.assertEquals(0, JSON.parseObject("0.0", Double.class).intValue());
        Assert.assertEquals(0, JSON.parseObject("'0'", Double.class).intValue());
        Assert.assertEquals(0, JSON.parseObject("'0'", double.class).intValue());
        Assert.assertEquals(null, JSON.parseObject("null", Double.class));


            

Reported by PMD.

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

Line: 17

              
    public void test_bigdecimal() throws Exception {
        Assert.assertEquals(0, JSON.parseObject("0", Double.class).intValue());
        Assert.assertEquals(0, JSON.parseObject("0.0", Double.class).intValue());
        Assert.assertEquals(0, JSON.parseObject("'0'", Double.class).intValue());
        Assert.assertEquals(0, JSON.parseObject("'0'", double.class).intValue());
        Assert.assertEquals(null, JSON.parseObject("null", Double.class));

        DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);

            

Reported by PMD.

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

Line: 18

                  public void test_bigdecimal() throws Exception {
        Assert.assertEquals(0, JSON.parseObject("0", Double.class).intValue());
        Assert.assertEquals(0, JSON.parseObject("0.0", Double.class).intValue());
        Assert.assertEquals(0, JSON.parseObject("'0'", Double.class).intValue());
        Assert.assertEquals(0, JSON.parseObject("'0'", double.class).intValue());
        Assert.assertEquals(null, JSON.parseObject("null", Double.class));

        DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
        Assert.assertEquals(null, NumberDeserializer.instance.deserialze(parser, null, null));

            

Reported by PMD.

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

Line: 19

                      Assert.assertEquals(0, JSON.parseObject("0", Double.class).intValue());
        Assert.assertEquals(0, JSON.parseObject("0.0", Double.class).intValue());
        Assert.assertEquals(0, JSON.parseObject("'0'", Double.class).intValue());
        Assert.assertEquals(0, JSON.parseObject("'0'", double.class).intValue());
        Assert.assertEquals(null, JSON.parseObject("null", Double.class));

        DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
        Assert.assertEquals(null, NumberDeserializer.instance.deserialze(parser, null, null));
        Assert.assertEquals(JSONToken.LITERAL_INT, NumberDeserializer.instance.getFastMatchToken());

            

Reported by PMD.

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

Line: 23

                      Assert.assertEquals(null, JSON.parseObject("null", Double.class));

        DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
        Assert.assertEquals(null, NumberDeserializer.instance.deserialze(parser, null, null));
        Assert.assertEquals(JSONToken.LITERAL_INT, NumberDeserializer.instance.getFastMatchToken());
    }
}


            

Reported by PMD.

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

Line: 24

              
        DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
        Assert.assertEquals(null, NumberDeserializer.instance.deserialze(parser, null, null));
        Assert.assertEquals(JSONToken.LITERAL_INT, NumberDeserializer.instance.getFastMatchToken());
    }
}


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/path/JSONPath_list_size_3.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: 10

              import junit.framework.TestCase;

public class JSONPath_list_size_3 extends TestCase {
    public void test_java_bean() throws Exception {
        Model model = new Model();
        model.id = 1001;
        model.name = "wenshao";
        JSONPath path = new JSONPath("$.size()");
        Integer result = (Integer) path.eval(model);

            

Reported by PMD.

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

Line: 16

                      model.name = "wenshao";
        JSONPath path = new JSONPath("$.size()");
        Integer result = (Integer) path.eval(model);
        Assert.assertEquals(2, result.intValue());
    }
    
    public void test_java_bean_field_null() throws Exception {
        Model model = new Model();
        model.id = 1001;

            

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(2, result.intValue());
    }
    
    public void test_java_bean_field_null() throws Exception {
        Model model = new Model();
        model.id = 1001;
        model.name = null;
        JSONPath path = new JSONPath("$.size()");
        Integer result = (Integer) path.eval(model);

            

Reported by PMD.

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

Line: 22

                  public void test_java_bean_field_null() throws Exception {
        Model model = new Model();
        model.id = 1001;
        model.name = null;
        JSONPath path = new JSONPath("$.size()");
        Integer result = (Integer) path.eval(model);
        Assert.assertEquals(1, result.intValue());
    }
    

            

Reported by PMD.

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

Line: 25

                      model.name = null;
        JSONPath path = new JSONPath("$.size()");
        Integer result = (Integer) path.eval(model);
        Assert.assertEquals(1, result.intValue());
    }
    
    public static class Model {
        public int id;
        public String name;

            

Reported by PMD.

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

Line: 29

                  }
    
    public static class Model {
        public int id;
        public String name;
    }
}

            

Reported by PMD.

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

Line: 30

                  
    public static class Model {
        public int id;
        public String name;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/InnerClassDeser2.java
7 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 12

               * Created by wenshao on 25/03/2017.
 */
public class InnerClassDeser2 extends TestCase {
    public void test_for_inner_class() throws Exception {
        Model model = JSON.parseObject("{\"items\":[{\"id\":123}]}", Model.class);
        assertNotNull(model.items);
        assertEquals(123, model.items.get(0).id);
    }


            

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

               * Created by wenshao on 25/03/2017.
 */
public class InnerClassDeser2 extends TestCase {
    public void test_for_inner_class() throws Exception {
        Model model = JSON.parseObject("{\"items\":[{\"id\":123}]}", Model.class);
        assertNotNull(model.items);
        assertEquals(123, model.items.get(0).id);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

              public class InnerClassDeser2 extends TestCase {
    public void test_for_inner_class() throws Exception {
        Model model = JSON.parseObject("{\"items\":[{\"id\":123}]}", Model.class);
        assertNotNull(model.items);
        assertEquals(123, model.items.get(0).id);
    }

    public static class Model {
        public List<Item> items;

            

Reported by PMD.

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

Line: 15

                  public void test_for_inner_class() throws Exception {
        Model model = JSON.parseObject("{\"items\":[{\"id\":123}]}", Model.class);
        assertNotNull(model.items);
        assertEquals(123, model.items.get(0).id);
    }

    public static class Model {
        public List<Item> items;


            

Reported by PMD.

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

Line: 15

                  public void test_for_inner_class() throws Exception {
        Model model = JSON.parseObject("{\"items\":[{\"id\":123}]}", Model.class);
        assertNotNull(model.items);
        assertEquals(123, model.items.get(0).id);
    }

    public static class Model {
        public List<Item> items;


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 15

                  public void test_for_inner_class() throws Exception {
        Model model = JSON.parseObject("{\"items\":[{\"id\":123}]}", Model.class);
        assertNotNull(model.items);
        assertEquals(123, model.items.get(0).id);
    }

    public static class Model {
        public List<Item> items;


            

Reported by PMD.

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

Line: 19

                  }

    public static class Model {
        public List<Item> items;

        public class Item {
            public int id;
        }
    }

            

Reported by PMD.

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

    public void test_list_map() throws Exception {
        Entity entity = new Entity(123, "wenshao");
        JSONPath path = new JSONPath("$['id','name']");
        
        List<Object> result = (List<Object>) path.eval(entity);
        Assert.assertSame(entity.getId(), result.get(0));

            

Reported by PMD.

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

Line: 18

                      JSONPath path = new JSONPath("$['id','name']");
        
        List<Object> result = (List<Object>) path.eval(entity);
        Assert.assertSame(entity.getId(), result.get(0));
        Assert.assertSame(entity.getName(), result.get(1));
    }

    public void test_list_map2() throws Exception {
        Entity entity = new Entity(123, "wenshao");

            

Reported by PMD.

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

Line: 19

                      
        List<Object> result = (List<Object>) path.eval(entity);
        Assert.assertSame(entity.getId(), result.get(0));
        Assert.assertSame(entity.getName(), result.get(1));
    }

    public void test_list_map2() throws Exception {
        Entity entity = new Entity(123, "wenshao");
        JSONPath path = new JSONPath("$.entity['id','name']");

            

Reported by PMD.

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

Line: 22

                      Assert.assertSame(entity.getName(), result.get(1));
    }

    public void test_list_map2() throws Exception {
        Entity entity = new Entity(123, "wenshao");
        JSONPath path = new JSONPath("$.entity['id','name']");

        Root root = new Root();
        root.setEntity(entity);

            

Reported by PMD.

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

Line: 30

                      root.setEntity(entity);

        List<Object> result = (List<Object>) path.eval(root);
        Assert.assertSame(entity.getId(), result.get(0));
        Assert.assertSame(entity.getName(), result.get(1));
    }

    public static class Entity {


            

Reported by PMD.

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

Line: 31

              
        List<Object> result = (List<Object>) path.eval(root);
        Assert.assertSame(entity.getId(), result.get(0));
        Assert.assertSame(entity.getName(), result.get(1));
    }

    public static class Entity {

        private Integer id;

            

Reported by PMD.

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

Line: 34

                      Assert.assertSame(entity.getName(), result.get(1));
    }

    public static class Entity {

        private Integer id;
        private String  name;

        public Entity(Integer id, String name){

            

Reported by PMD.

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

               */
public class PropertyPathTest extends TestCase {

    public void test_path() throws Exception {
        A a = new A();
        a.setId(123);

        B b = new B();
        b.setId(234);

            

Reported by PMD.

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

Line: 45

                  public static class MyPropertyPreFilter implements PropertyPreFilter {

        public boolean apply(JSONSerializer serializer, Object source, String name) {
            String path = serializer.getContext().toString() + "." + name;

            if (path.startsWith("$.b.d")) {
                return false;
            }


            

Reported by PMD.

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

Line: 47

                      public boolean apply(JSONSerializer serializer, Object source, String name) {
            String path = serializer.getContext().toString() + "." + name;

            if (path.startsWith("$.b.d")) {
                return false;
            }

            return true;
        }

            

Reported by PMD.

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

Line: 47

                      public boolean apply(JSONSerializer serializer, Object source, String name) {
            String path = serializer.getContext().toString() + "." + name;

            if (path.startsWith("$.b.d")) {
                return false;
            }

            return true;
        }

            

Reported by PMD.

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

Line: 56

              
    }

    public static class A {

        private int id;
        private B   b;

        public int getId() {

            

Reported by PMD.

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

Line: 79

              
    }

    public static class B {

        private int id;
        private C   c;
        private D   d;


            

Reported by PMD.

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

Line: 111

              
    }

    public static class C {

        private int    id;
        private String name;

        public int getId() {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/deny/DenyTest9.java
7 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 11

              
public class DenyTest9 extends TestCase {

    public void test_autoTypeDeny() throws Exception {
        ParserConfig config = new ParserConfig();

        assertFalse(config.isAutoTypeSupport());
        config.setAutoTypeSupport(true);
        assertTrue(config.isAutoTypeSupport());

            

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

    public void test_autoTypeDeny() throws Exception {
        ParserConfig config = new ParserConfig();

        assertFalse(config.isAutoTypeSupport());
        config.setAutoTypeSupport(true);
        assertTrue(config.isAutoTypeSupport());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

                  public void test_autoTypeDeny() throws Exception {
        ParserConfig config = new ParserConfig();

        assertFalse(config.isAutoTypeSupport());
        config.setAutoTypeSupport(true);
        assertTrue(config.isAutoTypeSupport());

        Properties properties = new Properties();
        properties.put(ParserConfig.AUTOTYPE_SUPPORT_PROPERTY, "false");

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

              
        assertFalse(config.isAutoTypeSupport());
        config.setAutoTypeSupport(true);
        assertTrue(config.isAutoTypeSupport());

        Properties properties = new Properties();
        properties.put(ParserConfig.AUTOTYPE_SUPPORT_PROPERTY, "false");
        properties.put(ParserConfig.AUTOTYPE_ACCEPT, "com.alibaba.json.bvt.parser.deser.deny.DenyTest9");
        // -ea -Dfastjson.parser.autoTypeAccept=com.alibaba.json.bvt.parser.deser.deny.DenyTest9

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 24

                      // -ea -Dfastjson.parser.autoTypeAccept=com.alibaba.json.bvt.parser.deser.deny.DenyTest9
        config.configFromPropety(properties);

        assertFalse(config.isAutoTypeSupport());


        Object obj = JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.deser.deny.DenyTest9$Model\"}", Object.class, config);
        assertEquals(Model.class, obj.getClass());
    }

            

Reported by PMD.

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

Line: 28

              

        Object obj = JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.deser.deny.DenyTest9$Model\"}", Object.class, config);
        assertEquals(Model.class, obj.getClass());
    }
    
    public static class Model {

    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 28

              

        Object obj = JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.deser.deny.DenyTest9$Model\"}", Object.class, config);
        assertEquals(Model.class, obj.getClass());
    }
    
    public static class Model {

    }

            

Reported by PMD.