The following issues were found

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

               * Created by wenshao on 21/02/2017.
 */
public class JSONPParseTest2 extends TestCase {
    public void test_f() throws Exception {
        String text = "parent.callback ({'id':1, 'name':'idonans'} );   /**/ ";

        JSONPObject jsonpObject = JSON.parseObject(text, JSONPObject.class);
        assertEquals("parent.callback", jsonpObject.getFunction());


            

Reported by PMD.

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

Line: 13

               * Created by wenshao on 21/02/2017.
 */
public class JSONPParseTest2 extends TestCase {
    public void test_f() throws Exception {
        String text = "parent.callback ({'id':1, 'name':'idonans'} );   /**/ ";

        JSONPObject jsonpObject = JSON.parseObject(text, JSONPObject.class);
        assertEquals("parent.callback", jsonpObject.getFunction());


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                      String text = "parent.callback ({'id':1, 'name':'idonans'} );   /**/ ";

        JSONPObject jsonpObject = JSON.parseObject(text, JSONPObject.class);
        assertEquals("parent.callback", jsonpObject.getFunction());

        assertEquals(1, jsonpObject.getParameters().size());
        JSONObject param = (JSONObject) jsonpObject.getParameters().get(0);
        assertEquals(1, param.get("id"));
        assertEquals("idonans", param.get("name"));

            

Reported by PMD.

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

Line: 17

                      String text = "parent.callback ({'id':1, 'name':'idonans'} );   /**/ ";

        JSONPObject jsonpObject = JSON.parseObject(text, JSONPObject.class);
        assertEquals("parent.callback", jsonpObject.getFunction());

        assertEquals(1, jsonpObject.getParameters().size());
        JSONObject param = (JSONObject) jsonpObject.getParameters().get(0);
        assertEquals(1, param.get("id"));
        assertEquals("idonans", param.get("name"));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                      JSONPObject jsonpObject = JSON.parseObject(text, JSONPObject.class);
        assertEquals("parent.callback", jsonpObject.getFunction());

        assertEquals(1, jsonpObject.getParameters().size());
        JSONObject param = (JSONObject) jsonpObject.getParameters().get(0);
        assertEquals(1, param.get("id"));
        assertEquals("idonans", param.get("name"));

        String json = JSON.toJSONString(jsonpObject, SerializerFeature.MapSortField);

            

Reported by PMD.

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

Line: 19

                      JSONPObject jsonpObject = JSON.parseObject(text, JSONPObject.class);
        assertEquals("parent.callback", jsonpObject.getFunction());

        assertEquals(1, jsonpObject.getParameters().size());
        JSONObject param = (JSONObject) jsonpObject.getParameters().get(0);
        assertEquals(1, param.get("id"));
        assertEquals("idonans", param.get("name"));

        String json = JSON.toJSONString(jsonpObject, SerializerFeature.MapSortField);

            

Reported by PMD.

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

Line: 19

                      JSONPObject jsonpObject = JSON.parseObject(text, JSONPObject.class);
        assertEquals("parent.callback", jsonpObject.getFunction());

        assertEquals(1, jsonpObject.getParameters().size());
        JSONObject param = (JSONObject) jsonpObject.getParameters().get(0);
        assertEquals(1, param.get("id"));
        assertEquals("idonans", param.get("name"));

        String json = JSON.toJSONString(jsonpObject, SerializerFeature.MapSortField);

            

Reported by PMD.

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

Line: 20

                      assertEquals("parent.callback", jsonpObject.getFunction());

        assertEquals(1, jsonpObject.getParameters().size());
        JSONObject param = (JSONObject) jsonpObject.getParameters().get(0);
        assertEquals(1, param.get("id"));
        assertEquals("idonans", param.get("name"));

        String json = JSON.toJSONString(jsonpObject, SerializerFeature.MapSortField);
        assertEquals("parent.callback({\"id\":1,\"name\":\"idonans\"})", json);

            

Reported by PMD.

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

Line: 20

                      assertEquals("parent.callback", jsonpObject.getFunction());

        assertEquals(1, jsonpObject.getParameters().size());
        JSONObject param = (JSONObject) jsonpObject.getParameters().get(0);
        assertEquals(1, param.get("id"));
        assertEquals("idonans", param.get("name"));

        String json = JSON.toJSONString(jsonpObject, SerializerFeature.MapSortField);
        assertEquals("parent.callback({\"id\":1,\"name\":\"idonans\"})", json);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 21

              
        assertEquals(1, jsonpObject.getParameters().size());
        JSONObject param = (JSONObject) jsonpObject.getParameters().get(0);
        assertEquals(1, param.get("id"));
        assertEquals("idonans", param.get("name"));

        String json = JSON.toJSONString(jsonpObject, SerializerFeature.MapSortField);
        assertEquals("parent.callback({\"id\":1,\"name\":\"idonans\"})", json);
    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/asm/ASMDeserTest.java
14 issues
Avoid throwing raw exception types.
Design

Line: 67

                  public static class EntityError extends ArrayList<String> {

        public EntityError(){
            throw new RuntimeException();
        }
    }
}

            

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

    public void test_codec() throws Exception {
        String text = JSON.toJSONString(new Entity());

        Assert.assertEquals("[]", text);

        Entity object = JSON.parseObject(text, Entity.class);

            

Reported by PMD.

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

Line: 18

                      Assert.assertEquals("[]", text);

        Entity object = JSON.parseObject(text, Entity.class);
        Assert.assertEquals(0, object.size());
    }
    
    public void test_codec_1() throws Exception {
        String text = JSON.toJSONString(new VO());


            

Reported by PMD.

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

Line: 21

                      Assert.assertEquals(0, object.size());
    }
    
    public void test_codec_1() throws Exception {
        String text = JSON.toJSONString(new VO());

        Assert.assertEquals("{\"value\":[]}", text);

        VO object = JSON.parseObject(text, VO.class);

            

Reported by PMD.

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

Line: 27

                      Assert.assertEquals("{\"value\":[]}", text);

        VO object = JSON.parseObject(text, VO.class);
        Assert.assertEquals(0, object.getValue().size());
    }

    public void test_ArrayList() throws Exception {

        ArrayList object = JSON.parseObject("[]", ArrayList.class);

            

Reported by PMD.

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

Line: 27

                      Assert.assertEquals("{\"value\":[]}", text);

        VO object = JSON.parseObject(text, VO.class);
        Assert.assertEquals(0, object.getValue().size());
    }

    public void test_ArrayList() throws Exception {

        ArrayList object = JSON.parseObject("[]", ArrayList.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: 30

                      Assert.assertEquals(0, object.getValue().size());
    }

    public void test_ArrayList() throws Exception {

        ArrayList object = JSON.parseObject("[]", ArrayList.class);
        Assert.assertEquals(0, object.size());
    }


            

Reported by PMD.

Avoid using implementation types like 'ArrayList'; use the interface instead
Design

Line: 32

              
    public void test_ArrayList() throws Exception {

        ArrayList object = JSON.parseObject("[]", ArrayList.class);
        Assert.assertEquals(0, object.size());
    }

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

            

Reported by PMD.

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

Line: 33

                  public void test_ArrayList() throws Exception {

        ArrayList object = JSON.parseObject("[]", ArrayList.class);
        Assert.assertEquals(0, object.size());
    }

    public void test_error() throws Exception {
        Exception error = null;
        try {

            

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

                      Assert.assertEquals(0, object.size());
    }

    public void test_error() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[]", EntityError.class);
        } catch (Exception ex) {
            error = ex;

            

Reported by PMD.

src/test/java/com/alibaba/json/test/codec/JsonLibCodec.java
14 issues
Return an empty array rather than null.
Error

Line: 42

                  }

    @Override
    public byte[] encodeToBytes(Object object) throws Exception {
        // TODO Auto-generated method stub
        return null;
    }

    @Override

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 12

                      return "json-lib";
    }

    public <T> T decodeObject(String text, Class<T> clazz) throws Exception {
        return (T) net.sf.json.JSONObject.fromObject(text);
    }

    public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {
        throw new UnsupportedOperationException();

            

Reported by PMD.

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

Line: 13

                  }

    public <T> T decodeObject(String text, Class<T> clazz) throws Exception {
        return (T) net.sf.json.JSONObject.fromObject(text);
    }

    public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {
        throw new UnsupportedOperationException();
    }

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 16

                      return (T) net.sf.json.JSONObject.fromObject(text);
    }

    public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {
        throw new UnsupportedOperationException();
    }

    public Object decodeObject(String text) throws Exception {
        return net.sf.json.JSONObject.fromObject(text);

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 20

                      throw new UnsupportedOperationException();
    }

    public Object decodeObject(String text) throws Exception {
        return net.sf.json.JSONObject.fromObject(text);
    }

    public Object decode(String text) throws Exception {
        if (text.charAt(0) == '[') {

            

Reported by PMD.

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

Line: 21

                  }

    public Object decodeObject(String text) throws Exception {
        return net.sf.json.JSONObject.fromObject(text);
    }

    public Object decode(String text) throws Exception {
        if (text.charAt(0) == '[') {
            return net.sf.json.JSONArray.fromObject(text);

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 24

                      return net.sf.json.JSONObject.fromObject(text);
    }

    public Object decode(String text) throws Exception {
        if (text.charAt(0) == '[') {
            return net.sf.json.JSONArray.fromObject(text);
        }
        return net.sf.json.JSONObject.fromObject(text);
        // return net.sf.json.JSONArray.fromObject(text);

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 25

                  }

    public Object decode(String text) throws Exception {
        if (text.charAt(0) == '[') {
            return net.sf.json.JSONArray.fromObject(text);
        }
        return net.sf.json.JSONObject.fromObject(text);
        // return net.sf.json.JSONArray.fromObject(text);
    }

            

Reported by PMD.

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

Line: 26

              
    public Object decode(String text) throws Exception {
        if (text.charAt(0) == '[') {
            return net.sf.json.JSONArray.fromObject(text);
        }
        return net.sf.json.JSONObject.fromObject(text);
        // return net.sf.json.JSONArray.fromObject(text);
    }


            

Reported by PMD.

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

Line: 28

                      if (text.charAt(0) == '[') {
            return net.sf.json.JSONArray.fromObject(text);
        }
        return net.sf.json.JSONObject.fromObject(text);
        // return net.sf.json.JSONArray.fromObject(text);
    }

    public String encode(Object object) throws Exception {
        return net.sf.json.JSONObject.fromObject(object).toString();

            

Reported by PMD.

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

              
public class ConcurrentHashMapTest extends TestCase {

    public void test_concurrentHashmap() throws Exception {
        OffsetSerializeWrapper wrapper = new OffsetSerializeWrapper();
        wrapper.getOffsetTable().put(new MessageQueue(), new AtomicLong(123));
        String text = JSON.toJSONString(wrapper);
        Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:123}}", text);
        

            

Reported by PMD.

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

Line: 25

                      Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:123}}", text);
        
        OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());
        
