The following issues were found

src/test/java/com/alibaba/json/bvt/path/JSONPath_field_access_filter_like_simple.java
55 issues
This class has too many methods, consider refactoring it.
Design

Line: 12

              
import com.alibaba.fastjson.JSONPath;

public class JSONPath_field_access_filter_like_simple extends TestCase {

    public void test_list_like_extract() throws Exception {
        JSONPath path = new JSONPath("$[name like 'ljw2083']");

        List<Entity> entities = new ArrayList<Entity>();

            

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

    public void test_list_like_extract() throws Exception {
        JSONPath path = new JSONPath("$[name like 'ljw2083']");

        List<Entity> entities = new ArrayList<Entity>();
        entities.add(new Entity(1001, "ljw2083"));
        entities.add(new Entity(1002, "wenshao"));

            

Reported by PMD.

The String literal 'ljw2083' appears 14 times in this file; the first occurrence is on line 18
Error

Line: 18

                      JSONPath path = new JSONPath("$[name like 'ljw2083']");

        List<Entity> entities = new ArrayList<Entity>();
        entities.add(new Entity(1001, "ljw2083"));
        entities.add(new Entity(1002, "wenshao"));
        entities.add(new Entity(1003, null));
        entities.add(new Entity(null, null));

        List<Object> result = (List<Object>) path.eval(entities);

            

Reported by PMD.

The String literal 'wenshao' appears 14 times in this file; the first occurrence is on line 19
Error

Line: 19

              
        List<Entity> entities = new ArrayList<Entity>();
        entities.add(new Entity(1001, "ljw2083"));
        entities.add(new Entity(1002, "wenshao"));
        entities.add(new Entity(1003, null));
        entities.add(new Entity(null, null));

        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(1, result.size());

            

Reported by PMD.

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

Line: 24

                      entities.add(new Entity(null, null));

        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(1, result.size());
        Assert.assertSame(entities.get(0), result.get(0));
    }
    
    public void test_list_not_like_extract() throws Exception {
        JSONPath path = new JSONPath("$[name not like 'ljw2083']");

            

Reported by PMD.

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

Line: 25

              
        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(1, result.size());
        Assert.assertSame(entities.get(0), result.get(0));
    }
    
    public void test_list_not_like_extract() throws Exception {
        JSONPath path = new JSONPath("$[name not like 'ljw2083']");


            

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.assertSame(entities.get(0), result.get(0));
    }
    
    public void test_list_not_like_extract() throws Exception {
        JSONPath path = new JSONPath("$[name not like 'ljw2083']");

        List<Entity> entities = new ArrayList<Entity>();
        entities.add(new Entity(1001, "ljw2083"));
        entities.add(new Entity(1002, "wenshao"));

            

Reported by PMD.

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

Line: 34

                      List<Entity> entities = new ArrayList<Entity>();
        entities.add(new Entity(1001, "ljw2083"));
        entities.add(new Entity(1002, "wenshao"));
        entities.add(new Entity(1003, "yakolee"));
        entities.add(new Entity(null, null));

        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(3, result.size());
        Assert.assertSame(entities.get(1), result.get(0));

            

Reported by PMD.

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

Line: 38

                      entities.add(new Entity(null, null));

        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(3, result.size());
        Assert.assertSame(entities.get(1), result.get(0));
        Assert.assertSame(entities.get(2), result.get(1));
        Assert.assertSame(entities.get(3), result.get(2));
    }
    

            

Reported by PMD.

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

Line: 39

              
        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(3, result.size());
        Assert.assertSame(entities.get(1), result.get(0));
        Assert.assertSame(entities.get(2), result.get(1));
        Assert.assertSame(entities.get(3), result.get(2));
    }
    
