The following issues were found

src/test/java/com/alibaba/json/bvt/JSONObjectTest7.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: 9

              
public class JSONObjectTest7 extends TestCase {

    public void test() throws Exception {
        JSONObject jsonObject = JSON.parseObject("{\"test\":null,\"a\":\"cc\"}");
        assertEquals(2, jsonObject.entrySet().size());
        assertTrue(jsonObject.containsKey("test"));
    }


            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 9

              
public class JSONObjectTest7 extends TestCase {

    public void test() throws Exception {
        JSONObject jsonObject = JSON.parseObject("{\"test\":null,\"a\":\"cc\"}");
        assertEquals(2, jsonObject.entrySet().size());
        assertTrue(jsonObject.containsKey("test"));
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 11

              
    public void test() throws Exception {
        JSONObject jsonObject = JSON.parseObject("{\"test\":null,\"a\":\"cc\"}");
        assertEquals(2, jsonObject.entrySet().size());
        assertTrue(jsonObject.containsKey("test"));
    }

}

            

Reported by PMD.

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

Line: 11

              
    public void test() throws Exception {
        JSONObject jsonObject = JSON.parseObject("{\"test\":null,\"a\":\"cc\"}");
        assertEquals(2, jsonObject.entrySet().size());
        assertTrue(jsonObject.containsKey("test"));
    }

}

            

Reported by PMD.

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

Line: 11

              
    public void test() throws Exception {
        JSONObject jsonObject = JSON.parseObject("{\"test\":null,\"a\":\"cc\"}");
        assertEquals(2, jsonObject.entrySet().size());
        assertTrue(jsonObject.containsKey("test"));
    }

}

            

Reported by PMD.

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

Line: 12

                  public void test() throws Exception {
        JSONObject jsonObject = JSON.parseObject("{\"test\":null,\"a\":\"cc\"}");
        assertEquals(2, jsonObject.entrySet().size());
        assertTrue(jsonObject.containsKey("test"));
    }

}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 12

                  public void test() throws Exception {
        JSONObject jsonObject = JSON.parseObject("{\"test\":null,\"a\":\"cc\"}");
        assertEquals(2, jsonObject.entrySet().size());
        assertTrue(jsonObject.containsKey("test"));
    }

}

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/support/config/FastJsonConfig.java
7 issues
The class 'FastJsonConfig' is suspected to be a Data Class (WOC=0.000%, NOPA=0, NOAM=20, WMC=23)
Design

Line: 29

               * @since 1.2.11
 */

public class FastJsonConfig {

    /**
     * default charset
     */
    private Charset charset;

            

Reported by PMD.

Returning 'serializerFeatures' may expose an internal array.
Design

Line: 133

                   * @return the serializerFeatures
     */
    public SerializerFeature[] getSerializerFeatures() {
        return serializerFeatures;
    }

    /**
     * @param serializerFeatures the serializerFeatures to set
     */

            

Reported by PMD.

The user-supplied array 'serializerFeatures' is stored directly.
Design

Line: 139

                  /**
     * @param serializerFeatures the serializerFeatures to set
     */
    public void setSerializerFeatures(SerializerFeature... serializerFeatures) {
        this.serializerFeatures = serializerFeatures;
    }

    /**
     * @return the serializeFilters

            

Reported by PMD.

Returning 'serializeFilters' may expose an internal array.
Design

Line: 147

                   * @return the serializeFilters
     */
    public SerializeFilter[] getSerializeFilters() {
        return serializeFilters;
    }

    /**
     * @param serializeFilters the serializeFilters to set
     */

            

Reported by PMD.

The user-supplied array 'serializeFilters' is stored directly.
Design

Line: 153

                  /**
     * @param serializeFilters the serializeFilters to set
     */
    public void setSerializeFilters(SerializeFilter... serializeFilters) {
        this.serializeFilters = serializeFilters;
    }

    /**
     * @return the features

            

Reported by PMD.

Returning 'features' may expose an internal array.
Design

Line: 161

                   * @return the features
     */
    public Feature[] getFeatures() {
        return features;
    }