        Iterator<Map.Entry<MessageQueue, AtomicLong>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicLong> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(123L, entry.getValue().longValue());

            

Reported by PMD.

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

Line: 25

                      Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:123}}", text);
        
        OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());
        
        Iterator<Map.Entry<MessageQueue, AtomicLong>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicLong> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(123L, entry.getValue().longValue());

            

Reported by PMD.

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

Line: 27

                      OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());
        
        Iterator<Map.Entry<MessageQueue, AtomicLong>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicLong> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(123L, entry.getValue().longValue());
    }


            

Reported by PMD.

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

Line: 27

                      OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());
        
        Iterator<Map.Entry<MessageQueue, AtomicLong>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicLong> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(123L, entry.getValue().longValue());
    }


            

Reported by PMD.

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

Line: 27

                      OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());
        
        Iterator<Map.Entry<MessageQueue, AtomicLong>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicLong> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(123L, entry.getValue().longValue());
    }


            

Reported by PMD.

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

Line: 29

                      
        Iterator<Map.Entry<MessageQueue, AtomicLong>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicLong> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(123L, entry.getValue().longValue());
    }

    public static class OffsetSerializeWrapper {


            

Reported by PMD.

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

Line: 29

                      
        Iterator<Map.Entry<MessageQueue, AtomicLong>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicLong> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(123L, entry.getValue().longValue());
    }

    public static class OffsetSerializeWrapper {


            

Reported by PMD.

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

Line: 29

                      
        Iterator<Map.Entry<MessageQueue, AtomicLong>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicLong> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(123L, entry.getValue().longValue());
    }

    public static class OffsetSerializeWrapper {


            

Reported by PMD.

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

Line: 30

                      Iterator<Map.Entry<MessageQueue, AtomicLong>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicLong> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(123L, entry.getValue().longValue());
    }

    public static class OffsetSerializeWrapper {

        private ConcurrentHashMap<MessageQueue, AtomicLong> offsetTable = new ConcurrentHashMap<MessageQueue, AtomicLong>();

            

Reported by PMD.

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

              
public class ConcurrentHashMapTest2 extends TestCase {

    public void test_concurrentHashmap() throws Exception {
        OffsetSerializeWrapper wrapper = new OffsetSerializeWrapper();
        wrapper.getOffsetTable().put(new MessageQueue(), new AtomicInteger(123));
        String text = JSON.toJSONString(wrapper);
        Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:123}}", text);
        

            

Reported by PMD.

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

Line: 25

                      Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:123}}", text);
        
        OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());
        
        Iterator<Map.Entry<MessageQueue, AtomicInteger>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicInteger> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(123, entry.getValue().intValue());

            

