The following issues were found

src/test/java/com/alibaba/json/bvt/parser/deser/FieldDeserializerTest10.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 FieldDeserializerTest10 extends TestCase {
    public void test_0 () throws Exception {
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\"\t}", VO.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\"\t}\n\t", VO.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\" }", V1.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\" }\n", V1.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\" }\n\t", V1.class).id);

            

Reported by PMD.

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

Line: 10

              
public class FieldDeserializerTest10 extends TestCase {
    public void test_0 () throws Exception {
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\"\t}", VO.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\"\t}\n\t", VO.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\" }", V1.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\" }\n", V1.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\" }\n\t", V1.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\"\n}", V1.class).id);

            

Reported by PMD.

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

Line: 11

              public class FieldDeserializerTest10 extends TestCase {
    public void test_0 () throws Exception {
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\"\t}", VO.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\"\t}\n\t", VO.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\" }", V1.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\" }\n", V1.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\" }\n\t", V1.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\"\n}", V1.class).id);
    }

            

Reported by PMD.

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

Line: 12

                  public void test_0 () throws Exception {
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\"\t}", VO.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\"\t}\n\t", VO.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\" }", V1.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\" }\n", V1.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\" }\n\t", V1.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\"\n}", V1.class).id);
    }
    

            

Reported by PMD.

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

