The following issues were found

src/test/java/com/alibaba/json/bvt/parser/stream/JSONReaderTest.java
4 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

              import com.alibaba.fastjson.JSONReader;

public class JSONReaderTest extends TestCase {
	public void test_read() throws Exception {
		String resource = "2.json";
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
         
		JSONReader reader = new JSONReader(new InputStreamReader(is, "UTF-8"));
		

            

Reported by PMD.

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

Line: 17

              public class JSONReaderTest extends TestCase {
	public void test_read() throws Exception {
		String resource = "2.json";
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
         
		JSONReader reader = new JSONReader(new InputStreamReader(is, "UTF-8"));
		
		reader.startObject();
		

            

Reported by PMD.

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

Line: 17

              public class JSONReaderTest extends TestCase {
	public void test_read() throws Exception {
		String resource = "2.json";
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
         
		JSONReader reader = new JSONReader(new InputStreamReader(is, "UTF-8"));
		
		reader.startObject();
		

            

Reported by PMD.

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

Line: 17

              public class JSONReaderTest extends TestCase {
	public void test_read() throws Exception {
		String resource = "2.json";
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
         
		JSONReader reader = new JSONReader(new InputStreamReader(is, "UTF-8"));
		
		reader.startObject();
		

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/writeAsArray/WriteAsArray_0_private.java
4 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 com.alibaba.fastjson.serializer.SerializerFeature;

public class WriteAsArray_0_private extends TestCase {
    public void test_0 () throws Exception {
        VO vo = new VO();
        vo.setId(123);
        vo.setName("wenshao");
        
        String text = JSON.toJSONString(vo, SerializerFeature.BeanToArray);

            

Reported by PMD.

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

Line: 20

                      String text = JSON.toJSONString(vo, SerializerFeature.BeanToArray);
        Assert.assertEquals("[123,\"wenshao\"]", text);
        VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
        Assert.assertEquals(vo.getId(), vo2.getId());
        Assert.assertEquals(vo.getName(), vo2.getName());
    }
    
    private static class VO {
        private int id;

            

Reported by PMD.

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

Line: 21

                      Assert.assertEquals("[123,\"wenshao\"]", text);
        VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
        Assert.assertEquals(vo.getId(), vo2.getId());
        Assert.assertEquals(vo.getName(), vo2.getName());
    }
    
    private static class VO {
        private int id;
        private String name;

            

Reported by PMD.

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

Line: 24

                      Assert.assertEquals(vo.getName(), vo2.getName());
    }
    
    private static class VO {
        private int id;
        private String name;

        public int getId() {
            return id;

            

Reported by PMD.

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

              
public class TestSpecial_4 extends TestCase {

    public void test_special() throws Exception {
        String json = "{\"大小\":123}";
        JSONObject object = JSON.parseObject(json);
        Object obj = JSONPath.eval(object, "$.大小");
        assertEquals(123, obj);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                      String json = "{\"大小\":123}";
        JSONObject object = JSON.parseObject(json);
        Object obj = JSONPath.eval(object, "$.大小");
        assertEquals(123, obj);
    }

}

            

Reported by PMD.

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

Line: 4

              package com.alibaba.json.bvt.path;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPath;
import com.alibaba.fastjson.parser.Feature;
import junit.framework.TestCase;


            

Reported by PMD.

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

Line: 7

              import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPath;
import com.alibaba.fastjson.parser.Feature;
import junit.framework.TestCase;

public class TestSpecial_4 extends TestCase {

    public void test_special() throws Exception {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/ref/RefTest.java
4 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 RefTest extends TestCase {
    
    public void test_ref() throws Exception {
        JSONSerializer ser = new JSONSerializer();
        Assert.assertFalse(ser.containsReference(null));
    }
    
    public void test_array_ref() 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: 18

                      Assert.assertFalse(ser.containsReference(null));
    }
    
    public void test_array_ref() throws Exception {
        JSON.toJSONString(new A[] {new A()}, SerializerFeature.DisableCircularReferenceDetect);
    }

    public class A {


            

Reported by PMD.

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

Line: 18

                      Assert.assertFalse(ser.containsReference(null));
    }
    
    public void test_array_ref() throws Exception {
        JSON.toJSONString(new A[] {new A()}, SerializerFeature.DisableCircularReferenceDetect);
    }

    public class A {


            

Reported by PMD.

It is somewhat confusing to have a field name matching the declaring class name
Error

Line: 24

              
    public class A {

        private A a;

        public A getA() {
            return a;
        }


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/stream/JSONReaderTest_4.java
4 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 JSONReaderTest_4 extends TestCase {

    public void test_read_Long() throws Exception {
        String text = "1001";
        JSONReader reader = new JSONReader(new MyReader(text));

    }


            

Reported by PMD.

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

Line: 13

              
public class JSONReaderTest_4 extends TestCase {

    public void test_read_Long() throws Exception {
        String text = "1001";
        JSONReader reader = new JSONReader(new MyReader(text));

    }


            

Reported by PMD.

Avoid unused local variables such as 'reader'.
Design

Line: 15

              
    public void test_read_Long() throws Exception {
        String text = "1001";
        JSONReader reader = new JSONReader(new MyReader(text));

    }

    public static class MyReader extends BufferedReader {


            

Reported by PMD.

Found 'DU'-anomaly for variable 'reader' (lines '15'-'17').
Error

Line: 15

              
    public void test_read_Long() throws Exception {
        String text = "1001";
        JSONReader reader = new JSONReader(new MyReader(text));

    }

    public static class MyReader extends BufferedReader {


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/generic/GenericTest3.java
4 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 12

              
public class GenericTest3 extends TestCase {
	public static class A<T> {
		public B<T> b;
	}

	public static class B<T> {
		public T value;
	}

            

Reported by PMD.

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

Line: 16

              	}

	public static class B<T> {
		public T value;
	}

	public static class ValueObject {
		public String property1;
		public int property2;

            

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

              		public int property2;
	}

	public void test_generic() throws Exception {
		A<ValueObject> object = JSON.parseObject(
				"{b:{value:{property1:'string',property2:123}}}",
				new TypeReference<A<ValueObject>>() {
				});
		

            

Reported by PMD.

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

Line: 30

              				new TypeReference<A<ValueObject>>() {
				});
		
		Assert.assertEquals(ValueObject.class, object.b.value.getClass());
	}
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/ref/RefTest18.java
4 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 RefTest18 extends TestCase {
    public void test_array() throws Exception {
        String text = "{\"b\":{},\"a\":[{\"$ref\":\"$.b\"}]}";
        
        JSONObject obj = JSON.parseObject(text);
        JSONArray array = obj.getJSONArray("a");
        Assert.assertEquals(1, array.size());

            

Reported by PMD.

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

Line: 16

                      String text = "{\"b\":{},\"a\":[{\"$ref\":\"$.b\"}]}";
        
        JSONObject obj = JSON.parseObject(text);
        JSONArray array = obj.getJSONArray("a");
        Assert.assertEquals(1, array.size());
        Assert.assertNotNull(array.get(0));
    }
}

            

Reported by PMD.

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

Line: 17

                      
        JSONObject obj = JSON.parseObject(text);
        JSONArray array = obj.getJSONArray("a");
        Assert.assertEquals(1, array.size());
        Assert.assertNotNull(array.get(0));
    }
}

            

Reported by PMD.

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

Line: 18

                      JSONObject obj = JSON.parseObject(text);
        JSONArray array = obj.getJSONArray("a");
        Assert.assertEquals(1, array.size());
        Assert.assertNotNull(array.get(0));
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/ref/RefTest21.java
4 issues
System.out.println is used
Design

Line: 15

                  public void test_ref() throws Exception {
        String jsonTest = "{\"details\":{\"type\":{\"items\":{\"allOf\":[{\"$ref\":\"title\",\"required\":[\"iconImg\"]}]}}}}";
        JSONObject object = JSON.parseObject(jsonTest, Feature.DisableSpecialKeyDetect);
        System.out.println( object.get( "details"));
    }
}

            

Reported by PMD.

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

Line: 12

               * Created by wenshao on 16/8/23.
 */
public class RefTest21 extends TestCase {
    public void test_ref() throws Exception {
        String jsonTest = "{\"details\":{\"type\":{\"items\":{\"allOf\":[{\"$ref\":\"title\",\"required\":[\"iconImg\"]}]}}}}";
        JSONObject object = JSON.parseObject(jsonTest, Feature.DisableSpecialKeyDetect);
        System.out.println( object.get( "details"));
    }
}

            

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 16/8/23.
 */
public class RefTest21 extends TestCase {
    public void test_ref() throws Exception {
        String jsonTest = "{\"details\":{\"type\":{\"items\":{\"allOf\":[{\"$ref\":\"title\",\"required\":[\"iconImg\"]}]}}}}";
        JSONObject object = JSON.parseObject(jsonTest, Feature.DisableSpecialKeyDetect);
        System.out.println( object.get( "details"));
    }
}

            

Reported by PMD.

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

Line: 15

                  public void test_ref() throws Exception {
        String jsonTest = "{\"details\":{\"type\":{\"items\":{\"allOf\":[{\"$ref\":\"title\",\"required\":[\"iconImg\"]}]}}}}";
        JSONObject object = JSON.parseObject(jsonTest, Feature.DisableSpecialKeyDetect);
        System.out.println( object.get( "details"));
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/ref/RefTest6.java
4 issues
System.out.println is used
Design

Line: 29

                      jsonObject.put("c", c);

        String text = JSON.toJSONString(jsonObject, SerializerFeature.PrettyFormat);
        System.out.println(text);
    }

    private class A {

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

                   * 
     * @throws Exception
     */
    public void test_0() throws Exception {
        A a = new A();
        B b = new B();
        C c = new C();
        a.setB(b);
        b.setC(c);

            

Reported by PMD.

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

Line: 16

                   * 
     * @throws Exception
     */
    public void test_0() throws Exception {
        A a = new A();
        B b = new B();
        C c = new C();
        a.setB(b);
        b.setC(c);

            

Reported by PMD.

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

Line: 45

                      }
    }

    private class B {

        private C c;
        private A a;

        public C getC() {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/error/ParseErrorTest_date.java
4 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 ParseErrorTest_date extends TestCase {

    public void test_for_error() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"2011-01-09M\"}", 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: 24

                      Assert.assertNotNull(error);
    }
    
    public void test_for_error_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"2011-01-09", Model.class);
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '15'-'19').
Error

Line: 15

              public class ParseErrorTest_date extends TestCase {

    public void test_for_error() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"2011-01-09M\"}", Model.class);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '25'-'29').
Error

Line: 25

                  }
    
    public void test_for_error_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"2011-01-09", Model.class);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.