The following issues were found

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

Line: 3

              package com.alibaba.fastjson.deserializer.issues3796.bean;

public class ObjectB {
	
	private long a;
	
	private long b;
	
	private long c;

            

Reported by PMD.

Too many fields
Design

Line: 3

              package com.alibaba.fastjson.deserializer.issues3796.bean;

public class ObjectB {
	
	private long a;
	
	private long b;
	
	private long c;

            

Reported by PMD.

Avoid using redundant field initializer for 'k'
Performance

Line: 29

              	private long j;

	
	private long k = 0;

	
	private long l = 0;
	
	private long m = 0;

            

Reported by PMD.

Avoid using redundant field initializer for 'l'
Performance

Line: 32

              	private long k = 0;

	
	private long l = 0;
	
	private long m = 0;

	
	private long n;

            

Reported by PMD.

Avoid using redundant field initializer for 'm'
Performance

Line: 34

              	
	private long l = 0;
	
	private long m = 0;

	
	private long n;

	

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_maiksagill.java
5 issues
JUnit tests should include assert() or fail()
Design

Line: 14

              
public class Bug_for_maiksagill extends TestCase {

    public void test_for_maiksagill() throws Exception {
        String resource = "json/maiksagill.json";
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
        String text = IOUtils.toString(is);
        
        JSON.parseObject(text, WareHouseInfo[].class);

            

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

    public void test_for_maiksagill() throws Exception {
        String resource = "json/maiksagill.json";
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
        String text = IOUtils.toString(is);
        
        JSON.parseObject(text, WareHouseInfo[].class);

            

Reported by PMD.

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

Line: 16

              
    public void test_for_maiksagill() throws Exception {
        String resource = "json/maiksagill.json";
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
        String text = IOUtils.toString(is);
        
        JSON.parseObject(text, WareHouseInfo[].class);
             
    }

            

Reported by PMD.

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

Line: 16

              
    public void test_for_maiksagill() throws Exception {
        String resource = "json/maiksagill.json";
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
        String text = IOUtils.toString(is);
        
        JSON.parseObject(text, WareHouseInfo[].class);
             
    }

            

Reported by PMD.

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

Line: 16

              
    public void test_for_maiksagill() throws Exception {
        String resource = "json/maiksagill.json";
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
        String text = IOUtils.toString(is);
        
        JSON.parseObject(text, WareHouseInfo[].class);
             
    }

            

Reported by PMD.

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

Line: 19

              
        String text = JSON.toJSONString(time);

        System.out.println(text);

        Time time2 = JSON.parseObject(text, Time.class);
        
        Assert.assertEquals(time2.getValue(), time.getValue());
        Assert.assertEquals(time2.getUnit(), time.getUnit());

            

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

    public void test_0() throws Exception {
        Time time = new Time(1000, TimeUnit.MILLISECONDS);

        String text = JSON.toJSONString(time);

        System.out.println(text);

            

Reported by PMD.

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

Line: 23

              
        Time time2 = JSON.parseObject(text, Time.class);
        
        Assert.assertEquals(time2.getValue(), time.getValue());
        Assert.assertEquals(time2.getUnit(), time.getUnit());
    }

    public static class Time {


            

Reported by PMD.

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

Line: 24

                      Time time2 = JSON.parseObject(text, Time.class);
        
        Assert.assertEquals(time2.getValue(), time.getValue());
        Assert.assertEquals(time2.getUnit(), time.getUnit());
    }

    public static class Time {

        private long     value;

            

Reported by PMD.

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

Line: 27

                      Assert.assertEquals(time2.getUnit(), time.getUnit());
    }

    public static class Time {

        private long     value;
        private TimeUnit unit;

        public Time(){

            

Reported by PMD.

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

Line: 14

                  public void testToEntry2() {
        InnerEntry inner1 = null;// 出错
        String source1 = JSONObject.toJSONString(inner1);
        System.out.println(source1);
        OuterEntry inner2 = JSONObject.parseObject(source1, OuterEntry.class);// 出错
    }
}

            

Reported by PMD.

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

Line: 11

              
public class Bug1 extends TestCase {

    public void testToEntry2() {
        InnerEntry inner1 = null;// 出错
        String source1 = JSONObject.toJSONString(inner1);
        System.out.println(source1);
        OuterEntry inner2 = JSONObject.parseObject(source1, OuterEntry.class);// 出错
    }

            

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

    public void testToEntry2() {
        InnerEntry inner1 = null;// 出错
        String source1 = JSONObject.toJSONString(inner1);
        System.out.println(source1);
        OuterEntry inner2 = JSONObject.parseObject(source1, OuterEntry.class);// 出错
    }

            

Reported by PMD.

Avoid unused local variables such as 'inner2'.
Design

Line: 15

                      InnerEntry inner1 = null;// 出错
        String source1 = JSONObject.toJSONString(inner1);
        System.out.println(source1);
        OuterEntry inner2 = JSONObject.parseObject(source1, OuterEntry.class);// 出错
    }
}

            

Reported by PMD.

Found 'DU'-anomaly for variable 'inner2' (lines '15'-'16').
Error

Line: 15

                      InnerEntry inner1 = null;// 出错
        String source1 = JSONObject.toJSONString(inner1);
        System.out.println(source1);
        OuterEntry inner2 = JSONObject.parseObject(source1, OuterEntry.class);// 出错
    }
}

            

Reported by PMD.

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

