The following issues were found

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

Line: 21

                      
        Color color = Color.RED;
        String text = JSON.toJSONString(color);
        System.out.println(text);
        
        Color color2 = JSON.parseObject(text, Color.class);
        
        Assert.assertEquals(color, color2);
    }

            

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

              

public class ColorTest extends TestCase {
    public void test_color() throws Exception {
        JSONSerializer serializer = new JSONSerializer();
        Assert.assertEquals(AwtCodec.class, serializer.getObjectWriter(Color.class).getClass());
        
        Color color = Color.RED;
        String text = JSON.toJSONString(color);

            

Reported by PMD.

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

Line: 17

              public class ColorTest extends TestCase {
    public void test_color() throws Exception {
        JSONSerializer serializer = new JSONSerializer();
        Assert.assertEquals(AwtCodec.class, serializer.getObjectWriter(Color.class).getClass());
        
        Color color = Color.RED;
        String text = JSON.toJSONString(color);
        System.out.println(text);
        

            

Reported by PMD.

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

Line: 22

                      
        Color color = Color.RED;
        String text = JSON.toJSONString(color, SerializerFeature.WriteClassName);
        System.out.println(text);
        
        Color color2 = (Color) JSON.parse(text);
        
        Assert.assertEquals(color, color2);
    }

            

Reported by PMD.

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

Line: 16

              

public class ColorTest2 extends TestCase {
    public void test_color() throws Exception {
        JSONSerializer serializer = new JSONSerializer();
        Assert.assertEquals(AwtCodec.class, serializer.getObjectWriter(Color.class).getClass());
        
        Color color = Color.RED;
        String text = JSON.toJSONString(color, SerializerFeature.WriteClassName);

            

Reported by PMD.

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

Line: 18

              public class ColorTest2 extends TestCase {
    public void test_color() throws Exception {
        JSONSerializer serializer = new JSONSerializer();
        Assert.assertEquals(AwtCodec.class, serializer.getObjectWriter(Color.class).getClass());
        
        Color color = Color.RED;
        String text = JSON.toJSONString(color, SerializerFeature.WriteClassName);
        System.out.println(text);
        

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/awt/FontTest.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

              
public class FontTest extends TestCase {

    public void test_color() throws Exception {
        Font[] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
        for (Font font : fonts) {
            String text = JSON.toJSONString(font);

            Font font2 = JSON.parseObject(text, Font.class);

            

Reported by PMD.

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

Line: 13

              public class FontTest extends TestCase {

    public void test_color() throws Exception {
        Font[] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
        for (Font font : fonts) {
            String text = JSON.toJSONString(font);

            Font font2 = JSON.parseObject(text, Font.class);


            

Reported by PMD.

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

Line: 13

              public class FontTest extends TestCase {

    public void test_color() throws Exception {
        Font[] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
        for (Font font : fonts) {
            String text = JSON.toJSONString(font);

            Font font2 = JSON.parseObject(text, Font.class);


            

Reported by PMD.

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

    public void test_color() throws Exception {
        Font[] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
        for (Font font : fonts) {
            String text = JSON.toJSONString(font, SerializerFeature.WriteClassName);

            Font font2 = (Font) JSON.parse(text);

            

Reported by PMD.

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

Line: 14

              public class FontTest2 extends TestCase {

    public void test_color() throws Exception {
        Font[] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
        for (Font font : fonts) {
            String text = JSON.toJSONString(font, SerializerFeature.WriteClassName);

            Font font2 = (Font) JSON.parse(text);


            

Reported by PMD.

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

Line: 14

              public class FontTest2 extends TestCase {

    public void test_color() throws Exception {
        Font[] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
        for (Font font : fonts) {
            String text = JSON.toJSONString(font, SerializerFeature.WriteClassName);

            Font font2 = (Font) JSON.parse(text);


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Issue952.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: 14

               * Created by wenshao on 19/12/2016.
 */
public class Issue952 extends TestCase {
    public void test_for_issue() throws Exception {
        final String pattern = "yyyy-MM-dd'T'HH:mm:ss";

        LocalDateTime dateTime = LocalDateTime.now();

        DateTimeFormatter formatter   = DateTimeFormatter.ofPattern(pattern);

            

Reported by PMD.

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

Line: 22

                      DateTimeFormatter formatter   = DateTimeFormatter.ofPattern(pattern);

        String text = JSON.toJSONString(dateTime, SerializerFeature.UseISO8601DateFormat);
        assertEquals(JSON.toJSONString(formatter.format(dateTime)), text);
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

                      DateTimeFormatter formatter   = DateTimeFormatter.ofPattern(pattern);

        String text = JSON.toJSONString(dateTime, SerializerFeature.UseISO8601DateFormat);
        assertEquals(JSON.toJSONString(formatter.format(dateTime)), text);
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/fastjson/deserializer/issues3796/bean/ObjectS1.java
3 issues
The class 'ObjectS1' is suspected to be a Data Class (WOC=0.000%, NOPA=0, NOAM=22, WMC=22)
Design

Line: 10

              import java.util.List;


public class ObjectS1 {
	
	private int a;

	
	private int b;

            

Reported by PMD.

Avoid using redundant field initializer for 'c'
Performance

Line: 18

              	private int b;

	
	private int c = 0;

	
	private int d;

	

            

Reported by PMD.

Avoid using redundant field initializer for 'g'
Performance

Line: 30

              	private List<ObjectS1_A> f;

	
	private boolean g = false;

	
	private List<ObjectK> h;

	

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/basicType/LongTest.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: 14

              import junit.framework.TestCase;

public class LongTest extends TestCase {
    public void test_array() throws Exception {
        long[] values = new long[] {Long.MIN_VALUE, -1, 0, 1, Long.MAX_VALUE};
        String text = JSON.toJSONString(values);
        long[] values_2 = JSON.parseObject(text, long[].class);
        Assert.assertEquals(values_2.length, values.length);
        for (int i = 0; i < values.length; ++i) {

            

Reported by PMD.

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

Line: 24

                      }
    }
    
    public void test_map() throws Exception {
        long[] values = new long[] {Long.MIN_VALUE, -1, 0, 1, Long.MAX_VALUE};
        Map<String, Object> map = new HashMap<String, Object>();
        for (int i = 0; i < values.length; ++i) {
            map.put(Long.toString(i), values[i]);
        }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'obj' (lines '32'-'36').
Error

Line: 32

                      }
        
        String text = JSON.toJSONString(map);
        JSONObject obj = JSON.parseObject(text);
        for (int i = 0; i < values.length; ++i) {
            Assert.assertEquals(values[i], ((Number) obj.get(Long.toString(i))).longValue());
        }
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/fastjson/deserializer/issues3796/bean/ObjectP1.java
3 issues
The class 'ObjectP1' is suspected to be a Data Class (WOC=0.000%, NOPA=0, NOAM=20, WMC=20)
Design

Line: 9

              import java.util.List;


public class ObjectP1 {
    
    private int a;
    
    private int b;
    

            

Reported by PMD.

Avoid using redundant field initializer for 'e'
Performance

Line: 19

                  
    private List<Long> d;
    
    private int e = 0;
    
    private int f = 0;
    
    private List<ObjectP1_A> g;
    

            

Reported by PMD.

Avoid using redundant field initializer for 'f'
Performance

Line: 21

                  
    private int e = 0;
    
    private int f = 0;
    
    private List<ObjectP1_A> g;
    
    private List<Integer> h;
    

            

Reported by PMD.

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

Line: 12

                  public void test_bug11() throws Exception {
        String text = "[{KH:\"(2010-2011-2)-13105-13039-1\", JC:\"1\"}] ";
        JSON.parse(text);
        System.out.println(text);
    }
}

            

Reported by PMD.

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

Line: 9

              
public class Bug11 extends TestCase {

    public void test_bug11() throws Exception {
        String text = "[{KH:\"(2010-2011-2)-13105-13039-1\", JC:\"1\"}] ";
        JSON.parse(text);
        System.out.println(text);
    }
}

            

Reported by PMD.

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

Line: 9

              
public class Bug11 extends TestCase {

    public void test_bug11() throws Exception {
        String text = "[{KH:\"(2010-2011-2)-13105-13039-1\", JC:\"1\"}] ";
        JSON.parse(text);
        System.out.println(text);
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_8.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

              
public class Bug_8 extends TestCase {

    public void test_0() throws Exception {
        List<String> typeList = JSONArray.parseArray("['java.lang.Class','java.lang.Long']", String.class);
        Assert.assertEquals("java.lang.Class", typeList.get(0));
        Assert.assertEquals("java.lang.Long", typeList.get(1));
    }
}

            

Reported by PMD.

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

Line: 14

              
    public void test_0() throws Exception {
        List<String> typeList = JSONArray.parseArray("['java.lang.Class','java.lang.Long']", String.class);
        Assert.assertEquals("java.lang.Class", typeList.get(0));
        Assert.assertEquals("java.lang.Long", typeList.get(1));
    }
}

            

Reported by PMD.

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

Line: 15

                  public void test_0() throws Exception {
        List<String> typeList = JSONArray.parseArray("['java.lang.Class','java.lang.Long']", String.class);
        Assert.assertEquals("java.lang.Class", typeList.get(0));
        Assert.assertEquals("java.lang.Long", typeList.get(1));
    }
}

            

Reported by PMD.