Reported by PMD.

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

Line: 25

                      Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:123}}", text);
        
        OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());
        
        Iterator<Map.Entry<MessageQueue, AtomicInteger>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicInteger> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(123, entry.getValue().intValue());

            

Reported by PMD.

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

Line: 27

                      OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());
        
        Iterator<Map.Entry<MessageQueue, AtomicInteger>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicInteger> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(123, entry.getValue().intValue());
    }


            

Reported by PMD.

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

Line: 27

                      OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());
        
        Iterator<Map.Entry<MessageQueue, AtomicInteger>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicInteger> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(123, entry.getValue().intValue());
    }


            

Reported by PMD.

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

Line: 27

                      OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());
        
        Iterator<Map.Entry<MessageQueue, AtomicInteger>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicInteger> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(123, entry.getValue().intValue());
    }


            

Reported by PMD.

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

Line: 29

                      
        Iterator<Map.Entry<MessageQueue, AtomicInteger>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicInteger> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(123, entry.getValue().intValue());
    }

    public static class OffsetSerializeWrapper {


            

Reported by PMD.

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

Line: 29

                      
        Iterator<Map.Entry<MessageQueue, AtomicInteger>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicInteger> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(123, entry.getValue().intValue());
    }

    public static class OffsetSerializeWrapper {


            

Reported by PMD.

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

Line: 29

                      
        Iterator<Map.Entry<MessageQueue, AtomicInteger>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicInteger> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(123, entry.getValue().intValue());
    }

    public static class OffsetSerializeWrapper {


            

Reported by PMD.

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

Line: 30

                      Iterator<Map.Entry<MessageQueue, AtomicInteger>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicInteger> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(123, entry.getValue().intValue());
    }

    public static class OffsetSerializeWrapper {

        private ConcurrentHashMap<MessageQueue, AtomicInteger> offsetTable = new ConcurrentHashMap<MessageQueue, AtomicInteger>();

            

Reported by PMD.

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

              
public class ConcurrentHashMapTest3 extends TestCase {

    public void test_concurrentHashmap() throws Exception {
        OffsetSerializeWrapper wrapper = new OffsetSerializeWrapper();
        wrapper.getOffsetTable().put(new MessageQueue(), new AtomicBoolean(true));
        String text = JSON.toJSONString(wrapper);
        Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:true}}", text);
        

            

Reported by PMD.

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

Line: 25

                      Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:true}}", text);
        
        OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());
        
        Iterator<Map.Entry<MessageQueue, AtomicBoolean>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicBoolean> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get());

            

