The following issues were found

src/test/java/com/alibaba/json/bvt/parser/deser/SmartMatchTest.java
4 issues
A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 11

              
public class SmartMatchTest extends TestCase {

    public void f_test_0() throws Exception {
        String text = "{\"message_id\":1001}";

        VO vo = JSON.parseObject(text, VO.class);
        Assert.assertEquals(1001, vo.getMessageId());
    }

            

Reported by PMD.

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

Line: 15

                      String text = "{\"message_id\":1001}";

        VO vo = JSON.parseObject(text, VO.class);
        Assert.assertEquals(1001, vo.getMessageId());
    }

    public void test_vo2() throws Exception {
        String text = "{\"message_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: 18

                      Assert.assertEquals(1001, vo.getMessageId());
    }

    public void test_vo2() throws Exception {
        String text = "{\"message_id\":1001}";

        VO2 vo = JSON.parseObject(text, VO2.class);
        Assert.assertEquals(1001, vo.getMessageId());
    }

            

Reported by PMD.

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

Line: 22

                      String text = "{\"message_id\":1001}";

        VO2 vo = JSON.parseObject(text, VO2.class);
        Assert.assertEquals(1001, vo.getMessageId());
    }

    private static class VO {

        private int messageId;

            

Reported by PMD.

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

    public void test_date() throws Exception {
        String text = "{\"gmtCreate\":\"2014-10-09T03:07:07.000Z\"}";

        Calendar date = JSON.parseObject(text, VO.class).getGmtCreate();
        Assert.assertNotNull(date);


            

Reported by PMD.

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

Line: 16

                  public void test_date() throws Exception {
        String text = "{\"gmtCreate\":\"2014-10-09T03:07:07.000Z\"}";

        Calendar date = JSON.parseObject(text, VO.class).getGmtCreate();
        Assert.assertNotNull(date);

        Assert.assertEquals(0, date.getTimeZone().getRawOffset() / (3600 * 1000));
    }


            

Reported by PMD.

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

Line: 19

                      Calendar date = JSON.parseObject(text, VO.class).getGmtCreate();
        Assert.assertNotNull(date);

        Assert.assertEquals(0, date.getTimeZone().getRawOffset() / (3600 * 1000));
    }

    public static class VO {

        private Calendar gmtCreate;

            

Reported by PMD.

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

Line: 19

                      Calendar date = JSON.parseObject(text, VO.class).getGmtCreate();
        Assert.assertNotNull(date);

        Assert.assertEquals(0, date.getTimeZone().getRawOffset() / (3600 * 1000));
    }

    public static class VO {

        private Calendar gmtCreate;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/enum_/EnumFieldsTest.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: 11

              import junit.framework.TestCase;

public class EnumFieldsTest extends TestCase {
    public void test_enum() throws Exception {
        Model model = new Model();
        model.t1 = Type.A;
        model.t2 = null;
        
        String text = JSON.toJSONString(model, SerializerFeature.WriteMapNullValue);

            

Reported by PMD.

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

Line: 14

                  public void test_enum() throws Exception {
        Model model = new Model();
        model.t1 = Type.A;
        model.t2 = null;
        
        String text = JSON.toJSONString(model, SerializerFeature.WriteMapNullValue);
        Assert.assertEquals("{\"t1\":\"A\",\"t2\":null}", text);
    }
    

            

Reported by PMD.

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

Line: 21

                  }
    
    public static class Model {
        public Type t1;
        public Type t2;
    }

    private static enum Type {
                             A, B, C

            

Reported by PMD.

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

Line: 22

                  
    public static class Model {
        public Type t1;
        public Type t2;
    }

    private static enum Type {
                             A, B, C
    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/enum_/EnumFieldsTest3.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

              import junit.framework.TestCase;

public class EnumFieldsTest3 extends TestCase {
    public void test_enum() throws Exception {
        Model model = new Model();
        model.types.add(Type.A);
        model.types.add(null);
        
        String text = JSON.toJSONString(model, SerializerFeature.WriteMapNullValue);

            

Reported by PMD.

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

Line: 16

              public class EnumFieldsTest3 extends TestCase {
    public void test_enum() throws Exception {
        Model model = new Model();
        model.types.add(Type.A);
        model.types.add(null);
        
        String text = JSON.toJSONString(model, SerializerFeature.WriteMapNullValue);
        Assert.assertEquals("{\"types\":[\"A\",null]}", text);
    }

            

Reported by PMD.

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

Line: 17

                  public void test_enum() throws Exception {
        Model model = new Model();
        model.types.add(Type.A);
        model.types.add(null);
        
        String text = JSON.toJSONString(model, SerializerFeature.WriteMapNullValue);
        Assert.assertEquals("{\"types\":[\"A\",null]}", text);
    }
    

            

Reported by PMD.

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

Line: 24

                  }
    
    public static class Model {
        public List<Type> types = new ArrayList<Type>();
    }

    private static enum Type {
                             A, B, C
    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/enum_/EnumFieldsTest5.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 junit.framework.TestCase;

public class EnumFieldsTest5 extends TestCase {
    public void test_enum() throws Exception {
        Model model = new Model();
        model.types.add(Type.A);
        model.types.add(null);
        
        String text = JSON.toJSONString(model, SerializerFeature.WriteMapNullValue);

            

Reported by PMD.

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

Line: 17

              public class EnumFieldsTest5 extends TestCase {
    public void test_enum() throws Exception {
        Model model = new Model();
        model.types.add(Type.A);
        model.types.add(null);
        
        String text = JSON.toJSONString(model, SerializerFeature.WriteMapNullValue);
        Assert.assertEquals("{\"types\":[\"A\",null]}", text);
    }

            

Reported by PMD.

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

Line: 18

                  public void test_enum() throws Exception {
        Model model = new Model();
        model.types.add(Type.A);
        model.types.add(null);
        
        String text = JSON.toJSONString(model, SerializerFeature.WriteMapNullValue);
        Assert.assertEquals("{\"types\":[\"A\",null]}", text);
    }
    

            

Reported by PMD.

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

Line: 25

                  }
    
    public static class Model {
        public Collection<Type> types = Collections.synchronizedCollection(new ArrayList<Type>());
    }

    private static enum Type {
                             A, B, C
    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/enum_/EnumTest.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: 16

                      Big, Medium, Small
    }

    public void test_enum() throws Exception {
        Assert.assertEquals("0", JSON.toJSONStringZ(Type.Big, SerializeConfig.getGlobalInstance())); // 0
        Assert.assertEquals("1", JSON.toJSONStringZ(Type.Medium, SerializeConfig.getGlobalInstance())); // 1
        Assert.assertEquals("2", JSON.toJSONStringZ(Type.Small, SerializeConfig.getGlobalInstance())); // 2

        Assert.assertEquals("\"Big\"", JSON.toJSONString(Type.Big, SerializerFeature.WriteEnumUsingToString)); // "Big"

            

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

                      Assert.assertEquals("'Small'", JSON.toJSONString(Type.Small, SerializerFeature.UseSingleQuotes)); // "Small"
    }

    public void test_empty() throws Exception {
        Model model = JSON.parseObject("{\"type\":\"\"}", Model.class);
        assertNull(model.type);
    }

    public static class Model {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

              
    public void test_empty() throws Exception {
        Model model = JSON.parseObject("{\"type\":\"\"}", Model.class);
        assertNull(model.type);
    }

    public static class Model {
        public Type type;
    }

            

Reported by PMD.

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

Line: 33

                  }

    public static class Model {
        public Type type;
    }

}

            

Reported by PMD.

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

Line: 20

                      Assert.assertEquals("value1", array[0]);
        Assert.assertEquals("value2", array[1]);
        
        System.out.println(Thread.currentThread().getContextClassLoader().getResource("com/alibaba/fastjson/JSON.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: 12

              import com.alibaba.fastjson.TypeReference;

public class Bug_for_lenolix extends TestCase {
    public void test_FieldMap() throws Exception {
        Map<String, String[]> map = JSON.parseObject("{\"key\":[\"value1\",\"value2\"]}",
                                                                     new TypeReference<Map<String, String[]>>() {
                                                                     });
        String[] array = map.get("key");
        Assert.assertEquals("value1", array[0]);

            

Reported by PMD.

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

Line: 20

                      Assert.assertEquals("value1", array[0]);
        Assert.assertEquals("value2", array[1]);
        
        System.out.println(Thread.currentThread().getContextClassLoader().getResource("com/alibaba/fastjson/JSON.class"));
    }

    
}

            

Reported by PMD.

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

Line: 20

                      Assert.assertEquals("value1", array[0]);
        Assert.assertEquals("value2", array[1]);
        
        System.out.println(Thread.currentThread().getContextClassLoader().getResource("com/alibaba/fastjson/JSON.class"));
    }

    
}

            

Reported by PMD.

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

               * Created by wenshao on 16/8/30.
 */
public class Issue776 extends TestCase {
    public void test_for_issue() throws Exception {
        String str1 = "{\"v\":[\" \",\"abc\",\"x\",\"abc\"]}";

        Exception error = null;
        try {
            JSON.parseObject(str1,

            

Reported by PMD.

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

Line: 20

                          JSON.parseObject(str1,
                    new com.alibaba.fastjson.TypeReference<Map<String, char[]>>() {
                    });
        } catch (Exception ex) {
            error = ex;
        }
        assertNotNull(error);
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 23

                      } catch (Exception ex) {
            error = ex;
        }
        assertNotNull(error);
    }
}

            

Reported by PMD.

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

Line: 15

                  public void test_for_issue() throws Exception {
        String str1 = "{\"v\":[\" \",\"abc\",\"x\",\"abc\"]}";

        Exception error = null;
        try {
            JSON.parseObject(str1,
                    new com.alibaba.fastjson.TypeReference<Map<String, char[]>>() {
                    });
        } catch (Exception ex) {

            

Reported by PMD.

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

    public void test_codec() throws Exception {
        User user = new User();
        user.setValue(Locale.CANADA);

        SerializeConfig mapping = new SerializeConfig();
        mapping.setAsmEnable(false);

            

Reported by PMD.

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

Line: 24

              
        User user1 = JSON.parseObject(text, User.class);

        Assert.assertEquals(user1.getValue(), user.getValue());
    }

    public void test_codec_null() throws Exception {
        User user = new User();
        user.setValue(null);

            

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

                      Assert.assertEquals(user1.getValue(), user.getValue());
    }

    public void test_codec_null() throws Exception {
        User user = new User();
        user.setValue(null);

        SerializeConfig mapping = new SerializeConfig();
        mapping.setAsmEnable(false);

            

Reported by PMD.

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

Line: 37

              
        User user1 = JSON.parseObject(text, User.class);

        Assert.assertEquals(user1.getValue(), user.getValue());
    }

    public static class User {

        private Locale value;

            

Reported by PMD.

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

              import junit.framework.TestCase;

public class StringFieldTest_special_singquote extends TestCase {
    public void test_special() throws Exception {
        Model model = new Model();
        StringBuilder buf = new StringBuilder();
        for (int i = Character.MIN_VALUE; i < Character.MAX_VALUE; ++i) {
            buf.append((char) 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: 28

                      Assert.assertEquals(model.name, model2.name);
    }
    
    public void test_special_browsecue() throws Exception {
        Model model = new Model();
        StringBuilder buf = new StringBuilder();
        for (int i = Character.MIN_VALUE; i < Character.MAX_VALUE; ++i) {
            buf.append((char) 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: 43

                      Assert.assertEquals(model.name, model2.name);
    }
    
    public void test_special_browsecompatible() throws Exception {
        Model model = new Model();
        StringBuilder buf = new StringBuilder();
        for (int i = Character.MIN_VALUE; i < Character.MAX_VALUE; ++i) {
            buf.append((char) i);
        }

            

Reported by PMD.

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

Line: 60

              
    private static class Model {

        public String name;

    }
}

            

Reported by PMD.