    public void test_list_like_left_match() throws Exception {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/support/spring/mock/testcase/FastJsonViewTest.java
54 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 34

              public class FastJsonViewTest {

    @Autowired
    private WebApplicationContext wac;

    private MockMvc mockMvc;

    @Before
    public void setup() {

            

Reported by PMD.

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

Line: 36

                  @Autowired
    private WebApplicationContext wac;

    private MockMvc mockMvc;

    @Before
    public void setup() {
        this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac) //
                .addFilter(new CharacterEncodingFilter("UTF-8", true)) // 设置服务器端返回的字符集为:UTF-8

            

Reported by PMD.

The String literal 'UTF-8' appears 7 times in this file; the first occurrence is on line 41
Error

Line: 41

                  @Before
    public void setup() {
        this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac) //
                .addFilter(new CharacterEncodingFilter("UTF-8", true)) // 设置服务器端返回的字符集为:UTF-8
                .build();
    }

    @Test
    public void isInjectComponent() {

            

Reported by PMD.

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

Line: 46

                  }

    @Test
    public void isInjectComponent() {
        wac.getBean(FastJsonViewResponseBodyAdvice.class);
    }

    /**
     * 只包括简单属性的对象,单独使用include属性

            

Reported by PMD.

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

Line: 54

                   * 只包括简单属性的对象,单独使用include属性
     */
    @Test
    public void test1() throws Exception {
        mockMvc.perform(
                (post("/fastjsonview/test1").characterEncoding("UTF-8")
                        .contentType(MediaType.APPLICATION_JSON))).andExpect(status
                ().isOk()).andDo(print()
        ).andExpect(content().string("{\"id\":100,\"name\":\"测试\"}"));

            

Reported by PMD.

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

Line: 55

                   */
    @Test
    public void test1() throws Exception {
        mockMvc.perform(
                (post("/fastjsonview/test1").characterEncoding("UTF-8")
                        .contentType(MediaType.APPLICATION_JSON))).andExpect(status
                ().isOk()).andDo(print()
        ).andExpect(content().string("{\"id\":100,\"name\":\"测试\"}"));
    }

            

Reported by PMD.

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

Line: 55

                   */
    @Test
    public void test1() throws Exception {
        mockMvc.perform(
                (post("/fastjsonview/test1").characterEncoding("UTF-8")
                        .contentType(MediaType.APPLICATION_JSON))).andExpect(status
                ().isOk()).andDo(print()
        ).andExpect(content().string("{\"id\":100,\"name\":\"测试\"}"));
    }

            

Reported by PMD.

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

Line: 55

                   */
    @Test
    public void test1() throws Exception {
        mockMvc.perform(
                (post("/fastjsonview/test1").characterEncoding("UTF-8")
                        .contentType(MediaType.APPLICATION_JSON))).andExpect(status
                ().isOk()).andDo(print()
        ).andExpect(content().string("{\"id\":100,\"name\":\"测试\"}"));
    }

            

Reported by PMD.

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

Line: 56

                  @Test
    public void test1() throws Exception {
        mockMvc.perform(
                (post("/fastjsonview/test1").characterEncoding("UTF-8")
                        .contentType(MediaType.APPLICATION_JSON))).andExpect(status
                ().isOk()).andDo(print()
        ).andExpect(content().string("{\"id\":100,\"name\":\"测试\"}"));
    }


            

Reported by PMD.

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

Line: 56

                  @Test
    public void test1() throws Exception {
        mockMvc.perform(
                (post("/fastjsonview/test1").characterEncoding("UTF-8")
                        .contentType(MediaType.APPLICATION_JSON))).andExpect(status
                ().isOk()).andDo(print()
        ).andExpect(content().string("{\"id\":100,\"name\":\"测试\"}"));
    }


            

Reported by PMD.

src/main/java/com/alibaba/fastjson/serializer/MapSerializer.java
54 issues
The class 'MapSerializer' has a Modified Cyclomatic Complexity of 28 (Highest = 53).
Design

Line: 29

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public class MapSerializer extends SerializeFilterable implements ObjectSerializer {

    public static MapSerializer instance = new MapSerializer();

    private static final int NON_STRINGKEY_AS_STRING = SerializerFeature.of(
            new SerializerFeature[] {

            

Reported by PMD.

Possible God Class (WMC=79, ATFD=51, TCC=0.000%)
Design

Line: 29

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public class MapSerializer extends SerializeFilterable implements ObjectSerializer {

    public static MapSerializer instance = new MapSerializer();

    private static final int NON_STRINGKEY_AS_STRING = SerializerFeature.of(
            new SerializerFeature[] {

            

Reported by PMD.

The class 'MapSerializer' has a Standard Cyclomatic Complexity of 28 (Highest = 53).
Design

Line: 29

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public class MapSerializer extends SerializeFilterable implements ObjectSerializer {

    public static MapSerializer instance = new MapSerializer();

    private static final int NON_STRINGKEY_AS_STRING = SerializerFeature.of(
            new SerializerFeature[] {

            

Reported by PMD.

The method 'write' has a Standard Cyclomatic Complexity of 53.
Design

Line: 48

                  }

    @SuppressWarnings({ "rawtypes"})
    public void write(JSONSerializer serializer
            , Object object
            , Object fieldName
            , Type fieldType
            , int features //
            , boolean unwrapped) throws IOException {

            

Reported by PMD.

The method 'write(JSONSerializer, Object, Object, Type, int, boolean)' has a NCSS line count of 144.
Design

Line: 48

                  }

    @SuppressWarnings({ "rawtypes"})
    public void write(JSONSerializer serializer
            , Object object
            , Object fieldName
            , Type fieldType
            , int features //
            , boolean unwrapped) throws IOException {

            

Reported by PMD.

The method 'write(JSONSerializer, Object, Object, Type, int, boolean)' has a cyclomatic complexity of 78.
Design

Line: 48

                  }

    @SuppressWarnings({ "rawtypes"})
    public void write(JSONSerializer serializer
            , Object object
            , Object fieldName
            , Type fieldType
            , int features //
            , boolean unwrapped) throws IOException {

            

Reported by PMD.

The method write() has an NCSS line count of 144
Design

Line: 48

                  }

    @SuppressWarnings({ "rawtypes"})
    public void write(JSONSerializer serializer
            , Object object
            , Object fieldName
            , Type fieldType
            , int features //
            , boolean unwrapped) throws IOException {

            

Reported by PMD.

The method 'write(JSONSerializer, Object, Object, Type, int, boolean)' has an NPath complexity of 2147483647, current threshold is 200
Design

Line: 48

                  }

    @SuppressWarnings({ "rawtypes"})
    public void write(JSONSerializer serializer
            , Object object
            , Object fieldName
            , Type fieldType
            , int features //
            , boolean unwrapped) throws IOException {

            

Reported by PMD.

The method 'write' has a Modified Cyclomatic Complexity of 53.
Design

Line: 48

                  }

    @SuppressWarnings({ "rawtypes"})
    public void write(JSONSerializer serializer
            , Object object
            , Object fieldName
            , Type fieldType
            , int features //
            , boolean unwrapped) throws IOException {

            

Reported by PMD.

Avoid really long methods.
Design

Line: 48

                  }

    @SuppressWarnings({ "rawtypes"})
    public void write(JSONSerializer serializer
            , Object object
            , Object fieldName
            , Type fieldType
            , int features //
            , boolean unwrapped) throws IOException {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/SqlTimestampTest.java
54 issues
System.out.println is used
Design

Line: 29

                              12345678
        );

        System.out.println('"' + ts.toString() + '"');

        String json = JSON.toJSONString(ts, SerializerFeature.UseISO8601DateFormat);
        System.out.println(json);
        Timestamp ts2 = JSON.parseObject(json, Timestamp.class);
        String json2 = JSON.toJSONString(ts2, SerializerFeature.UseISO8601DateFormat);

            

Reported by PMD.

System.out.println is used
Design

Line: 32

                      System.out.println('"' + ts.toString() + '"');

        String json = JSON.toJSONString(ts, SerializerFeature.UseISO8601DateFormat);
        System.out.println(json);
        Timestamp ts2 = JSON.parseObject(json, Timestamp.class);
        String json2 = JSON.toJSONString(ts2, SerializerFeature.UseISO8601DateFormat);
        System.out.println(json2);
        assertEquals('"' + ts.toString() + '"', '"' + ts2.toString() + '"');
    }

            

Reported by PMD.

System.out.println is used
Design

Line: 35

                      System.out.println(json);
        Timestamp ts2 = JSON.parseObject(json, Timestamp.class);
        String json2 = JSON.toJSONString(ts2, SerializerFeature.UseISO8601DateFormat);
        System.out.println(json2);
        assertEquals('"' + ts.toString() + '"', '"' + ts2.toString() + '"');
    }

    public void test_date_1() throws Exception {
        // 2020-04-11 03:10:19.516

            

Reported by PMD.

System.out.println is used
Design

Line: 51

                              516000000
        );

        System.out.println('"' + ts.toString() + '"');

        String json = JSON.toJSONString(ts, SerializerFeature.UseISO8601DateFormat);
        System.out.println(json);
        Timestamp ts2 = JSON.parseObject(json, Timestamp.class);
        String json2 = JSON.toJSONString(ts2, SerializerFeature.UseISO8601DateFormat);

            

Reported by PMD.

System.out.println is used
Design

Line: 54

                      System.out.println('"' + ts.toString() + '"');

        String json = JSON.toJSONString(ts, SerializerFeature.UseISO8601DateFormat);
        System.out.println(json);
        Timestamp ts2 = JSON.parseObject(json, Timestamp.class);
        String json2 = JSON.toJSONString(ts2, SerializerFeature.UseISO8601DateFormat);
        System.out.println(json2);
        assertEquals('"' + ts.toString() + '"', '"' + ts2.toString() + '"');
    }

            

Reported by PMD.

System.out.println is used
Design

Line: 57

                      System.out.println(json);
        Timestamp ts2 = JSON.parseObject(json, Timestamp.class);
        String json2 = JSON.toJSONString(ts2, SerializerFeature.UseISO8601DateFormat);
        System.out.println(json2);
        assertEquals('"' + ts.toString() + '"', '"' + ts2.toString() + '"');
    }

    // 1997-03-17 15:53:01.01
    public void test_date_2() throws Exception {

            

Reported by PMD.

System.out.println is used
Design

Line: 74

                              10000000
        );

        System.out.println('"' + ts.toString() + '"');

        String json = JSON.toJSONString(ts, SerializerFeature.UseISO8601DateFormat);
        System.out.println(json);
        Timestamp ts2 = JSON.parseObject(json, Timestamp.class);
        String json2 = JSON.toJSONString(ts2, SerializerFeature.UseISO8601DateFormat);

            

Reported by PMD.

System.out.println is used
Design

Line: 77

                      System.out.println('"' + ts.toString() + '"');

        String json = JSON.toJSONString(ts, SerializerFeature.UseISO8601DateFormat);
        System.out.println(json);
        Timestamp ts2 = JSON.parseObject(json, Timestamp.class);
        String json2 = JSON.toJSONString(ts2, SerializerFeature.UseISO8601DateFormat);
        System.out.println(json2);
        assertEquals('"' + ts.toString() + '"', '"' + ts2.toString() + '"');
    }

            

Reported by PMD.

System.out.println is used
Design

Line: 80

                      System.out.println(json);
        Timestamp ts2 = JSON.parseObject(json, Timestamp.class);
        String json2 = JSON.toJSONString(ts2, SerializerFeature.UseISO8601DateFormat);
        System.out.println(json2);
        assertEquals('"' + ts.toString() + '"', '"' + ts2.toString() + '"');
    }

    public void test_date_999999999() throws Exception {
        // 2020-04-11 03:10:19.516

            

Reported by PMD.

System.out.println is used
Design

Line: 96

                              999999999
        );

        System.out.println('"' + ts.toString() + '"');

        String json = JSON.toJSONString(ts, SerializerFeature.UseISO8601DateFormat);
        System.out.println(json);
        Timestamp ts2 = JSON.parseObject(json, Timestamp.class);
        String json2 = JSON.toJSONString(ts2, SerializerFeature.UseISO8601DateFormat);

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/BigStringFieldTest_private.java
54 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 16

              import junit.framework.TestCase;

public class BigStringFieldTest_private extends TestCase {
    public void test_bigFieldString() throws Exception {
        Model model = new Model();
        model.f0 = random(1024);
        model.f1 = random(1024);
        model.f2 = random(1024);
        model.f3 = random(1024);

            

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

              import junit.framework.TestCase;

public class BigStringFieldTest_private extends TestCase {
    public void test_bigFieldString() throws Exception {
        Model model = new Model();
        model.f0 = random(1024);
        model.f1 = random(1024);
        model.f2 = random(1024);
        model.f3 = random(1024);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 26

                      
        String text = JSON.toJSONString(model);
        Model model2 = JSON.parseObject(text, Model.class);
        assertEquals(model2.f0, model.f0);
        assertEquals(model2.f1, model.f1);
        assertEquals(model2.f2, model.f2);
        assertEquals(model2.f3, model.f3);
        assertEquals(model2.f4, model.f4);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 27

                      String text = JSON.toJSONString(model);
        Model model2 = JSON.parseObject(text, Model.class);
        assertEquals(model2.f0, model.f0);
        assertEquals(model2.f1, model.f1);
        assertEquals(model2.f2, model.f2);
        assertEquals(model2.f3, model.f3);
        assertEquals(model2.f4, model.f4);
    }
    

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 28

                      Model model2 = JSON.parseObject(text, Model.class);
        assertEquals(model2.f0, model.f0);
        assertEquals(model2.f1, model.f1);
        assertEquals(model2.f2, model.f2);
        assertEquals(model2.f3, model.f3);
        assertEquals(model2.f4, model.f4);
    }
    
    public void test_list() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

                      assertEquals(model2.f0, model.f0);
        assertEquals(model2.f1, model.f1);
        assertEquals(model2.f2, model.f2);
        assertEquals(model2.f3, model.f3);
        assertEquals(model2.f4, model.f4);
    }
    
    public void test_list() throws Exception {
        List<Model> list = new ArrayList<Model>();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

                      assertEquals(model2.f1, model.f1);
        assertEquals(model2.f2, model.f2);
        assertEquals(model2.f3, model.f3);
        assertEquals(model2.f4, model.f4);
    }
    
    public void test_list() throws Exception {
        List<Model> list = new ArrayList<Model>();
        for (int i = 0; i < 1000; ++i) {

            

Reported by PMD.

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

Line: 33

                      assertEquals(model2.f4, model.f4);
    }
    
    public void test_list() throws Exception {
        List<Model> list = new ArrayList<Model>();
        for (int i = 0; i < 1000; ++i) {
            Model model = new Model();
            model.f0 = random(64);
            model.f1 = random(64);

            

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

                      assertEquals(model2.f4, model.f4);
    }
    
    public void test_list() throws Exception {
        List<Model> list = new ArrayList<Model>();
        for (int i = 0; i < 1000; ++i) {
            Model model = new Model();
            model.f0 = random(64);
            model.f1 = random(64);

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 36

                  public void test_list() throws Exception {
        List<Model> list = new ArrayList<Model>();
        for (int i = 0; i < 1000; ++i) {
            Model model = new Model();
            model.f0 = random(64);
            model.f1 = random(64);
            model.f2 = random(64);
            model.f3 = random(64);
            model.f4 = random(64);

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/LexerTest.java
52 issues
This class has too many methods, consider refactoring it.
Design

Line: 29

              import com.alibaba.fastjson.parser.JSONScanner;
import com.alibaba.fastjson.parser.JSONToken;

public class LexerTest extends TestCase {

    public void test_float() throws Exception {
        String text = "123456789.0123";
        JSONScanner lexer = new JSONScanner(text);
        lexer.nextToken();

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 31

              
public class LexerTest extends TestCase {

    public void test_float() throws Exception {
        String text = "123456789.0123";
        JSONScanner lexer = new JSONScanner(text);
        lexer.nextToken();
        BigDecimal decimalValue = lexer.decimalValue();
        Assert.assertEquals(new BigDecimal("123456789.0123"), decimalValue);

            

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

              
    }

    public void test_string() throws Exception {
        {
            JSONScanner lexer = new JSONScanner("\"中国\"");
            lexer.nextToken();
            Assert.assertEquals("中国", lexer.stringVal());
        }

            

Reported by PMD.

StringBuffer constructor is initialized with size 16, but has at least 29 characters appended.
Performance

Line: 57

                          Assert.assertEquals("中国\tV5", lexer.stringVal());
        }

        StringBuilder buf = new StringBuilder();

        buf.append('"');
        buf.append("\\\\\\/\\b\\f\\n\\r\\t\\u" + Integer.toHexString('中'));
        buf.append('"');
        buf.append('\u2001');

            

Reported by PMD.

StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
Performance

Line: 59

              
        StringBuilder buf = new StringBuilder();

        buf.append('"');
        buf.append("\\\\\\/\\b\\f\\n\\r\\t\\u" + Integer.toHexString('中'));
        buf.append('"');
        buf.append('\u2001');

        String text = buf.toString();

            

Reported by PMD.

StringBuffer (or StringBuilder).append is called 2 consecutive times with literals. Use a single append with a single combined String.
Performance

Line: 59

              
        StringBuilder buf = new StringBuilder();

        buf.append('"');
        buf.append("\\\\\\/\\b\\f\\n\\r\\t\\u" + Integer.toHexString('中'));
        buf.append('"');
        buf.append('\u2001');

        String text = buf.toString();

            

Reported by PMD.

Avoid concatenating nonliterals in a StringBuffer/StringBuilder constructor or append().
Performance

Line: 60

                      StringBuilder buf = new StringBuilder();

        buf.append('"');
        buf.append("\\\\\\/\\b\\f\\n\\r\\t\\u" + Integer.toHexString('中'));
        buf.append('"');
        buf.append('\u2001');

        String text = buf.toString();


            

Reported by PMD.

StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
Performance

Line: 60

                      StringBuilder buf = new StringBuilder();

        buf.append('"');
        buf.append("\\\\\\/\\b\\f\\n\\r\\t\\u" + Integer.toHexString('中'));
        buf.append('"');
        buf.append('\u2001');

        String text = buf.toString();


            

Reported by PMD.

StringBuffer (or StringBuilder).append is called 2 consecutive times with literals. Use a single append with a single combined String.
Performance

Line: 61

              
        buf.append('"');
        buf.append("\\\\\\/\\b\\f\\n\\r\\t\\u" + Integer.toHexString('中'));
        buf.append('"');
        buf.append('\u2001');

        String text = buf.toString();

        JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length() - 1);

            

Reported by PMD.

StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
Performance

Line: 61

              
        buf.append('"');
        buf.append("\\\\\\/\\b\\f\\n\\r\\t\\u" + Integer.toHexString('中'));
        buf.append('"');
        buf.append('\u2001');

        String text = buf.toString();

        JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length() - 1);

            

Reported by PMD.

src/test/java/com/alibaba/json/test/FNV32_CollisionTest_2.java
52 issues
System.out.println is used
Design

Line: 29

              
        long id_hash_64 = fnv_hash("name".toCharArray());
        int id_hash_32 = (int) id_hash_64;
        System.out.println("name : " + id_hash_32 + ", " + id_hash_64);

        long v = 0;
        long time = System.currentTimeMillis();
        NumberFormat format = NumberFormat.getInstance();


            

Reported by PMD.

System.out.println is used
Design

Line: 97

                                                  v++;
                                    if (h6 == id_hash_64) {
                                        int hash_32 = (int) h6;
                                        System.out.println("collision : " + build(v, len) + ", hash64 : " + h6 + ", hash 32 " + hash_32);
                                        break;
                                    }

                                    if (v != 0 && v % (1000 * 1000 * 1000) == 0) {
                                        long now = System.currentTimeMillis();

            

Reported by PMD.

System.out.println is used
Design

Line: 105

                                                      long now = System.currentTimeMillis();
                                        long millis = now - time;
                                        time = now;
                                        System.out.println("millis : " + millis + ", " + format.format(v));
                                    }
                                }
                            }
                        }
                    }

            

Reported by PMD.

System.out.println is used
Design

Line: 116

                      }


        System.out.println("end : " + len);

    }

    String build(long v, int len) {
        char[] chars = new char[len];

            

Reported by PMD.

The class 'FNV32_CollisionTest_2' has a Standard Cyclomatic Complexity of 4 (Highest = 10).
Design

Line: 11

              /**
 * Created by wenshao on 08/01/2017.
 */
public class FNV32_CollisionTest_2 extends TestCase {
    char[] digLetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_".toCharArray();
    //char[] digLetters = "0123456789".toCharArray();
    Random r = new Random();
    int[] powers = new int[10];


            

Reported by PMD.

The class 'FNV32_CollisionTest_2' has a Modified Cyclomatic Complexity of 4 (Highest = 10).
Design

Line: 11

              /**
 * Created by wenshao on 08/01/2017.
 */
public class FNV32_CollisionTest_2 extends TestCase {
    char[] digLetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_".toCharArray();
    //char[] digLetters = "0123456789".toCharArray();
    Random r = new Random();
    int[] powers = new int[10];


            

Reported by PMD.

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

Line: 12

               * Created by wenshao on 08/01/2017.
 */
public class FNV32_CollisionTest_2 extends TestCase {
    char[] digLetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_".toCharArray();
    //char[] digLetters = "0123456789".toCharArray();
    Random r = new Random();
    int[] powers = new int[10];

    {

            

Reported by PMD.

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

Line: 15

                  char[] digLetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_".toCharArray();
    //char[] digLetters = "0123456789".toCharArray();
    Random r = new Random();
    int[] powers = new int[10];

    {
        for (int i = 0; i < powers.length; ++i) {
            powers[i] = (int) Math.pow(digLetters.length, i);
        }

            

Reported by PMD.

Non-static initializers are confusing
Error

Line: 17

                  Random r = new Random();
    int[] powers = new int[10];

    {
        for (int i = 0; i < powers.length; ++i) {
            powers[i] = (int) Math.pow(digLetters.length, 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: 24

                  }


    public void test_fnv_hash_7() throws Exception {
        int COUNT = 1000 * 1000 * 1000;

        long id_hash_64 = fnv_hash("name".toCharArray());
        int id_hash_32 = (int) id_hash_64;
        System.out.println("name : " + id_hash_32 + ", " + id_hash_64);

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_2200/Issue2249.java
51 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 9

              import junit.framework.TestCase;

public class Issue2249 extends TestCase {
    public void test_for_issue() throws Exception {
        assertSame(Type.Big, JSON.parseObject("\"big\"", Type.class));
        assertSame(Type.Big, JSON.parseObject("\"Big\"", Type.class));
        assertSame(Type.Big, JSON.parseObject("\"BIG\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"Small\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"small\"", Type.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: 9

              import junit.framework.TestCase;

public class Issue2249 extends TestCase {
    public void test_for_issue() throws Exception {
        assertSame(Type.Big, JSON.parseObject("\"big\"", Type.class));
        assertSame(Type.Big, JSON.parseObject("\"Big\"", Type.class));
        assertSame(Type.Big, JSON.parseObject("\"BIG\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"Small\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"small\"", Type.class));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 10

              
public class Issue2249 extends TestCase {
    public void test_for_issue() throws Exception {
        assertSame(Type.Big, JSON.parseObject("\"big\"", Type.class));
        assertSame(Type.Big, JSON.parseObject("\"Big\"", Type.class));
        assertSame(Type.Big, JSON.parseObject("\"BIG\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"Small\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"small\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"SMALL\"", Type.class));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 11

              public class Issue2249 extends TestCase {
    public void test_for_issue() throws Exception {
        assertSame(Type.Big, JSON.parseObject("\"big\"", Type.class));
        assertSame(Type.Big, JSON.parseObject("\"Big\"", Type.class));
        assertSame(Type.Big, JSON.parseObject("\"BIG\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"Small\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"small\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"SMALL\"", Type.class));
        assertSame(Type.Medium, JSON.parseObject("\"medium\"", Type.class));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 12

                  public void test_for_issue() throws Exception {
        assertSame(Type.Big, JSON.parseObject("\"big\"", Type.class));
        assertSame(Type.Big, JSON.parseObject("\"Big\"", Type.class));
        assertSame(Type.Big, JSON.parseObject("\"BIG\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"Small\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"small\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"SMALL\"", Type.class));
        assertSame(Type.Medium, JSON.parseObject("\"medium\"", Type.class));
        assertSame(Type.Medium, JSON.parseObject("\"MEDIUM\"", Type.class));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 13

                      assertSame(Type.Big, JSON.parseObject("\"big\"", Type.class));
        assertSame(Type.Big, JSON.parseObject("\"Big\"", Type.class));
        assertSame(Type.Big, JSON.parseObject("\"BIG\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"Small\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"small\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"SMALL\"", Type.class));
        assertSame(Type.Medium, JSON.parseObject("\"medium\"", Type.class));
        assertSame(Type.Medium, JSON.parseObject("\"MEDIUM\"", Type.class));
        assertSame(Type.Medium, JSON.parseObject("\"Medium\"", Type.class));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

                      assertSame(Type.Big, JSON.parseObject("\"Big\"", Type.class));
        assertSame(Type.Big, JSON.parseObject("\"BIG\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"Small\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"small\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"SMALL\"", Type.class));
        assertSame(Type.Medium, JSON.parseObject("\"medium\"", Type.class));
        assertSame(Type.Medium, JSON.parseObject("\"MEDIUM\"", Type.class));
        assertSame(Type.Medium, JSON.parseObject("\"Medium\"", Type.class));
        assertSame(Type.Medium, JSON.parseObject("\"MediuM\"", Type.class));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 15

                      assertSame(Type.Big, JSON.parseObject("\"BIG\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"Small\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"small\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"SMALL\"", Type.class));
        assertSame(Type.Medium, JSON.parseObject("\"medium\"", Type.class));
        assertSame(Type.Medium, JSON.parseObject("\"MEDIUM\"", Type.class));
        assertSame(Type.Medium, JSON.parseObject("\"Medium\"", Type.class));
        assertSame(Type.Medium, JSON.parseObject("\"MediuM\"", Type.class));
        assertNull(JSON.parseObject("\"\"", Type.class));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                      assertSame(Type.Small, JSON.parseObject("\"Small\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"small\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"SMALL\"", Type.class));
        assertSame(Type.Medium, JSON.parseObject("\"medium\"", Type.class));
        assertSame(Type.Medium, JSON.parseObject("\"MEDIUM\"", Type.class));
        assertSame(Type.Medium, JSON.parseObject("\"Medium\"", Type.class));
        assertSame(Type.Medium, JSON.parseObject("\"MediuM\"", Type.class));
        assertNull(JSON.parseObject("\"\"", Type.class));
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                      assertSame(Type.Small, JSON.parseObject("\"small\"", Type.class));
        assertSame(Type.Small, JSON.parseObject("\"SMALL\"", Type.class));
        assertSame(Type.Medium, JSON.parseObject("\"medium\"", Type.class));
        assertSame(Type.Medium, JSON.parseObject("\"MEDIUM\"", Type.class));
        assertSame(Type.Medium, JSON.parseObject("\"Medium\"", Type.class));
        assertSame(Type.Medium, JSON.parseObject("\"MediuM\"", Type.class));
        assertNull(JSON.parseObject("\"\"", Type.class));
    }


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/JSONTest.java
51 issues
This class has too many methods, consider refactoring it.
Design

Line: 31

              import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializeWriter;

public class JSONTest extends TestCase {

    public void test_number() throws Exception {
        Assert.assertEquals("3", JSON.parse("3").toString());
        Assert.assertEquals("34", JSON.parse("34").toString());
        Assert.assertEquals("922337203685477580755", JSON.parse("922337203685477580755").toString());

            

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

              
public class JSONTest extends TestCase {

    public void test_number() throws Exception {
        Assert.assertEquals("3", JSON.parse("3").toString());
        Assert.assertEquals("34", JSON.parse("34").toString());
        Assert.assertEquals("922337203685477580755", JSON.parse("922337203685477580755").toString());
        Assert.assertEquals("-34", JSON.parse("-34").toString());
        Assert.assertEquals(new BigDecimal("9.223372036854776E18"), new BigDecimal(JSON.parse("9.223372036854776E18").toString()));

            

Reported by PMD.

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

Line: 34

              public class JSONTest extends TestCase {

    public void test_number() throws Exception {
        Assert.assertEquals("3", JSON.parse("3").toString());
        Assert.assertEquals("34", JSON.parse("34").toString());
        Assert.assertEquals("922337203685477580755", JSON.parse("922337203685477580755").toString());
        Assert.assertEquals("-34", JSON.parse("-34").toString());
        Assert.assertEquals(new BigDecimal("9.223372036854776E18"), new BigDecimal(JSON.parse("9.223372036854776E18").toString()));
        Assert.assertEquals(new BigDecimal("9.223372036854776E+18"), new BigDecimal(JSON.parse("9.223372036854776E+18").toString()));

            

Reported by PMD.

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

Line: 35

              
    public void test_number() throws Exception {
        Assert.assertEquals("3", JSON.parse("3").toString());
        Assert.assertEquals("34", JSON.parse("34").toString());
        Assert.assertEquals("922337203685477580755", JSON.parse("922337203685477580755").toString());
        Assert.assertEquals("-34", JSON.parse("-34").toString());
        Assert.assertEquals(new BigDecimal("9.223372036854776E18"), new BigDecimal(JSON.parse("9.223372036854776E18").toString()));
        Assert.assertEquals(new BigDecimal("9.223372036854776E+18"), new BigDecimal(JSON.parse("9.223372036854776E+18").toString()));
        Assert.assertEquals(new BigDecimal("9.223372036854776E-18"), new BigDecimal(JSON.parse("9.223372036854776E-18").toString()));

            

Reported by PMD.

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

Line: 36

                  public void test_number() throws Exception {
        Assert.assertEquals("3", JSON.parse("3").toString());
        Assert.assertEquals("34", JSON.parse("34").toString());
        Assert.assertEquals("922337203685477580755", JSON.parse("922337203685477580755").toString());
        Assert.assertEquals("-34", JSON.parse("-34").toString());
        Assert.assertEquals(new BigDecimal("9.223372036854776E18"), new BigDecimal(JSON.parse("9.223372036854776E18").toString()));
        Assert.assertEquals(new BigDecimal("9.223372036854776E+18"), new BigDecimal(JSON.parse("9.223372036854776E+18").toString()));
        Assert.assertEquals(new BigDecimal("9.223372036854776E-18"), new BigDecimal(JSON.parse("9.223372036854776E-18").toString()));
    }

            

Reported by PMD.

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

Line: 37

                      Assert.assertEquals("3", JSON.parse("3").toString());
        Assert.assertEquals("34", JSON.parse("34").toString());
        Assert.assertEquals("922337203685477580755", JSON.parse("922337203685477580755").toString());
        Assert.assertEquals("-34", JSON.parse("-34").toString());
        Assert.assertEquals(new BigDecimal("9.223372036854776E18"), new BigDecimal(JSON.parse("9.223372036854776E18").toString()));
        Assert.assertEquals(new BigDecimal("9.223372036854776E+18"), new BigDecimal(JSON.parse("9.223372036854776E+18").toString()));
        Assert.assertEquals(new BigDecimal("9.223372036854776E-18"), new BigDecimal(JSON.parse("9.223372036854776E-18").toString()));
    }


            

Reported by PMD.

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

Line: 38

                      Assert.assertEquals("34", JSON.parse("34").toString());
        Assert.assertEquals("922337203685477580755", JSON.parse("922337203685477580755").toString());
        Assert.assertEquals("-34", JSON.parse("-34").toString());
        Assert.assertEquals(new BigDecimal("9.223372036854776E18"), new BigDecimal(JSON.parse("9.223372036854776E18").toString()));
        Assert.assertEquals(new BigDecimal("9.223372036854776E+18"), new BigDecimal(JSON.parse("9.223372036854776E+18").toString()));
        Assert.assertEquals(new BigDecimal("9.223372036854776E-18"), new BigDecimal(JSON.parse("9.223372036854776E-18").toString()));
    }

    public void test_string() throws Exception {

            

Reported by PMD.

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

Line: 39

                      Assert.assertEquals("922337203685477580755", JSON.parse("922337203685477580755").toString());
        Assert.assertEquals("-34", JSON.parse("-34").toString());
        Assert.assertEquals(new BigDecimal("9.223372036854776E18"), new BigDecimal(JSON.parse("9.223372036854776E18").toString()));
        Assert.assertEquals(new BigDecimal("9.223372036854776E+18"), new BigDecimal(JSON.parse("9.223372036854776E+18").toString()));
        Assert.assertEquals(new BigDecimal("9.223372036854776E-18"), new BigDecimal(JSON.parse("9.223372036854776E-18").toString()));
    }

    public void test_string() throws Exception {
        Assert.assertEquals("", JSON.parse("\"\"").toString());

            

Reported by PMD.

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

Line: 40

                      Assert.assertEquals("-34", JSON.parse("-34").toString());
        Assert.assertEquals(new BigDecimal("9.223372036854776E18"), new BigDecimal(JSON.parse("9.223372036854776E18").toString()));
        Assert.assertEquals(new BigDecimal("9.223372036854776E+18"), new BigDecimal(JSON.parse("9.223372036854776E+18").toString()));
        Assert.assertEquals(new BigDecimal("9.223372036854776E-18"), new BigDecimal(JSON.parse("9.223372036854776E-18").toString()));
    }

    public void test_string() throws Exception {
        Assert.assertEquals("", JSON.parse("\"\"").toString());
        Assert.assertEquals("3", JSON.parse("\"3\"").toString());

            

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(new BigDecimal("9.223372036854776E-18"), new BigDecimal(JSON.parse("9.223372036854776E-18").toString()));
    }

    public void test_string() throws Exception {
        Assert.assertEquals("", JSON.parse("\"\"").toString());
        Assert.assertEquals("3", JSON.parse("\"3\"").toString());
        Assert.assertEquals("34", JSON.parse("\"34\"").toString());
        Assert.assertEquals("3\\4", JSON.parse("\"3\\\\4\"").toString());
        Assert.assertEquals("3\"4", JSON.parse("\"3\\\"4\"").toString());

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/TypeUtilsTest_castToJavaBean.java
49 issues
Avoid reassigning parameters such as 'className'
Design

Line: 97

                      TypeUtils.clearClassMapping();
    }
    
    public static void addClassMapping(String className, Class<?> clazz) throws Exception {
        Field field = TypeUtils.class.getDeclaredField("mappings");
        field.setAccessible(true);
        field.get(null);
        
        ConcurrentMap<String, Class<?>> mappings = (ConcurrentMap<String, Class<?>>) field.get(null);

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 22

              
import junit.framework.TestCase;

public class TypeUtilsTest_castToJavaBean extends TestCase {
    protected void setUp() throws Exception {
        ParserConfig.global.addAccept("com.alibaba.json.bvt.parser.TypeUtilsTest_castToJavaBean.");
    }

    public void test_castToJavaBean_StackTraceElement() throws Exception {

            

Reported by PMD.

JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 23

              import junit.framework.TestCase;

public class TypeUtilsTest_castToJavaBean extends TestCase {
    protected void setUp() throws Exception {
        ParserConfig.global.addAccept("com.alibaba.json.bvt.parser.TypeUtilsTest_castToJavaBean.");
    }

    public void test_castToJavaBean_StackTraceElement() throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();

            

Reported by PMD.

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

Line: 24

              
public class TypeUtilsTest_castToJavaBean extends TestCase {
    protected void setUp() throws Exception {
        ParserConfig.global.addAccept("com.alibaba.json.bvt.parser.TypeUtilsTest_castToJavaBean.");
    }

    public void test_castToJavaBean_StackTraceElement() throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("className", "java.lang.Object");

            

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

                      ParserConfig.global.addAccept("com.alibaba.json.bvt.parser.TypeUtilsTest_castToJavaBean.");
    }

    public void test_castToJavaBean_StackTraceElement() throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("className", "java.lang.Object");
        map.put("methodName", "hashCode");
        StackTraceElement element = TypeUtils.castToJavaBean(map, StackTraceElement.class, null);
        Assert.assertEquals("java.lang.Object", element.getClassName());

            

Reported by PMD.

The String literal 'java.lang.Object' appears 6 times in this file; the first occurrence is on line 29
Error

Line: 29

              
    public void test_castToJavaBean_StackTraceElement() throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("className", "java.lang.Object");
        map.put("methodName", "hashCode");
        StackTraceElement element = TypeUtils.castToJavaBean(map, StackTraceElement.class, null);
        Assert.assertEquals("java.lang.Object", element.getClassName());
        Assert.assertEquals("hashCode", element.getMethodName());
        Assert.assertEquals(null, element.getFileName());

            

Reported by PMD.

The String literal 'hashCode' appears 6 times in this file; the first occurrence is on line 30
Error

Line: 30

                  public void test_castToJavaBean_StackTraceElement() throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("className", "java.lang.Object");
        map.put("methodName", "hashCode");
        StackTraceElement element = TypeUtils.castToJavaBean(map, StackTraceElement.class, null);
        Assert.assertEquals("java.lang.Object", element.getClassName());
        Assert.assertEquals("hashCode", element.getMethodName());
        Assert.assertEquals(null, element.getFileName());
    }

            

Reported by PMD.

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

Line: 32

                      map.put("className", "java.lang.Object");
        map.put("methodName", "hashCode");
        StackTraceElement element = TypeUtils.castToJavaBean(map, StackTraceElement.class, null);
        Assert.assertEquals("java.lang.Object", element.getClassName());
        Assert.assertEquals("hashCode", element.getMethodName());
        Assert.assertEquals(null, element.getFileName());
    }

    public void test_castToJavaBean_StackTraceElement_1() throws Exception {

            

Reported by PMD.

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

Line: 33

                      map.put("methodName", "hashCode");
        StackTraceElement element = TypeUtils.castToJavaBean(map, StackTraceElement.class, null);
        Assert.assertEquals("java.lang.Object", element.getClassName());
        Assert.assertEquals("hashCode", element.getMethodName());
        Assert.assertEquals(null, element.getFileName());
    }

    public void test_castToJavaBean_StackTraceElement_1() throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();

            

Reported by PMD.

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

Line: 34

                      StackTraceElement element = TypeUtils.castToJavaBean(map, StackTraceElement.class, null);
        Assert.assertEquals("java.lang.Object", element.getClassName());
        Assert.assertEquals("hashCode", element.getMethodName());
        Assert.assertEquals(null, element.getFileName());
    }

    public void test_castToJavaBean_StackTraceElement_1() throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("className", "java.lang.Object");

            

Reported by PMD.