Reported by PMD.

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

Line: 25

                      Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:true}}", text);
        
        OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());
        
        Iterator<Map.Entry<MessageQueue, AtomicBoolean>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicBoolean> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get());

            

Reported by PMD.

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

Line: 27

                      OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());
        
        Iterator<Map.Entry<MessageQueue, AtomicBoolean>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicBoolean> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get());
    }


            

Reported by PMD.

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

Line: 27

                      OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());
        
        Iterator<Map.Entry<MessageQueue, AtomicBoolean>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicBoolean> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get());
    }


            

Reported by PMD.

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

Line: 27

                      OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());
        
        Iterator<Map.Entry<MessageQueue, AtomicBoolean>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicBoolean> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get());
    }


            

Reported by PMD.

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

Line: 29

                      
        Iterator<Map.Entry<MessageQueue, AtomicBoolean>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicBoolean> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get());
    }

    public static class OffsetSerializeWrapper {


            

Reported by PMD.

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

Line: 29

                      
        Iterator<Map.Entry<MessageQueue, AtomicBoolean>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicBoolean> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get());
    }

    public static class OffsetSerializeWrapper {


            

Reported by PMD.

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

Line: 29

                      
        Iterator<Map.Entry<MessageQueue, AtomicBoolean>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicBoolean> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get());
    }

    public static class OffsetSerializeWrapper {


            

Reported by PMD.

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

Line: 30

                      Iterator<Map.Entry<MessageQueue, AtomicBoolean>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicBoolean> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get());
    }

    public static class OffsetSerializeWrapper {

        private ConcurrentHashMap<MessageQueue, AtomicBoolean> offsetTable = new ConcurrentHashMap<MessageQueue, AtomicBoolean>();

            

Reported by PMD.

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

Line: 43

                          char c1 = model.name.charAt(i);
            char c2 = model.name.charAt(i);
            if (c1 != c2) {
                System.out.println("diff : " + c1 + " -> " + c2);
                break;
            }
        }
