The following issues were found

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

    public void test_codec() throws Exception {
        User user = new User();
        user.setValue(URI.create("http://www.alibaba.com/abc"));

        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 URI value;

            

Reported by PMD.

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

Line: 18

                      map.put("a", Enum.ENUM1);
        map.put("b", Enum.ENUM1);

        System.out.println(JSON.toJSONString(map, SerializerFeature.WriteEnumUsingToString));

        System.out.println(JSON.toJSONString(map));

    }


            

Reported by PMD.

System.out.println is used
Design

Line: 20

              
        System.out.println(JSON.toJSONString(map, SerializerFeature.WriteEnumUsingToString));

        System.out.println(JSON.toJSONString(map));

    }

    public static enum Enum {


            

Reported by PMD.

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

Line: 13

              
public class Bug_for_ruiqi extends TestCase {

    public void test_0() throws Exception {
        Map<String, Enum> map = new HashMap<String, Enum>();
        map.put("a", Enum.ENUM1);
        map.put("b", Enum.ENUM1);

        System.out.println(JSON.toJSONString(map, SerializerFeature.WriteEnumUsingToString));

            

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

              
public class Bug_for_ruiqi extends TestCase {

    public void test_0() throws Exception {
        Map<String, Enum> map = new HashMap<String, Enum>();
        map.put("a", Enum.ENUM1);
        map.put("b", Enum.ENUM1);

        System.out.println(JSON.toJSONString(map, SerializerFeature.WriteEnumUsingToString));

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_937.java
4 issues
Overridable method 'setOutPara' called during object construction
Error

Line: 39

                      }

        public Out(T t) {
            setOutPara(t);
        }
    }

    public static class Info {
        private String name;

            

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

               */
public class Bug_for_issue_937 extends TestCase {

    public void test_for_issue() throws Exception {
        String json = "{outPara:{name:\"user\"}}";
        Out<Info> out = returnOut(json, Info.class);
        Assert.assertEquals("user", out.getOutPara().getName());
    }


            

Reported by PMD.

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

Line: 16

                  public void test_for_issue() throws Exception {
        String json = "{outPara:{name:\"user\"}}";
        Out<Info> out = returnOut(json, Info.class);
        Assert.assertEquals("user", out.getOutPara().getName());
    }

    public static <T> Out<T> returnOut(String jsonStr, Class<T> c2) {
        return JSON.parseObject(jsonStr, new TypeReference<Out<T>>(c2) {
        });

            

Reported by PMD.

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

Line: 16

                  public void test_for_issue() throws Exception {
        String json = "{outPara:{name:\"user\"}}";
        Out<Info> out = returnOut(json, Info.class);
        Assert.assertEquals("user", out.getOutPara().getName());
    }

    public static <T> Out<T> returnOut(String jsonStr, Class<T> c2) {
        return JSON.parseObject(jsonStr, new TypeReference<Out<T>>(c2) {
        });

            

Reported by PMD.

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

Line: 16

                      vo.setValue("<a href=\"http://www.baidu.com\"> 问题链接 </a> ");
        
        String text = JSON.toJSONString(vo, SerializerFeature.WriteSlashAsSpecial);
        System.out.println(text);
    }

    public static class VO {

        private String value;

            

Reported by PMD.

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

Line: 11

              
public class Bug_for_qqdwll2012 extends TestCase {

    public void test_for_x() throws Exception {
        VO vo = new VO();
        vo.setValue("<a href=\"http://www.baidu.com\"> 问题链接 </a> ");
        
        String text = JSON.toJSONString(vo, SerializerFeature.WriteSlashAsSpecial);
        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: 11

              
public class Bug_for_qqdwll2012 extends TestCase {

    public void test_for_x() throws Exception {
        VO vo = new VO();
        vo.setValue("<a href=\"http://www.baidu.com\"> 问题链接 </a> ");
        
        String text = JSON.toJSONString(vo, SerializerFeature.WriteSlashAsSpecial);
        System.out.println(text);

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.serializer.SerializeFilter'
Design

Line: 4

              package com.alibaba.json.bvt.bug;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializeFilter;
import com.alibaba.fastjson.serializer.SerializerFeature;

import junit.framework.TestCase;

public class Bug_for_qqdwll2012 extends TestCase {

            

Reported by PMD.

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

              
public class bug_for_pengsong0302 extends TestCase {

    public void test_0() throws Exception {
        Assert.assertEquals("\"a\\u2028b\"", JSON.toJSONString("a\u2028b"));
    }
    
    public void test_1() throws Exception {
        Assert.assertEquals("{\"value\":\"a\\u2028b\"}", JSON.toJSONString(new A("a\u2028b")));

            

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

                      Assert.assertEquals("\"a\\u2028b\"", JSON.toJSONString("a\u2028b"));
    }
    
    public void test_1() throws Exception {
        Assert.assertEquals("{\"value\":\"a\\u2028b\"}", JSON.toJSONString(new A("a\u2028b")));
    }

    public void test_2029() throws Exception {
        Assert.assertEquals("\"a\\u2029b\"", JSON.toJSONString("a\u2029b"));

            

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

                      Assert.assertEquals("{\"value\":\"a\\u2028b\"}", JSON.toJSONString(new A("a\u2028b")));
    }

    public void test_2029() throws Exception {
        Assert.assertEquals("\"a\\u2029b\"", JSON.toJSONString("a\u2029b"));
    }

    public void test_2029_1() throws Exception {
        Assert.assertEquals("{\"value\":\"a\\u2029b\"}", JSON.toJSONString(new A("a\u2029b")));

            

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

                      Assert.assertEquals("\"a\\u2029b\"", JSON.toJSONString("a\u2029b"));
    }

    public void test_2029_1() throws Exception {
        Assert.assertEquals("{\"value\":\"a\\u2029b\"}", JSON.toJSONString(new A("a\u2029b")));
    }

    public static class A {


            

Reported by PMD.

src/main/java/com/alibaba/fastjson/parser/ParseContext.java
4 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 7

              
public class ParseContext {

    public Object             object;
    public final ParseContext parent;
    public final Object       fieldName;
    public final int          level;
    public Type               type;
    private transient String  path;

            

Reported by PMD.

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

Line: 8

              public class ParseContext {

    public Object             object;
    public final ParseContext parent;
    public final Object       fieldName;
    public final int          level;
    public Type               type;
    private transient String  path;


            

Reported by PMD.

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

Line: 9

              
    public Object             object;
    public final ParseContext parent;
    public final Object       fieldName;
    public final int          level;
    public Type               type;
    private transient String  path;

    public ParseContext(ParseContext parent, Object object, Object fieldName){

            

Reported by PMD.

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

Line: 10

                  public Object             object;
    public final ParseContext parent;
    public final Object       fieldName;
    public final int          level;
    public Type               type;
    private transient String  path;

    public ParseContext(ParseContext parent, Object object, Object fieldName){
        this.parent = parent;

            

Reported by PMD.

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

    public void test_for_parent() throws Exception {
        String text = "{\"content\":\"result\"}";
        
        ParentClass parentClass = JSON.parseObject(text, ParentClass.class);

        Assert.assertEquals(parentClass.getTest(), "result");

            

Reported by PMD.

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

Line: 17

                      
        ParentClass parentClass = JSON.parseObject(text, ParentClass.class);

        Assert.assertEquals(parentClass.getTest(), "result");
        
        String text2 = JSON.toJSONString(parentClass);
        Assert.assertEquals(text, text2);
    }
    

            

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

                      Assert.assertEquals(text, text2);
    }
    
    public void test_for_sub() throws Exception {
        String text = "{\"content\":\"result\"}";
        
        SubClass  parentClass = JSON.parseObject(text, SubClass.class);
        
        Assert.assertEquals(parentClass.getTest(), "result");

            

Reported by PMD.

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

Line: 28

                      
        SubClass  parentClass = JSON.parseObject(text, SubClass.class);
        
        Assert.assertEquals(parentClass.getTest(), "result");
        String text2 = JSON.toJSONString(parentClass);
        Assert.assertEquals(text, text2);
    }

    public static class ParentClass {

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/JSONPObject.java
4 issues
Potential violation of Law of Demeter (object not created locally)
Design

Line: 51

                      SerializeWriter writer = serializer.out;

        if ((features & SerializerFeature.BrowserSecure.mask) != 0
                || (writer.isEnabled(SerializerFeature.BrowserSecure.mask)))
        {
            writer.write(SECURITY_PREFIX);
        }

        writer.write(function);

            

Reported by PMD.

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

Line: 56

                          writer.write(SECURITY_PREFIX);
        }

        writer.write(function);
        writer.write('(');
        for (int i = 0; i < parameters.size(); ++i) {
            if (i != 0) {
                writer.write(',');
            }

            

Reported by PMD.

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

Line: 57

                      }

        writer.write(function);
        writer.write('(');
        for (int i = 0; i < parameters.size(); ++i) {
            if (i != 0) {
                writer.write(',');
            }
            serializer.write(parameters.get(i));

            

Reported by PMD.

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

Line: 64

                          }
            serializer.write(parameters.get(i));
        }
        writer.write(')');
    }

    public String toString() {
        return JSON.toJSONString(this);
    }

            

Reported by PMD.

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

Line: 20

                                        SerializerFeature.WriteNonStringKeyAsString, SerializerFeature.QuoteFieldNames,
                          SerializerFeature.SkipTransientField, SerializerFeature.SortField,
                          SerializerFeature.PrettyFormat);
        System.out.println(text);
        
        VO vo2 = JSON.parseObject(text, VO.class);
        
        Assert.assertEquals(vo.getbId(), vo2.getbId());
    }

            

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

    public void test_for_issue() throws Exception {
        VO vo = new VO();
        vo.setbId("xxxx");

        String text = JSON.toJSONString(vo, SerializerFeature.WriteDateUseDateFormat, SerializerFeature.WriteEnumUsingToString,
                          SerializerFeature.WriteNonStringKeyAsString, SerializerFeature.QuoteFieldNames,

            

Reported by PMD.

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

Line: 24

                      
        VO vo2 = JSON.parseObject(text, VO.class);
        
        Assert.assertEquals(vo.getbId(), vo2.getbId());
    }

    public static class VO {

        private String bId;

            

Reported by PMD.

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

Line: 29

              
    public static class VO {

        private String bId;

        public String getbId() {
            return bId;
        }


            

Reported by PMD.

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

              import junit.framework.TestCase;

public class CustomDeserializerTest extends TestCase {
    public void test_0() throws Exception {
        String text = "{\"xid\":1001}";
        Model model = JSON.parseObject(text, Model.class);
        Assert.assertEquals(1001, model.id);
    }
    

            

Reported by PMD.

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

Line: 24

                  
    @JSONType(deserializer=ModelDeserializer.class)
    public static class Model {
        public int id;
    }
    
    public static class ModelDeserializer implements ObjectDeserializer {
        @Override
        public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {

            

Reported by PMD.

Avoid unused local variables such as 'key'.
Design

Line: 34

                          
            reader.startObject();
            
            String key = reader.readString();
            Integer value = reader.readInteger();
            
            Model model = new Model();
            model.id = value;
            

            

Reported by PMD.

Found 'DU'-anomaly for variable 'key' (lines '34'-'43').
Error

Line: 34

                          
            reader.startObject();
            
            String key = reader.readString();
            Integer value = reader.readInteger();
            
            Model model = new Model();
            model.id = value;
            

            

Reported by PMD.