Line: 13

                      Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\"\t}", VO.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\"\t}\n\t", VO.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\" }", V1.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\" }\n", V1.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\" }\n\t", V1.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\"\n}", V1.class).id);
    }
    
    public static class VO {

            

Reported by PMD.

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

Line: 14

                      Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\"\t}\n\t", VO.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\" }", V1.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\" }\n", V1.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\" }\n\t", V1.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\"\n}", V1.class).id);
    }
    
    public static class VO {
        public Type id;

            

Reported by PMD.

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

Line: 15

                      Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\" }", V1.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\" }\n", V1.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\" }\n\t", V1.class).id);
        Assert.assertEquals(Type.Big, JSON.parseObject("{\"id\":\"Big\"\n}", V1.class).id);
    }
    
    public static class VO {
        public Type id;
    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/GetOnlyCollectionTest.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: 13

              
public class GetOnlyCollectionTest extends TestCase {

    public void test_getOnly() throws Exception {
        VO vo = JSON.parseObject("{\"items\":[\"a\",\"b\"]}", VO.class);
        Assert.assertEquals(2, vo.getItems().size());
        Assert.assertEquals("a", vo.getItems().get(0));
        Assert.assertEquals("b", vo.getItems().get(1));
    }

            

Reported by PMD.

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

Line: 15

              
    public void test_getOnly() throws Exception {
        VO vo = JSON.parseObject("{\"items\":[\"a\",\"b\"]}", VO.class);
        Assert.assertEquals(2, vo.getItems().size());
        Assert.assertEquals("a", vo.getItems().get(0));
        Assert.assertEquals("b", vo.getItems().get(1));
    }

    public static class VO {

            

Reported by PMD.

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

Line: 15

              
    public void test_getOnly() throws Exception {
        VO vo = JSON.parseObject("{\"items\":[\"a\",\"b\"]}", VO.class);
        Assert.assertEquals(2, vo.getItems().size());
        Assert.assertEquals("a", vo.getItems().get(0));
        Assert.assertEquals("b", vo.getItems().get(1));
    }

    public static class VO {

            

Reported by PMD.

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

Line: 16

                  public void test_getOnly() throws Exception {
        VO vo = JSON.parseObject("{\"items\":[\"a\",\"b\"]}", VO.class);
        Assert.assertEquals(2, vo.getItems().size());
        Assert.assertEquals("a", vo.getItems().get(0));
        Assert.assertEquals("b", vo.getItems().get(1));
    }

    public static class VO {
        private final List<String> items = new ArrayList<String>();

            

Reported by PMD.

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

Line: 16

                  public void test_getOnly() throws Exception {
        VO vo = JSON.parseObject("{\"items\":[\"a\",\"b\"]}", VO.class);
        Assert.assertEquals(2, vo.getItems().size());
        Assert.assertEquals("a", vo.getItems().get(0));
        Assert.assertEquals("b", vo.getItems().get(1));
    }

    public static class VO {
        private final List<String> items = new ArrayList<String>();

            

Reported by PMD.

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

Line: 17

                      VO vo = JSON.parseObject("{\"items\":[\"a\",\"b\"]}", VO.class);
        Assert.assertEquals(2, vo.getItems().size());
        Assert.assertEquals("a", vo.getItems().get(0));
        Assert.assertEquals("b", vo.getItems().get(1));
    }

    public static class VO {
        private final List<String> items = new ArrayList<String>();


            

Reported by PMD.

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

Line: 17

                      VO vo = JSON.parseObject("{\"items\":[\"a\",\"b\"]}", VO.class);
        Assert.assertEquals(2, vo.getItems().size());
        Assert.assertEquals("a", vo.getItems().get(0));
        Assert.assertEquals("b", vo.getItems().get(1));
    }

    public static class VO {
        private final List<String> items = new ArrayList<String>();


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/filters/PropertyPathTest2.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: 15

              
public class PropertyPathTest2 extends TestCase {

    public void test_path() throws Exception {
        Person p1 = new Person();
        p1.setId(100);
        
        Person c1 = new Person();
        c1.setId(1000);

            

Reported by PMD.

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

Line: 25

                      Person c2 = new Person();
        c2.setId(2000);
        
        p1.getChildren().add(c1);
        p1.getChildren().add(c2);
        
        Assert.assertEquals("{\"children\":[{\"id\":1000},{\"id\":2000}],\"id\":100}", JSON.toJSONString(p1, new MyPropertyPreFilter()));
    }


            

Reported by PMD.

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

Line: 26

                      c2.setId(2000);
        
        p1.getChildren().add(c1);
        p1.getChildren().add(c2);
        
        Assert.assertEquals("{\"children\":[{\"id\":1000},{\"id\":2000}],\"id\":100}", JSON.toJSONString(p1, new MyPropertyPreFilter()));
    }

    public static class MyPropertyPreFilter implements PropertyPreFilter {

            

Reported by PMD.

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

Line: 34

                  public static class MyPropertyPreFilter implements PropertyPreFilter {

        public boolean apply(JSONSerializer serializer, Object source, String name) {
            String path = serializer.getContext().toString() + "." + name;

            if (path.endsWith("].children")) {
                return false;
            }


            

Reported by PMD.

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

Line: 36

                      public boolean apply(JSONSerializer serializer, Object source, String name) {
            String path = serializer.getContext().toString() + "." + name;

            if (path.endsWith("].children")) {
                return false;
            }

            return true;
        }

            

Reported by PMD.

Avoid unnecessary if..then..else statements when returning booleans
Design

Line: 36

                      public boolean apply(JSONSerializer serializer, Object source, String name) {
            String path = serializer.getContext().toString() + "." + name;

            if (path.endsWith("].children")) {
                return false;
            }

            return true;
        }

            

Reported by PMD.

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

Line: 45

              
    }

    public static class Person {

        private int          id;

        private List<Person> children = new ArrayList<Person>();


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/deny/DenyTest4.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: 14

              
public class DenyTest4 extends TestCase {

    public void test_0() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.deser.deny.DenyTest4$MyClassLoader\"}", Object.class);
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 21

                      } catch (JSONException ex) {
            error = ex;
        }
        assertNotNull(error);
    }
    
    public static class MyClassLoader extends ClassLoader {

    }

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.parser.ParserConfig'
Design

Line: 5

              
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.json.bvtVO.deny.A;
import junit.framework.TestCase;
import org.junit.Assert;

import java.util.Properties;

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.json.bvtVO.deny.A'
Design

Line: 6

              import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.json.bvtVO.deny.A;
import junit.framework.TestCase;
import org.junit.Assert;

import java.util.Properties;


            

Reported by PMD.

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

Line: 8

              import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.json.bvtVO.deny.A;
import junit.framework.TestCase;
import org.junit.Assert;

import java.util.Properties;

public class DenyTest4 extends TestCase {


            

Reported by PMD.

Avoid unused imports such as 'java.util.Properties'
Design

Line: 10

              import junit.framework.TestCase;
import org.junit.Assert;

import java.util.Properties;

public class DenyTest4 extends TestCase {

    public void test_0() throws Exception {
        Exception error = null;

            

Reported by PMD.

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

Line: 15

              public class DenyTest4 extends TestCase {

    public void test_0() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.deser.deny.DenyTest4$MyClassLoader\"}", Object.class);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

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

               * Created by wenshao on 16/8/25.
 */
public class Issue780 extends TestCase {
    public void test_for_issue() throws Exception {
        JSONObject json = new JSONObject();
        json.put("robj", "{abc: 123}");
        JSONObject robj = json.getJSONObject("robj");
        assertEquals(123, robj.get("abc"));
    }

            

Reported by PMD.

The String literal 'robj' appears 4 times in this file; the first occurrence is on line 13
Error

Line: 13

              public class Issue780 extends TestCase {
    public void test_for_issue() throws Exception {
        JSONObject json = new JSONObject();
        json.put("robj", "{abc: 123}");
        JSONObject robj = json.getJSONObject("robj");
        assertEquals(123, robj.get("abc"));
    }

    public void test_for_issue_array() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 15

                      JSONObject json = new JSONObject();
        json.put("robj", "{abc: 123}");
        JSONObject robj = json.getJSONObject("robj");
        assertEquals(123, robj.get("abc"));
    }

    public void test_for_issue_array() throws Exception {
        JSONObject json = new JSONObject();
        json.put("robj", "[123]");

            

Reported by PMD.

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

Line: 15

                      JSONObject json = new JSONObject();
        json.put("robj", "{abc: 123}");
        JSONObject robj = json.getJSONObject("robj");
        assertEquals(123, robj.get("abc"));
    }

    public void test_for_issue_array() throws Exception {
        JSONObject json = new JSONObject();
        json.put("robj", "[123]");

            

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

                      assertEquals(123, robj.get("abc"));
    }

    public void test_for_issue_array() throws Exception {
        JSONObject json = new JSONObject();
        json.put("robj", "[123]");
        JSONArray robj = json.getJSONArray("robj");
        assertEquals(123, robj.get(0));
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

                      JSONObject json = new JSONObject();
        json.put("robj", "[123]");
        JSONArray robj = json.getJSONArray("robj");
        assertEquals(123, robj.get(0));
    }
}

            

Reported by PMD.

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

Line: 22

                      JSONObject json = new JSONObject();
        json.put("robj", "[123]");
        JSONArray robj = json.getJSONArray("robj");
        assertEquals(123, robj.get(0));
    }
}

            

Reported by PMD.

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

Line: 54

                          out.writeInt(value.intValue());
        }
        
        if (out.isEnabled(SerializerFeature.WriteClassName)) {
            Class<?> clazz = value.getClass();
            if (clazz == Byte.class) {
                out.write('B');
            } else if (clazz == Short.class) {
                out.write('S');

            

Reported by PMD.

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

Line: 68

                  public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
        final JSONLexer lexer = parser.lexer;

        final int token = lexer.token();

        if (token == JSONToken.NULL) {
            lexer.nextToken(JSONToken.COMMA);
            return null;
        }

            

Reported by PMD.

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

Line: 96

                                  intObj = TypeUtils.castToInt(value);
                }
            }
        } catch (Exception ex) {
            String message = "parseInt error";
            if (fieldName != null) {
                message += (", field : " + fieldName);
            }
            throw new JSONException(message, ex);

            

Reported by PMD.

Found 'DU'-anomaly for variable 'intObj' (lines '81'-'110').
Error

Line: 81

                          if (token == JSONToken.LITERAL_INT) {
                int val = lexer.intValue();
                lexer.nextToken(JSONToken.COMMA);
                intObj = Integer.valueOf(val);
            } else if (token == JSONToken.LITERAL_FLOAT) {
                BigDecimal number = lexer.decimalValue();
                intObj = TypeUtils.intValue(number);
                lexer.nextToken(JSONToken.COMMA);
            } else {

            

Reported by PMD.

Found 'DU'-anomaly for variable 'intObj' (lines '84'-'110').
Error

Line: 84

                              intObj = Integer.valueOf(val);
            } else if (token == JSONToken.LITERAL_FLOAT) {
                BigDecimal number = lexer.decimalValue();
                intObj = TypeUtils.intValue(number);
                lexer.nextToken(JSONToken.COMMA);
            } else {
                if (token == JSONToken.LBRACE) {
                    JSONObject jsonObject = new JSONObject(true);
                    parser.parseObject(jsonObject);

            

Reported by PMD.

Found 'DU'-anomaly for variable 'intObj' (lines '90'-'110').
Error

Line: 90

                              if (token == JSONToken.LBRACE) {
                    JSONObject jsonObject = new JSONObject(true);
                    parser.parseObject(jsonObject);
                    intObj = TypeUtils.castToInt(jsonObject);
                } else {
                    Object value = parser.parse();
                    intObj = TypeUtils.castToInt(value);
                }
            }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'intObj' (lines '93'-'110').
Error

Line: 93

                                  intObj = TypeUtils.castToInt(jsonObject);
                } else {
                    Object value = parser.parse();
                    intObj = TypeUtils.castToInt(value);
                }
            }
        } catch (Exception ex) {
            String message = "parseInt error";
            if (fieldName != null) {

            

Reported by PMD.

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

              import junit.framework.TestCase;

public class StringFieldTest_special_3 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: 29

                      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.

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

Line: 42

              
        String text = writer.toString();

        text = text.replaceAll("&lt;", "<");
        text = text.replaceAll("&gt;", ">");

        Model model2 = JSON.parseObject(text, Model.class);
        assertEquals(model.name, model2.name);
    }

            

Reported by PMD.

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

Line: 43

                      String text = writer.toString();

        text = text.replaceAll("&lt;", "<");
        text = text.replaceAll("&gt;", ">");

        Model model2 = JSON.parseObject(text, Model.class);
        assertEquals(model.name, model2.name);
    }
    

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 46

                      text = text.replaceAll("&gt;", ">");

        Model model2 = JSON.parseObject(text, Model.class);
        assertEquals(model.name, model2.name);
    }
    
    public void test_special_browsecompatible() throws Exception {
        Model model = new Model();
        StringBuilder buf = new StringBuilder();

            

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

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

              
    private static class Model {

        public String name;

    }
}

            

Reported by PMD.

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

Line: 25

               */
public class SymbolTable {

    private final String[] symbols;
    private final int      indexMask;
    
    public SymbolTable(int tableSize){
        this.indexMask = tableSize - 1;
        this.symbols = new String[tableSize];

            

Reported by PMD.

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

Line: 26

              public class SymbolTable {

    private final String[] symbols;
    private final int      indexMask;
    
    public SymbolTable(int tableSize){
        this.indexMask = tableSize - 1;
        this.symbols = new String[tableSize];
        

            

Reported by PMD.

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

Line: 108

                      symbol = len == buffer.length() //
            ? buffer //
            : subString(buffer, offset, len);
        symbol = symbol.intern();
        symbols[bucket] = symbol;
        return symbol;
    }
    
    private static String subString(String src, int offset, int len) {

            

Reported by PMD.

Found 'DD'-anomaly for variable 'eq' (lines '56'-'66').
Error

Line: 56

                      
        String symbol = symbols[bucket];
        if (symbol != null) {
            boolean eq = true;
            if (hash == symbol.hashCode() // 
                    && len == symbol.length()) {
                for (int i = 0; i < len; i++) {
                    if (buffer[offset + i] != symbol.charAt(i)) {
                        eq = false;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'eq' (lines '56'-'61').
Error

Line: 56

                      
        String symbol = symbols[bucket];
        if (symbol != null) {
            boolean eq = true;
            if (hash == symbol.hashCode() // 
                    && len == symbol.length()) {
                for (int i = 0; i < len; i++) {
                    if (buffer[offset + i] != symbol.charAt(i)) {
                        eq = false;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'eq' (lines '61'-'66').
Error

Line: 61

                                  && len == symbol.length()) {
                for (int i = 0; i < len; i++) {
                    if (buffer[offset + i] != symbol.charAt(i)) {
                        eq = false;
                        break;
                    }
                }
            } else {
                eq = false;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'off' (lines '121'-'127').
Error

Line: 121

              
    public static int hash(char[] buffer, int offset, int len) {
        int h = 0;
        int off = offset;

        for (int i = 0; i < len; i++) {
            h = 31 * h + buffer[off++];
        }
        return h;

            

Reported by PMD.

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

              
public class BuilderTest0 extends TestCase {
    
    public void test_0() throws Exception {
        VO vo = JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);
        
        Assert.assertEquals(12304, vo.getId());
        Assert.assertEquals("ljw", vo.getName());
    }

            

Reported by PMD.

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

Line: 15

                  public void test_0() throws Exception {
        VO vo = JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);
        
        Assert.assertEquals(12304, vo.getId());
        Assert.assertEquals("ljw", vo.getName());
    }

    @JSONType(builder=VOBuilder.class)
    public static class VO {

            

Reported by PMD.

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

Line: 16

                      VO vo = JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);
        
        Assert.assertEquals(12304, vo.getId());
        Assert.assertEquals("ljw", vo.getName());
    }

    @JSONType(builder=VOBuilder.class)
    public static class VO {
        private int id;

            

Reported by PMD.

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

Line: 21

              
    @JSONType(builder=VOBuilder.class)
    public static class VO {
        private int id;
        private String name;
        
        public int getId() {
            return id;
        }

            

Reported by PMD.

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

Line: 22

                  @JSONType(builder=VOBuilder.class)
    public static class VO {
        private int id;
        private String name;
        
        public int getId() {
            return id;
        }
        

            

Reported by PMD.

Private field 'vo' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 35

              
    public static class VOBuilder {

        private VO vo = new VO();

        public VO build() {
            return vo;
        }
        

            

Reported by PMD.

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

Line: 35

              
    public static class VOBuilder {

        private VO vo = new VO();

        public VO build() {
            return vo;
        }
        

            

Reported by PMD.

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

              
public class InetSocketAddressFieldTest extends TestCase {

    public void test_codec() throws Exception {
        User user = new User();
        user.setValue(new InetSocketAddress(33));

        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 void test_codec_null_2() throws Exception {
        User user = JSON.parseObject("{\"value\":{\"address\":null,\"port\":33}}", User.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: 40

                      Assert.assertEquals(user1.getValue(), user.getValue());
    }
    
    public void test_codec_null_2() throws Exception {
        User user = JSON.parseObject("{\"value\":{\"address\":null,\"port\":33}}", User.class);

        Assert.assertEquals(33, user.getValue().getPort());
    }


            

Reported by PMD.

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

Line: 43

                  public void test_codec_null_2() throws Exception {
        User user = JSON.parseObject("{\"value\":{\"address\":null,\"port\":33}}", User.class);

        Assert.assertEquals(33, user.getValue().getPort());
    }

    public static class User {

        private InetSocketAddress value;

            

Reported by PMD.

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

Line: 43

                  public void test_codec_null_2() throws Exception {
        User user = JSON.parseObject("{\"value\":{\"address\":null,\"port\":33}}", User.class);

        Assert.assertEquals(33, user.getValue().getPort());
    }

    public static class User {

        private InetSocketAddress value;

            

Reported by PMD.