//        String str = model2.name.substring(65535);
//        System.out.println(str);

            

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

              import junit.framework.TestCase;

public class StringFieldTest_special_2 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: 25

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

                      model.name = buf.toString();
        
        String text = JSON.toJSONString(model, SerializerFeature.BrowserSecure);
        text = text.replaceAll("&lt;", "<");
        text = text.replaceAll("&gt;", ">");
//        text = text.replaceAll("\\\\/", "/");
        Model model2 = JSON.parseObject(text, Model.class);

        for (int i = 0; i < model.name.length() && i < model2.name.length(); ++i) {

            

Reported by PMD.

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

Line: 35

                      
        String text = JSON.toJSONString(model, SerializerFeature.BrowserSecure);
        text = text.replaceAll("&lt;", "<");
        text = text.replaceAll("&gt;", ">");
//        text = text.replaceAll("\\\\/", "/");
        Model model2 = JSON.parseObject(text, Model.class);

        for (int i = 0; i < model.name.length() && i < model2.name.length(); ++i) {
            char c1 = model.name.charAt(i);

            

Reported by PMD.

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

Line: 39

              //        text = text.replaceAll("\\\\/", "/");
        Model model2 = JSON.parseObject(text, Model.class);

        for (int i = 0; i < model.name.length() && i < model2.name.length(); ++i) {
            char c1 = model.name.charAt(i);
            char c2 = model.name.charAt(i);
            if (c1 != c2) {
                System.out.println("diff : " + c1 + " -> " + c2);
                break;

            

Reported by PMD.

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

Line: 39

              //        text = text.replaceAll("\\\\/", "/");
        Model model2 = JSON.parseObject(text, Model.class);

        for (int i = 0; i < model.name.length() && i < model2.name.length(); ++i) {
            char c1 = model.name.charAt(i);
            char c2 = model.name.charAt(i);
            if (c1 != c2) {
                System.out.println("diff : " + c1 + " -> " + c2);
                break;

            

Reported by PMD.

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

Line: 40

                      Model model2 = JSON.parseObject(text, Model.class);

        for (int i = 0; i < model.name.length() && i < model2.name.length(); ++i) {
            char c1 = model.name.charAt(i);
            char c2 = model.name.charAt(i);
            if (c1 != c2) {
                System.out.println("diff : " + c1 + " -> " + c2);
                break;
            }

            

Reported by PMD.

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

Line: 41

              
        for (int i = 0; i < model.name.length() && i < model2.name.length(); ++i) {
            char c1 = model.name.charAt(i);
            char c2 = model.name.charAt(i);
            if (c1 != c2) {
                System.out.println("diff : " + c1 + " -> " + c2);
                break;
            }
        }

            

Reported by PMD.

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

Line: 49

                      }
//        String str = model2.name.substring(65535);
//        System.out.println(str);
        Assert.assertEquals(model.name.length(), model2.name.length());
        Assert.assertEquals(model.name, model2.name);
    }
    
    public void test_special_browsecompatible() throws Exception {
        Model model = new Model();

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/support/moneta/MonetaCodec.java
13 issues
Potential violation of Law of Demeter (object not created locally)
Design

Line: 28

                      }

        SerializeWriter out = serializer.out;
        out.writeFieldValue('{', "numberStripped", money.getNumberStripped());
        out.writeFieldValue(',', "currency", money.getCurrency().getCurrencyCode());
        out.write('}');
    }

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

            

Reported by PMD.

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

Line: 28

                      }

        SerializeWriter out = serializer.out;
        out.writeFieldValue('{', "numberStripped", money.getNumberStripped());
        out.writeFieldValue(',', "currency", money.getCurrency().getCurrencyCode());
        out.write('}');
    }

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

            

Reported by PMD.

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

Line: 29

              
        SerializeWriter out = serializer.out;
        out.writeFieldValue('{', "numberStripped", money.getNumberStripped());
        out.writeFieldValue(',', "currency", money.getCurrency().getCurrencyCode());
        out.write('}');
    }

    public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
        JSONObject object = parser.parseObject();

            

Reported by PMD.

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

Line: 29

              
        SerializeWriter out = serializer.out;
        out.writeFieldValue('{', "numberStripped", money.getNumberStripped());
        out.writeFieldValue(',', "currency", money.getCurrency().getCurrencyCode());
        out.write('}');
    }

    public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
        JSONObject object = parser.parseObject();

            