    public void test_1() throws Exception {
        Model[] array = new Model[2048];
        for (int i = 0; i < array.length; ++i) {
            array[i] = new Model();
            array[i].value = Type.A;
        }

            

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

                      }
    }
    
    public void test_1_writer() throws Exception {
        Model[] array = new Model[2048];
        for (int i = 0; i < array.length; ++i) {
            array[i] = new Model();
            array[i].value = Type.A;
        }

            

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

                      }
    }
    
    public void test_null() throws Exception {
        Model[] array = new Model[2048];
        for (int i = 0; i < array.length; ++i) {
            array[i] = new Model();
            array[i].value = null;
        }

            

Reported by PMD.

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

Line: 54

                      Model[] array = new Model[2048];
        for (int i = 0; i < array.length; ++i) {
            array[i] = new Model();
            array[i].value = null;
        }

        String text = JSON.toJSONString(array, SerializerFeature.WriteMapNullValue);

        Model[] array2 = JSON.parseObject(text, Model[].class);

            

Reported by PMD.

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

Line: 69

              
    public static class Model {

        public Type value;

    }
    
    public static enum Type {
        A, B, C

            

Reported by PMD.

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

Line: 25

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

        Object object = JSON.parse(userJSON);
        
    }
}

            

Reported by PMD.

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

Line: 14

              
public class Bug_for_lenolix_6 extends TestCase {

    public void test_for_objectKey() throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", 1);
        map.put("name", "leno.lix");
        map.put("birthday", new Date());
        map.put("gmtCreate", new java.sql.Date(new Date().getTime()));

            

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

    public void test_for_objectKey() throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", 1);
        map.put("name", "leno.lix");
        map.put("birthday", new Date());
        map.put("gmtCreate", new java.sql.Date(new Date().getTime()));

            

Reported by PMD.

Avoid unused local variables such as 'object'.
Design

Line: 27

                      
        System.out.println(userJSON);

        Object object = JSON.parse(userJSON);
        
    }
}

            

Reported by PMD.

Found 'DU'-anomaly for variable 'object' (lines '27'-'29').
Error

Line: 27

                      
        System.out.println(userJSON);

        Object object = JSON.parse(userJSON);
        
    }
}

            

Reported by PMD.

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