    /**
     * @param features the features to set
     */

            

Reported by PMD.

The user-supplied array 'features' is stored directly.
Design

Line: 167

                  /**
     * @param features the features to set
     */
    public void setFeatures(Feature... features) {
        this.features = features;
    }

    /**
     * @return the classSerializeFilters

            

Reported by PMD.

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

Line: 13

                      String json = "{\"f1\":11222509, \"f2\":7}";

        VO v = JSON.parseObject(json, VO.class);
        System.out.println(v.getF1());
        System.out.println(v.getF2());

    }

    public static class VO {

            

Reported by PMD.

System.out.println is used
Design

Line: 14

              
        VO v = JSON.parseObject(json, VO.class);
        System.out.println(v.getF1());
        System.out.println(v.getF2());

    }

    public static class VO {


            

Reported by PMD.

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

Line: 9

              
public class Bug_for_long_whitespace extends TestCase {

    public void test() throws Exception {
        String json = "{\"f1\":11222509, \"f2\":7}";

        VO v = JSON.parseObject(json, VO.class);
        System.out.println(v.getF1());
        System.out.println(v.getF2());

            

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

    public void test() throws Exception {
        String json = "{\"f1\":11222509, \"f2\":7}";

        VO v = JSON.parseObject(json, VO.class);
        System.out.println(v.getF1());
        System.out.println(v.getF2());

            

Reported by PMD.

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

Line: 13

                      String json = "{\"f1\":11222509, \"f2\":7}";

        VO v = JSON.parseObject(json, VO.class);
        System.out.println(v.getF1());
        System.out.println(v.getF2());

    }

    public static class VO {

            

Reported by PMD.

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

Line: 14

              
        VO v = JSON.parseObject(json, VO.class);
        System.out.println(v.getF1());
        System.out.println(v.getF2());

    }

    public static class VO {


            

Reported by PMD.

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

Line: 18

              
    }

    public static class VO {

        private long f1;
        private int  f2;

        public long getF1() {

            

Reported by PMD.

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

              import junit.framework.TestCase;

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

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 12

              import junit.framework.TestCase;

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

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                      int[] values = new int[] {Integer.MIN_VALUE, -1, 0, 1, Integer.MAX_VALUE};
        String text = JSON.toJSONString(values);
        long[] values_2 = JSON.parseObject(text, long[].class);
        assertEquals(values_2.length, values.length);
        for (int i = 0; i < values.length; ++i) {
            assertEquals(values[i], values_2[i]);
        }
    }
    

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      long[] values_2 = JSON.parseObject(text, long[].class);
        assertEquals(values_2.length, values.length);
        for (int i = 0; i < values.length; ++i) {
            assertEquals(values[i], values_2[i]);
        }
    }
    
    public void test_map() throws Exception {
        int[] values = new int[] {Integer.MIN_VALUE, -1, 0, 1, Integer.MAX_VALUE};

            

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

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

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 32

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

            

Reported by PMD.

Found 'DU'-anomaly for variable 'obj' (lines '30'-'34').
Error

Line: 30

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

            

Reported by PMD.

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

Line: 22

                      }.getType();
        // this is ok
        Page<Sub> page1 = JSON.parseObject(JSON.toJSONString(page), type);
        System.out.println(page1.sub.getClass());
    }

    public void xx_testCast() {
        Page<Sub> page = new Page<Sub>(new Sub(1));
        Type type = new TypeReference<Page<Sub>>() {

            

Reported by PMD.

System.out.println is used
Design

Line: 33

                      // !!!! this will fail:
        // !!!! com.alibaba.fastjson.JSONException: can not cast to : Page<Sub> TypeUtils.java:719
        Page<Sub> page1 = TypeUtils.cast(page, type, parserconfig);
        System.out.println(page1.sub.getClass());
    }

    static class Page<T> {

        public Page(){

            

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

    public void test_for_issue() throws Exception {
        Page<Sub> page = new Page<Sub>(new Sub(1));
        Type type = new TypeReference<Page<Sub>>() {
        }.getType();
        // this is ok
        Page<Sub> page1 = JSON.parseObject(JSON.toJSONString(page), type);

            

Reported by PMD.

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

Line: 16

              
public class Issue96 extends TestCase {

    public void test_for_issue() throws Exception {
        Page<Sub> page = new Page<Sub>(new Sub(1));
        Type type = new TypeReference<Page<Sub>>() {
        }.getType();
        // this is ok
        Page<Sub> page1 = JSON.parseObject(JSON.toJSONString(page), type);

            

Reported by PMD.

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

Line: 22

                      }.getType();
        // this is ok
        Page<Sub> page1 = JSON.parseObject(JSON.toJSONString(page), type);
        System.out.println(page1.sub.getClass());
    }

    public void xx_testCast() {
        Page<Sub> page = new Page<Sub>(new Sub(1));
        Type type = new TypeReference<Page<Sub>>() {

            

Reported by PMD.

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

Line: 33

                      // !!!! this will fail:
        // !!!! com.alibaba.fastjson.JSONException: can not cast to : Page<Sub> TypeUtils.java:719
        Page<Sub> page1 = TypeUtils.cast(page, type, parserconfig);
        System.out.println(page1.sub.getClass());
    }

    static class Page<T> {

        public Page(){

            

Reported by PMD.

Avoid unused imports such as 'org.junit.Test'
Design

Line: 7

              
import junit.framework.TestCase;

import org.junit.Test;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.util.TypeUtils;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Issue117.java
7 issues
Avoid using equals() to compare against null
Error

Line: 15

                      VO vo = JSON.parseObject("{\"id\":123}", VO.class);
        Assert.assertEquals(123, vo.getId());
        vo.setId(124);
        vo.equals(null);
        vo.hashCode();
        Assert.assertEquals("{\"id\":124}", vo.toString());
    }
    
    public static interface VO {

            

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 Issue117 extends TestCase {
    public void test_for_issue() throws Exception {
        VO vo = JSON.parseObject("{\"id\":123}", VO.class);
        Assert.assertEquals(123, vo.getId());
        vo.setId(124);
        vo.equals(null);
        vo.hashCode();

            

Reported by PMD.

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

Line: 13

              public class Issue117 extends TestCase {
    public void test_for_issue() throws Exception {
        VO vo = JSON.parseObject("{\"id\":123}", VO.class);
        Assert.assertEquals(123, vo.getId());
        vo.setId(124);
        vo.equals(null);
        vo.hashCode();
        Assert.assertEquals("{\"id\":124}", vo.toString());
    }

            

Reported by PMD.

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

Line: 14

                  public void test_for_issue() throws Exception {
        VO vo = JSON.parseObject("{\"id\":123}", VO.class);
        Assert.assertEquals(123, vo.getId());
        vo.setId(124);
        vo.equals(null);
        vo.hashCode();
        Assert.assertEquals("{\"id\":124}", vo.toString());
    }
    

            

Reported by PMD.

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

Line: 15

                      VO vo = JSON.parseObject("{\"id\":123}", VO.class);
        Assert.assertEquals(123, vo.getId());
        vo.setId(124);
        vo.equals(null);
        vo.hashCode();
        Assert.assertEquals("{\"id\":124}", vo.toString());
    }
    
    public static interface VO {

            

Reported by PMD.

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

Line: 16

                      Assert.assertEquals(123, vo.getId());
        vo.setId(124);
        vo.equals(null);
        vo.hashCode();
        Assert.assertEquals("{\"id\":124}", vo.toString());
    }
    
    public static interface VO {
        public int getId();

            

Reported by PMD.

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

Line: 17

                      vo.setId(124);
        vo.equals(null);
        vo.hashCode();
        Assert.assertEquals("{\"id\":124}", vo.toString());
    }
    
    public static interface VO {
        public int getId();
        public void setId(int val);

            

Reported by PMD.

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

Line: 21

              

        String text = JSON.toJSONString(map, SerializerFeature.WriteClassName);
        System.out.println(text);
        Assert.assertEquals("{\"@type\":\"java.util.LinkedHashMap\",1:\"a\",2:\"b\"}",
                            text);

        Map<Integer, Object> value = (Map<Integer, Object>) JSON.parse(text);
        Assert.assertEquals(map, value);

            

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

    public void test_set() throws Exception {
        Map<Integer, Object> map = new LinkedHashMap<Integer, Object>();
        map.put(1, "a");
        map.put(2, "b");



            

Reported by PMD.

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

Line: 27

              
        Map<Integer, Object> value = (Map<Integer, Object>) JSON.parse(text);
        Assert.assertEquals(map, value);
        Assert.assertEquals(map.getClass(), value.getClass());
        Assert.assertEquals(Integer.class, value.keySet().iterator().next().getClass());
    }
    

    public static class Entity {

            

Reported by PMD.

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

Line: 28

                      Map<Integer, Object> value = (Map<Integer, Object>) JSON.parse(text);
        Assert.assertEquals(map, value);
        Assert.assertEquals(map.getClass(), value.getClass());
        Assert.assertEquals(Integer.class, value.keySet().iterator().next().getClass());
    }
    

    public static class Entity {


            

Reported by PMD.

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

Line: 28

                      Map<Integer, Object> value = (Map<Integer, Object>) JSON.parse(text);
        Assert.assertEquals(map, value);
        Assert.assertEquals(map.getClass(), value.getClass());
        Assert.assertEquals(Integer.class, value.keySet().iterator().next().getClass());
    }
    

    public static class Entity {


            

Reported by PMD.

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

Line: 28

                      Map<Integer, Object> value = (Map<Integer, Object>) JSON.parse(text);
        Assert.assertEquals(map, value);
        Assert.assertEquals(map.getClass(), value.getClass());
        Assert.assertEquals(Integer.class, value.keySet().iterator().next().getClass());
    }
    

    public static class Entity {


            

Reported by PMD.

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

Line: 28

                      Map<Integer, Object> value = (Map<Integer, Object>) JSON.parse(text);
        Assert.assertEquals(map, value);
        Assert.assertEquals(map.getClass(), value.getClass());
        Assert.assertEquals(Integer.class, value.keySet().iterator().next().getClass());
    }
    

    public static class Entity {


            

Reported by PMD.

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

Line: 18

                      cus.setName("name");

        Object json = JSON.toJSON(cus);
        System.out.println(json);

        String cusJson = json.toString();

        cusJson = "{\"name\":\"name\",\"id\":1}";


            

Reported by PMD.

System.out.println is used
Design

Line: 26

              
        Customer customer = JSON.parseObject(cusJson, Customer.class);

        System.out.println(customer);
    }

    public interface Indexable<ID extends Serializable> {

        public ID getId();

            

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

    public void test() throws Exception {
        Customer cus = new Customer();
        cus.setId(1L);
        cus.setName("name");

        Object json = JSON.toJSON(cus);

            

Reported by PMD.

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

Line: 12

              
public class Issue274 extends TestCase {

    public void test() throws Exception {
        Customer cus = new Customer();
        cus.setId(1L);
        cus.setName("name");

        Object json = JSON.toJSON(cus);

            

Reported by PMD.

The initializer for variable 'cusJson' is never used (overwritten on line 22)
Design

Line: 20

                      Object json = JSON.toJSON(cus);
        System.out.println(json);

        String cusJson = json.toString();

        cusJson = "{\"name\":\"name\",\"id\":1}";

        Customer customer = JSON.parseObject(cusJson, Customer.class);


            

Reported by PMD.

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

Line: 20

                      Object json = JSON.toJSON(cus);
        System.out.println(json);

        String cusJson = json.toString();

        cusJson = "{\"name\":\"name\",\"id\":1}";

        Customer customer = JSON.parseObject(cusJson, Customer.class);


            

Reported by PMD.

Found 'DD'-anomaly for variable 'cusJson' (lines '20'-'22').
Error

Line: 20

                      Object json = JSON.toJSON(cus);
        System.out.println(json);

        String cusJson = json.toString();

        cusJson = "{\"name\":\"name\",\"id\":1}";

        Customer customer = JSON.parseObject(cusJson, Customer.class);


            

Reported by PMD.

src/main/java/com/alibaba/fastjson/serializer/GuavaCodec.java
7 issues
Avoid unused local variables such as 'out'.
Design

Line: 23

                  public static GuavaCodec instance = new GuavaCodec();

    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
        SerializeWriter out = serializer.out;
        if (object instanceof Multimap) {
            Multimap multimap = (Multimap) object;
            serializer.write(multimap.asMap());
        }
    }

            

Reported by PMD.

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

Line: 26

                      SerializeWriter out = serializer.out;
        if (object instanceof Multimap) {
            Multimap multimap = (Multimap) object;
            serializer.write(multimap.asMap());
        }
    }

    public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
        Type rawType = type;

            

Reported by PMD.

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

Line: 39

                      if (rawType == ArrayListMultimap.class) {
            ArrayListMultimap multimap = ArrayListMultimap.create();
            JSONObject object = parser.parseObject();
            for (Map.Entry entry : object.entrySet()) {
                Object value = entry.getValue();
                if (value instanceof Collection) {
                    multimap.putAll(entry.getKey(), (List) value);
                } else {
                    multimap.put(entry.getKey(), value);

            

Reported by PMD.

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

Line: 42

                          for (Map.Entry entry : object.entrySet()) {
                Object value = entry.getValue();
                if (value instanceof Collection) {
                    multimap.putAll(entry.getKey(), (List) value);
                } else {
                    multimap.put(entry.getKey(), value);
                }
            }


            

Reported by PMD.

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

Line: 44

                              if (value instanceof Collection) {
                    multimap.putAll(entry.getKey(), (List) value);
                } else {
                    multimap.put(entry.getKey(), value);
                }
            }

            return (T) multimap;
        }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'out' (lines '23'-'28').
Error

Line: 23

                  public static GuavaCodec instance = new GuavaCodec();

    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
        SerializeWriter out = serializer.out;
        if (object instanceof Multimap) {
            Multimap multimap = (Multimap) object;
            serializer.write(multimap.asMap());
        }
    }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'rawType' (lines '31'-'33').
Error

Line: 31

                  }

    public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
        Type rawType = type;
        if (type instanceof ParameterizedType) {
            rawType = ((ParameterizedType) type).getRawType();
        }

        if (rawType == ArrayListMultimap.class) {

            

Reported by PMD.

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

Line: 21

                      users.add(new User());

        String text = JSON.toJSONString(users);
        System.out.println(text);
        
        List<User> users2 = JSON.parseArray(text, User.class);
    }

    public static class User implements Serializable {

            

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

    public void test_0() throws Exception {
        List<User> users = new ArrayList<User>();
        users.add(new User());
        users.add(new User());

        String text = JSON.toJSONString(users);

            

Reported by PMD.

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

Line: 15

              
public class Bug_for_wtusmchen extends TestCase {

    public void test_0() throws Exception {
        List<User> users = new ArrayList<User>();
        users.add(new User());
        users.add(new User());

        String text = JSON.toJSONString(users);

            

Reported by PMD.

Avoid unused local variables such as 'users2'.
Design

Line: 23

                      String text = JSON.toJSONString(users);
        System.out.println(text);
        
        List<User> users2 = JSON.parseArray(text, User.class);
    }

    public static class User implements Serializable {

        private String user_id = "aaaa";

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 26

                      List<User> users2 = JSON.parseArray(text, User.class);
    }

    public static class User implements Serializable {

        private String user_id = "aaaa";
        Date           bri;
        Timestamp      bri2;
        Double         num;

            

Reported by PMD.

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

Line: 26

                      List<User> users2 = JSON.parseArray(text, User.class);
    }

    public static class User implements Serializable {

        private String user_id = "aaaa";
        Date           bri;
        Timestamp      bri2;
        Double         num;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'users2' (lines '23'-'24').
Error

Line: 23

                      String text = JSON.toJSONString(users);
        System.out.println(text);
        
        List<User> users2 = JSON.parseArray(text, User.class);
    }

    public static class User implements Serializable {

        private String user_id = "aaaa";

            

Reported by PMD.