Reported by PMD.

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

Line: 29

              
        SerializeWriter out = serializer.out;
        out.writeFieldValue('{', "numberStripped", money.getNumberStripped());
        out.writeFieldValue(',', "currency", money.getCurrency().getCurrencyCode());
        out.write('}');
    }

    public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
        JSONObject object = parser.parseObject();

            

Reported by PMD.

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

Line: 30

                      SerializeWriter out = serializer.out;
        out.writeFieldValue('{', "numberStripped", money.getNumberStripped());
        out.writeFieldValue(',', "currency", money.getCurrency().getCurrencyCode());
        out.write('}');
    }

    public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
        JSONObject object = parser.parseObject();
        Object currency = object.get("currency");

            

Reported by PMD.

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

Line: 35

              
    public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
        JSONObject object = parser.parseObject();
        Object currency = object.get("currency");

        String currencyCode = null;
        if (currency instanceof JSONObject) {
            currencyCode = ((JSONObject) currency).getString("currencyCode");
        } else if (currency instanceof String) {

            

Reported by PMD.

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

Line: 44

                          currencyCode = (String) currency;
        }

        Object numberStripped = object.get("numberStripped");

        if (numberStripped instanceof BigDecimal
                || numberStripped instanceof Integer || numberStripped instanceof BigInteger) {
            return (T) Money.of((Number) numberStripped, Monetary.getCurrency(currencyCode));
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'currencyCode' (lines '37'-'41').
Error

Line: 37

                      JSONObject object = parser.parseObject();
        Object currency = object.get("currency");

        String currencyCode = null;
        if (currency instanceof JSONObject) {
            currencyCode = ((JSONObject) currency).getString("currencyCode");
        } else if (currency instanceof String) {
            currencyCode = (String) currency;
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'currencyCode' (lines '37'-'39').
Error

Line: 37

                      JSONObject object = parser.parseObject();
        Object currency = object.get("currency");

        String currencyCode = null;
        if (currency instanceof JSONObject) {
            currencyCode = ((JSONObject) currency).getString("currencyCode");
        } else if (currency instanceof String) {
            currencyCode = (String) currency;
        }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/geo/FeatureTest.java
13 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 FeatureTest
        extends TestCase {
    public void test_geo() throws Exception {
        String str = "{\n" +
                "    \"type\": \"Feature\",\n" +
                "    \"bbox\": [-10.0, -10.0, 10.0, 10.0],\n" +
                "    \"geometry\": {\n" +
                "       \"type\": \"Polygon\",\n" +

            

Reported by PMD.

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

Line: 11

              
public class FeatureTest
        extends TestCase {
    public void test_geo() throws Exception {
        String str = "{\n" +
                "    \"type\": \"Feature\",\n" +
                "    \"bbox\": [-10.0, -10.0, 10.0, 10.0],\n" +
                "    \"geometry\": {\n" +
                "       \"type\": \"Polygon\",\n" +

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

                              "}";

        Geometry geometry = JSON.parseObject(str, Geometry.class);
        assertEquals(Feature.class, geometry.getClass());

        assertEquals("{\"type\":\"Feature\",\"bbox\":[-10.0,-10.0,10.0,10.0],\"properties\":{},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-10.0,-10.0],[10.0,-10.0],[10.0,10.0],[-10.0,-10.0]]]}}", JSON.toJSONString(geometry));

        String str2 = JSON.toJSONString(geometry);
        assertEquals(str2, JSON.toJSONString(JSON.parseObject(str2, Geometry.class)));

            

Reported by PMD.

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

Line: 29

                              "}";

        Geometry geometry = JSON.parseObject(str, Geometry.class);
        assertEquals(Feature.class, geometry.getClass());

        assertEquals("{\"type\":\"Feature\",\"bbox\":[-10.0,-10.0,10.0,10.0],\"properties\":{},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-10.0,-10.0],[10.0,-10.0],[10.0,10.0],[-10.0,-10.0]]]}}", JSON.toJSONString(geometry));

        String str2 = JSON.toJSONString(geometry);
        assertEquals(str2, JSON.toJSONString(JSON.parseObject(str2, Geometry.class)));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 31

                      Geometry geometry = JSON.parseObject(str, Geometry.class);
        assertEquals(Feature.class, geometry.getClass());

        assertEquals("{\"type\":\"Feature\",\"bbox\":[-10.0,-10.0,10.0,10.0],\"properties\":{},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-10.0,-10.0],[10.0,-10.0],[10.0,10.0],[-10.0,-10.0]]]}}", JSON.toJSONString(geometry));

        String str2 = JSON.toJSONString(geometry);
        assertEquals(str2, JSON.toJSONString(JSON.parseObject(str2, Geometry.class)));
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 34

                      assertEquals("{\"type\":\"Feature\",\"bbox\":[-10.0,-10.0,10.0,10.0],\"properties\":{},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-10.0,-10.0],[10.0,-10.0],[10.0,10.0],[-10.0,-10.0]]]}}", JSON.toJSONString(geometry));

        String str2 = JSON.toJSONString(geometry);
        assertEquals(str2, JSON.toJSONString(JSON.parseObject(str2, Geometry.class)));
    }

    public void test_geo_1() throws Exception {
        String str = "{\n" +
                "    \"type\": \"Feature\",\n" +

            

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

                      assertEquals(str2, JSON.toJSONString(JSON.parseObject(str2, Geometry.class)));
    }

    public void test_geo_1() throws Exception {
        String str = "{\n" +
                "    \"type\": \"Feature\",\n" +
                "    \"id\": \"f2\",\n" +
                "    \"geometry\": {\n" +
                "       \"type\": \"Polygon\",\n" +

            

Reported by PMD.

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

Line: 37

                      assertEquals(str2, JSON.toJSONString(JSON.parseObject(str2, Geometry.class)));
    }

    public void test_geo_1() throws Exception {
        String str = "{\n" +
                "    \"type\": \"Feature\",\n" +
                "    \"id\": \"f2\",\n" +
                "    \"geometry\": {\n" +
                "       \"type\": \"Polygon\",\n" +

            

Reported by PMD.

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

Line: 55

                              "}";

        Geometry geometry = JSON.parseObject(str, Geometry.class);
        assertEquals(Feature.class, geometry.getClass());

        assertEquals("{\"type\":\"Feature\",\"id\":\"f2\",\"properties\":{},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-10.0,-10.0],[10.0,-10.0],[10.0,10.0],[-10.0,-10.0]]]}}", JSON.toJSONString(geometry));

        String str2 = JSON.toJSONString(geometry);
        assertEquals(str2, JSON.toJSONString(JSON.parseObject(str2, Geometry.class)));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 55

                              "}";

        Geometry geometry = JSON.parseObject(str, Geometry.class);
        assertEquals(Feature.class, geometry.getClass());

        assertEquals("{\"type\":\"Feature\",\"id\":\"f2\",\"properties\":{},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-10.0,-10.0],[10.0,-10.0],[10.0,10.0],[-10.0,-10.0]]]}}", JSON.toJSONString(geometry));

        String str2 = JSON.toJSONString(geometry);
        assertEquals(str2, JSON.toJSONString(JSON.parseObject(str2, Geometry.class)));

            

Reported by PMD.

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

    public void test_namefilter() throws Exception {
        NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 19

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";
                }

                return name;
            }

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 19

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";
                }

                return name;
            }

            

Reported by PMD.

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

Line: 30

              
        SerializeWriter out = new SerializeWriter();
        JSONSerializer serializer = new JSONSerializer(out);
        serializer.getNameFilters().add(filter);

        Bean a = new Bean();
        serializer.write(a);

        String text = out.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: 39

                      Assert.assertEquals("{\"ID\":0.0}", text);
    }

    public void test_namefilter_1() throws Exception {
        NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 43

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";
                }

                return name;
            }

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 43

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";
                }

                return name;
            }

            

Reported by PMD.

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

Line: 54

              
        SerializeWriter out = new SerializeWriter();
        JSONSerializer serializer = new JSONSerializer(out);
        serializer.getNameFilters().add(filter);

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", 0);
        serializer.write(map);


            

Reported by PMD.

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

Line: 64

                      Assert.assertEquals("{\"ID\":0}", text);
    }

    public static class Bean {

        private float  id;
        private String name;

        public float getId() {

            

Reported by PMD.

Found 'DU'-anomaly for variable 'filter' (lines '16'-'37').
Error

Line: 16

              public class NameFilterTest_float extends TestCase {

    public void test_namefilter() throws Exception {
        NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";
                }

            

Reported by PMD.