Line: 19

                      Map<String, User> matcherMap = new HashMap<String, User>();
        String matcherMapString = JSON.toJSONString(matcherMap, SerializerFeature.WriteMapNullValue);

        System.out.println(matcherMapString);

        matcherMap = JSONObject.parseObject(matcherMapString, new TypeReference<Map<String, User>>() {
        });
    }


            

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

    public void test_0() throws Exception {
        Map<String, User> matcherMap = new HashMap<String, User>();
        String matcherMapString = JSON.toJSONString(matcherMap, SerializerFeature.WriteMapNullValue);

        System.out.println(matcherMapString);


            

Reported by PMD.

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

Line: 15

              
public class Bug_for_lenolix_2 extends TestCase {

    public void test_0() throws Exception {
        Map<String, User> matcherMap = new HashMap<String, User>();
        String matcherMapString = JSON.toJSONString(matcherMap, SerializerFeature.WriteMapNullValue);

        System.out.println(matcherMapString);


            

Reported by PMD.

The value assigned to variable 'matcherMap' is never used
Design

Line: 21

              
        System.out.println(matcherMapString);

        matcherMap = JSONObject.parseObject(matcherMapString, new TypeReference<Map<String, User>>() {
        });
    }

    public static class User {


            

Reported by PMD.

Found 'DU'-anomaly for variable 'matcherMap' (lines '21'-'23').
Error

Line: 21

              
        System.out.println(matcherMapString);

        matcherMap = JSONObject.parseObject(matcherMapString, new TypeReference<Map<String, User>>() {
        });
    }

    public static class User {


            

Reported by PMD.

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

Line: 20

                      String matcherMapString = JSON.toJSONString(matcherMap, SerializerFeature.WriteClassName,
                                                    SerializerFeature.WriteMapNullValue);
        
        System.out.println(matcherMapString);
        
        matcherMap = JSONObject.parseObject(matcherMapString, new TypeReference<Map<String, User>>() {
        });
    }


            

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

    public void test_0() throws Exception {
        Map<String, User> matcherMap = new HashMap<String, User>();
        String matcherMapString = JSON.toJSONString(matcherMap, SerializerFeature.WriteClassName,
                                                    SerializerFeature.WriteMapNullValue);
        
        System.out.println(matcherMapString);

            

Reported by PMD.

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

Line: 15

              
public class Bug_for_lenolix_1 extends TestCase {

    public void test_0() throws Exception {
        Map<String, User> matcherMap = new HashMap<String, User>();
        String matcherMapString = JSON.toJSONString(matcherMap, SerializerFeature.WriteClassName,
                                                    SerializerFeature.WriteMapNullValue);
        
        System.out.println(matcherMapString);

            

Reported by PMD.

The value assigned to variable 'matcherMap' is never used
Design

Line: 22

                      
        System.out.println(matcherMapString);
        
        matcherMap = JSONObject.parseObject(matcherMapString, new TypeReference<Map<String, User>>() {
        });
    }

    public static class User {


            

Reported by PMD.

Found 'DU'-anomaly for variable 'matcherMap' (lines '22'-'24').
Error

Line: 22

                      
        System.out.println(matcherMapString);
        
        matcherMap = JSONObject.parseObject(matcherMapString, new TypeReference<Map<String, User>>() {
        });
    }

    public static class User {


            

Reported by PMD.

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

              

public class Bug_for_juewu extends TestCase {
    public void test_str() throws Exception {
        String text = "{\"weitao_feed\":{\"head\":{\"Version\":\"V1.0\",\"Status\":\"OK\",\"SearchTime\":1488,\"DocsReturn\":18,\"DocsFound\":20,\"DocsRestrict\":20,\"DocsSearch\":0},\"auctions\":[{\"id\":\"110009362197\",\"creator_id\":\"673515636\",\"gmt_create_ms\":\"1385540374000\"}]}}";

    }
}

            

Reported by PMD.

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

Line: 9

              

public class Bug_for_juewu extends TestCase {
    public void test_str() throws Exception {
        String text = "{\"weitao_feed\":{\"head\":{\"Version\":\"V1.0\",\"Status\":\"OK\",\"SearchTime\":1488,\"DocsReturn\":18,\"DocsFound\":20,\"DocsRestrict\":20,\"DocsSearch\":0},\"auctions\":[{\"id\":\"110009362197\",\"creator_id\":\"673515636\",\"gmt_create_ms\":\"1385540374000\"}]}}";

    }
}

            

Reported by PMD.

Avoid unused local variables such as 'text'.
Design

Line: 10

              
public class Bug_for_juewu extends TestCase {
    public void test_str() throws Exception {
        String text = "{\"weitao_feed\":{\"head\":{\"Version\":\"V1.0\",\"Status\":\"OK\",\"SearchTime\":1488,\"DocsReturn\":18,\"DocsFound\":20,\"DocsRestrict\":20,\"DocsSearch\":0},\"auctions\":[{\"id\":\"110009362197\",\"creator_id\":\"673515636\",\"gmt_create_ms\":\"1385540374000\"}]}}";

    }
}

            

Reported by PMD.

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

Line: 5

              
import junit.framework.TestCase;

import com.alibaba.fastjson.JSON;


public class Bug_for_juewu extends TestCase {
    public void test_str() throws Exception {
        String text = "{\"weitao_feed\":{\"head\":{\"Version\":\"V1.0\",\"Status\":\"OK\",\"SearchTime\":1488,\"DocsReturn\":18,\"DocsFound\":20,\"DocsRestrict\":20,\"DocsSearch\":0},\"auctions\":[{\"id\":\"110009362197\",\"creator_id\":\"673515636\",\"gmt_create_ms\":\"1385540374000\"}]}}";

            

Reported by PMD.

Found 'DU'-anomaly for variable 'text' (lines '10'-'12').
Error

Line: 10

              
public class Bug_for_juewu extends TestCase {
    public void test_str() throws Exception {
        String text = "{\"weitao_feed\":{\"head\":{\"Version\":\"V1.0\",\"Status\":\"OK\",\"SearchTime\":1488,\"DocsReturn\":18,\"DocsFound\":20,\"DocsRestrict\":20,\"DocsSearch\":0},\"auctions\":[{\"id\":\"110009362197\",\"creator_id\":\"673515636\",\"gmt_create_ms\":\"1385540374000\"}]}}";

    }
}

            

Reported by PMD.

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

Line: 38

                  public void test_listErrorTest() {
        Foo foo = new Foo();
        String json = JSON.toJSONString(foo, SerializerFeature.WriteMapNullValue);
        System.out.println(json);
        Foo f = JSON.parseObject(json, Foo.class);
        System.out.println(f);
    }

}

            

Reported by PMD.

System.out.println is used
Design

Line: 40

                      String json = JSON.toJSONString(foo, SerializerFeature.WriteMapNullValue);
        System.out.println(json);
        Foo f = JSON.parseObject(json, Foo.class);
        System.out.println(f);
    }

}

            

Reported by PMD.

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

Line: 12

              
public class Bug_105_for_SpitFire extends TestCase {

    static private class Foo {

        private List<String> names;
        private List<String> codes;

        public List<String> getNames() {

            

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

              
    }

    public void test_listErrorTest() {
        Foo foo = new Foo();
        String json = JSON.toJSONString(foo, SerializerFeature.WriteMapNullValue);
        System.out.println(json);
        Foo f = JSON.parseObject(json, Foo.class);
        System.out.println(f);

            

Reported by PMD.

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

Line: 35

              
    }

    public void test_listErrorTest() {
        Foo foo = new Foo();
        String json = JSON.toJSONString(foo, SerializerFeature.WriteMapNullValue);
        System.out.println(json);
        Foo f = JSON.parseObject(json, Foo.class);
        System.out.println(f);

            

Reported by PMD.