The following issues were found

src/test/java/com/alibaba/json/bvt/issue_1200/Issue1233.java
12 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: 17

               * Created by wenshao on 30/05/2017.
 */
public class Issue1233 extends TestCase {
    public void test_for_issue() throws Exception {
        ParserConfig.getGlobalInstance().putDeserializer(Area.class, new ObjectDeserializer() {
            public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
                JSONObject jsonObject = (JSONObject) parser.parse();
                String areaType;


            

Reported by PMD.

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

Line: 17

               * Created by wenshao on 30/05/2017.
 */
public class Issue1233 extends TestCase {
    public void test_for_issue() throws Exception {
        ParserConfig.getGlobalInstance().putDeserializer(Area.class, new ObjectDeserializer() {
            public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
                JSONObject jsonObject = (JSONObject) parser.parse();
                String areaType;


            

Reported by PMD.

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

Line: 23

                              JSONObject jsonObject = (JSONObject) parser.parse();
                String areaType;

                if (jsonObject.get("type") instanceof String) {
                    areaType = (String) jsonObject.get("type");
                } else {
                    return null;
                }
                if (Area.TYPE_SECTION.equals(areaType)) {

            

Reported by PMD.

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

Line: 28

                              } else {
                    return null;
                }
                if (Area.TYPE_SECTION.equals(areaType)) {
                    return (T) JSON.toJavaObject(jsonObject, Section.class);
                } else if (Area.TYPE_FLOORV1.equals(areaType)) {
                    return (T) JSON.toJavaObject(jsonObject, FloorV1.class);
                } else if (Area.TYPE_FLOORV2.equals(areaType)) {
                    return (T) JSON.toJavaObject(jsonObject, FloorV2.class);

            

Reported by PMD.

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

Line: 30

                              }
                if (Area.TYPE_SECTION.equals(areaType)) {
                    return (T) JSON.toJavaObject(jsonObject, Section.class);
                } else if (Area.TYPE_FLOORV1.equals(areaType)) {
                    return (T) JSON.toJavaObject(jsonObject, FloorV1.class);
                } else if (Area.TYPE_FLOORV2.equals(areaType)) {
                    return (T) JSON.toJavaObject(jsonObject, FloorV2.class);
                }
                return null;

            

Reported by PMD.

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

Line: 32

                                  return (T) JSON.toJavaObject(jsonObject, Section.class);
                } else if (Area.TYPE_FLOORV1.equals(areaType)) {
                    return (T) JSON.toJavaObject(jsonObject, FloorV1.class);
                } else if (Area.TYPE_FLOORV2.equals(areaType)) {
                    return (T) JSON.toJavaObject(jsonObject, FloorV2.class);
                }
                return null;
            }


            

Reported by PMD.

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

Line: 45

              
        JSONObject jsonObject = JSON.parseObject("{\"type\":\"floorV2\",\"templateId\":\"x123\"}");

        FloorV2 floorV2 = (FloorV2) jsonObject.toJavaObject(Area.class);
        assertNotNull(floorV2);
        assertEquals("x123", floorV2.templateId);
    }

    public interface Area {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 46

                      JSONObject jsonObject = JSON.parseObject("{\"type\":\"floorV2\",\"templateId\":\"x123\"}");

        FloorV2 floorV2 = (FloorV2) jsonObject.toJavaObject(Area.class);
        assertNotNull(floorV2);
        assertEquals("x123", floorV2.templateId);
    }

    public interface Area {
        public static final String TYPE_SECTION = "section";

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 47

              
        FloorV2 floorV2 = (FloorV2) jsonObject.toJavaObject(Area.class);
        assertNotNull(floorV2);
        assertEquals("x123", floorV2.templateId);
    }

    public interface Area {
        public static final String TYPE_SECTION = "section";
        public static final String TYPE_FLOORV1 = "floorV1";

            

Reported by PMD.

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

Line: 63

              
        public String type;

        public String templateId;

        public String getName() {
            return templateId;
        }
    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest_long_field.java
12 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_long_field 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")) {
                    Assert.assertTrue(value instanceof Long);

            

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")) {
                    Assert.assertTrue(value instanceof Long);
                    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")) {
                    Assert.assertTrue(value instanceof Long);
                    return "ID";
                }

                return name;

            

Reported by PMD.

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

Line: 31

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

                      Assert.assertEquals("{\"ID\":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: 44

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

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

              
        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.

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

Line: 16

              public class NameFilterTest_long_field 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")) {
                    Assert.assertTrue(value instanceof Long);
                    return "ID";

            

Reported by PMD.

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

Line: 16

              public class NameFilterTest_long_field 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")) {
                    Assert.assertTrue(value instanceof Long);
                    return "ID";

            

Reported by PMD.

src/test/java/com/alibaba/json/demo/FilterDemo.java
12 issues
System.out.println is used
Design

Line: 46

                      serializer.write(object);

        String outText = out.toString();
        System.out.println(outText);
    }
}

            

Reported by PMD.

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

Line: 13

              
public class FilterDemo extends TestCase {

    public void test_secure() throws Exception {

        ValueFilter filter = new ValueFilter() {

            public Object process(Object source, String name, Object value) {
                if (name.equals("name")) {

            

Reported by PMD.

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

Line: 13

              
public class FilterDemo extends TestCase {

    public void test_secure() throws Exception {

        ValueFilter filter = new ValueFilter() {

            public Object process(Object source, String name, Object value) {
                if (name.equals("name")) {

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 18

                      ValueFilter filter = new ValueFilter() {

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

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 18

                      ValueFilter filter = new ValueFilter() {

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

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 27

              
        NameFilter nameFilter = 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: 27

              
        NameFilter nameFilter = 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: 40

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

        serializer.write(object);

        String outText = out.toString();

            

Reported by PMD.

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

Line: 41

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

        serializer.write(object);

        String outText = out.toString();
        System.out.println(outText);

            

Reported by PMD.

Found 'DU'-anomaly for variable 'filter' (lines '15'-'47').
Error

Line: 15

              
    public void test_secure() throws Exception {

        ValueFilter filter = new ValueFilter() {

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

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/path/JSONPath_min.java
12 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: 10

              import java.math.BigDecimal;

public class JSONPath_min extends TestCase {
    public void test_max() throws Exception {
        Object root = JSON.parse("[1,3,9, 5, 2, 4]");
        assertEquals(1, JSONPath.eval(root, "$.min()"));
    }

    public void test_max_1() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 12

              public class JSONPath_min extends TestCase {
    public void test_max() throws Exception {
        Object root = JSON.parse("[1,3,9, 5, 2, 4]");
        assertEquals(1, JSONPath.eval(root, "$.min()"));
    }

    public void test_max_1() throws Exception {
        Object root = JSON.parse("[1,6,7L,3,8,9.1, 5, 2L, 4]");
        assertEquals(1, JSONPath.eval(root, "$.min()"));

            

Reported by PMD.

The String literal '$.min()' appears 5 times in this file; the first occurrence is on line 12
Error

Line: 12

              public class JSONPath_min extends TestCase {
    public void test_max() throws Exception {
        Object root = JSON.parse("[1,3,9, 5, 2, 4]");
        assertEquals(1, JSONPath.eval(root, "$.min()"));
    }

    public void test_max_1() throws Exception {
        Object root = JSON.parse("[1,6,7L,3,8,9.1, 5, 2L, 4]");
        assertEquals(1, JSONPath.eval(root, "$.min()"));

            

Reported by PMD.

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

Line: 15

                      assertEquals(1, JSONPath.eval(root, "$.min()"));
    }

    public void test_max_1() throws Exception {
        Object root = JSON.parse("[1,6,7L,3,8,9.1, 5, 2L, 4]");
        assertEquals(1, JSONPath.eval(root, "$.min()"));
    }

    public void test_max_2() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

              
    public void test_max_1() throws Exception {
        Object root = JSON.parse("[1,6,7L,3,8,9.1, 5, 2L, 4]");
        assertEquals(1, JSONPath.eval(root, "$.min()"));
    }

    public void test_max_2() throws Exception {
        Object root = JSON.parse("[1,6,7L,3,3.1D,8,9.1F, 5, 2L, 4]");
        assertEquals(1, JSONPath.eval(root, "$.min()"));

            

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

                      assertEquals(1, JSONPath.eval(root, "$.min()"));
    }

    public void test_max_2() throws Exception {
        Object root = JSON.parse("[1,6,7L,3,3.1D,8,9.1F, 5, 2L, 4]");
        assertEquals(1, JSONPath.eval(root, "$.min()"));
    }

    public void test_max_3() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

              
    public void test_max_2() throws Exception {
        Object root = JSON.parse("[1,6,7L,3,3.1D,8,9.1F, 5, 2L, 4]");
        assertEquals(1, JSONPath.eval(root, "$.min()"));
    }

    public void test_max_3() throws Exception {
        Object root = JSON.parse("[1,6,7L,3,3.1F,8,9.1F, 5, 2L, 4]");
        assertEquals(1, JSONPath.eval(root, "$.min()"));

            

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

                      assertEquals(1, JSONPath.eval(root, "$.min()"));
    }

    public void test_max_3() throws Exception {
        Object root = JSON.parse("[1,6,7L,3,3.1F,8,9.1F, 5, 2L, 4]");
        assertEquals(1, JSONPath.eval(root, "$.min()"));
    }

    public void test_max_4() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 27

              
    public void test_max_3() throws Exception {
        Object root = JSON.parse("[1,6,7L,3,3.1F,8,9.1F, 5, 2L, 4]");
        assertEquals(1, JSONPath.eval(root, "$.min()"));
    }

    public void test_max_4() throws Exception {
        Object root = JSON.parse("['1', '111', '2']");
        assertEquals("1", JSONPath.eval(root, "$.min()"));

            

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

                      assertEquals(1, JSONPath.eval(root, "$.min()"));
    }

    public void test_max_4() throws Exception {
        Object root = JSON.parse("['1', '111', '2']");
        assertEquals("1", JSONPath.eval(root, "$.min()"));
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest_float_field.java
12 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_field 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.

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

Line: 16

              public class NameFilterTest_float_field 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.

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

Line: 16

              public class NameFilterTest_float_field 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.

src/test/java/com/alibaba/json/bvt/issue_1200/Issue1235.java
12 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 12

               * Created by wenshao on 30/05/2017.
 */
public class Issue1235 extends TestCase {
    public void test_for_issue() throws Exception {
        String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\"}";

        FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
        assertNotNull(floorV2);
        assertNotNull(floorV2.templateId);

            

Reported by PMD.

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

Line: 12

               * Created by wenshao on 30/05/2017.
 */
public class Issue1235 extends TestCase {
    public void test_for_issue() throws Exception {
        String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\"}";

        FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
        assertNotNull(floorV2);
        assertNotNull(floorV2.templateId);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                      String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\"}";

        FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
        assertNotNull(floorV2);
        assertNotNull(floorV2.templateId);
        assertEquals("x123", floorV2.templateId);
        assertEquals("floorV2", floorV2.type);

        String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

              
        FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
        assertNotNull(floorV2);
        assertNotNull(floorV2.templateId);
        assertEquals("x123", floorV2.templateId);
        assertEquals("floorV2", floorV2.type);

        String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
        assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
        assertNotNull(floorV2);
        assertNotNull(floorV2.templateId);
        assertEquals("x123", floorV2.templateId);
        assertEquals("floorV2", floorV2.type);

        String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
        assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                      assertNotNull(floorV2);
        assertNotNull(floorV2.templateId);
        assertEquals("x123", floorV2.templateId);
        assertEquals("floorV2", floorV2.type);

        String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
        assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

                      assertEquals("floorV2", floorV2.type);

        String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
        assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
    }

    @JSONType(seeAlso = {FloorV2.class}, typeKey = "type")
    public interface Area {
        public static final String TYPE_SECTION = "section";

            

Reported by PMD.

Avoid constants in interfaces. Interfaces define types, constants are implementation details better placed in classes or enums. See Effective Java, item 19.
Design

Line: 27

              
    @JSONType(seeAlso = {FloorV2.class}, typeKey = "type")
    public interface Area {
        public static final String TYPE_SECTION = "section";
        public static final String TYPE_FLOORV1 = "floorV1";
        public static final String TYPE_FLOORV2 = "floorV2";
    }

    @JSONType(typeName = "floorV2")

            

Reported by PMD.

Avoid constants in interfaces. Interfaces define types, constants are implementation details better placed in classes or enums. See Effective Java, item 19.
Design

Line: 28

                  @JSONType(seeAlso = {FloorV2.class}, typeKey = "type")
    public interface Area {
        public static final String TYPE_SECTION = "section";
        public static final String TYPE_FLOORV1 = "floorV1";
        public static final String TYPE_FLOORV2 = "floorV2";
    }

    @JSONType(typeName = "floorV2")
    public static class FloorV2 implements Area {

            

Reported by PMD.

Avoid constants in interfaces. Interfaces define types, constants are implementation details better placed in classes or enums. See Effective Java, item 19.
Design

Line: 29

                  public interface Area {
        public static final String TYPE_SECTION = "section";
        public static final String TYPE_FLOORV1 = "floorV1";
        public static final String TYPE_FLOORV2 = "floorV2";
    }

    @JSONType(typeName = "floorV2")
    public static class FloorV2 implements Area {
        public String type;

            

Reported by PMD.

src/test/java/com/alibaba/fastjson/jsonpath/issue3607/TestIssue3607.java
12 issues
The String literal ' {\n' appears 7 times in this file; the first occurrence is on line 24
Error

Line: 24

                              "        \"dataRows\": [\n" +
                "            {\n" +
                "                \"dataFields\": [\n" +
                "                    {\n" +
                "                        \"id\": 1332,\n" +
                "                        \"name\": \"gmtRegular\",\n" +
                "                        \"status\": \"success\",\n" +
                "                        \"valueType\": \"DATE\"\n" +
                "                    },\n" +

            

Reported by PMD.

The String literal ' \'status\': \'success\',\n' appears 7 times in this file; the first occurrence is on line 27
Error

Line: 27

                              "                    {\n" +
                "                        \"id\": 1332,\n" +
                "                        \"name\": \"gmtRegular\",\n" +
                "                        \"status\": \"success\",\n" +
                "                        \"valueType\": \"DATE\"\n" +
                "                    },\n" +
                "                    {\n" +
                "                        \"id\": 302,\n" +
                "                        \"name\": \"deptNo\",\n" +

            

Reported by PMD.

The String literal ' },\n' appears 6 times in this file; the first occurrence is on line 29
Error

Line: 29

                              "                        \"name\": \"gmtRegular\",\n" +
                "                        \"status\": \"success\",\n" +
                "                        \"valueType\": \"DATE\"\n" +
                "                    },\n" +
                "                    {\n" +
                "                        \"id\": 302,\n" +
                "                        \"name\": \"deptNo\",\n" +
                "                        \"status\": \"success\",\n" +
                "                        \"value\": \"C3736\",\n" +

            

Reported by PMD.

The String literal ' \'valueType\': \'STRING\'\n' appears 4 times in this file; the first occurrence is on line 35
Error

Line: 35

                              "                        \"name\": \"deptNo\",\n" +
                "                        \"status\": \"success\",\n" +
                "                        \"value\": \"C3736\",\n" +
                "                        \"valueType\": \"STRING\"\n" +
                "                    },\n" +
                "                    {\n" +
                "                        \"id\": 143,\n" +
                "                        \"name\": \"gmtOrigRegular\",\n" +
                "                        \"status\": \"success\",\n" +

            

Reported by PMD.

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

Line: 82

              

        List<String> evalResult = (List<String>) JSONPath.eval(testData, "$.data.dataRows[*].dataFields[*].value", false);
        Assert.assertEquals(testData.getData().getDataRows().get(0).getDataFields().size(), evalResult.size());

    }

    static class TestData {
        private Test1 data;

            

Reported by PMD.

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

Line: 82

              

        List<String> evalResult = (List<String>) JSONPath.eval(testData, "$.data.dataRows[*].dataFields[*].value", false);
        Assert.assertEquals(testData.getData().getDataRows().get(0).getDataFields().size(), evalResult.size());

    }

    static class TestData {
        private Test1 data;

            

Reported by PMD.

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

Line: 82

              

        List<String> evalResult = (List<String>) JSONPath.eval(testData, "$.data.dataRows[*].dataFields[*].value", false);
        Assert.assertEquals(testData.getData().getDataRows().get(0).getDataFields().size(), evalResult.size());

    }

    static class TestData {
        private Test1 data;

            

Reported by PMD.

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

Line: 82

              

        List<String> evalResult = (List<String>) JSONPath.eval(testData, "$.data.dataRows[*].dataFields[*].value", false);
        Assert.assertEquals(testData.getData().getDataRows().get(0).getDataFields().size(), evalResult.size());

    }

    static class TestData {
        private Test1 data;

            

Reported by PMD.

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

Line: 82

              

        List<String> evalResult = (List<String>) JSONPath.eval(testData, "$.data.dataRows[*].dataFields[*].value", false);
        Assert.assertEquals(testData.getData().getDataRows().get(0).getDataFields().size(), evalResult.size());

    }

    static class TestData {
        private Test1 data;

            

Reported by PMD.

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

Line: 82

              

        List<String> evalResult = (List<String>) JSONPath.eval(testData, "$.data.dataRows[*].dataFields[*].value", false);
        Assert.assertEquals(testData.getData().getDataRows().get(0).getDataFields().size(), evalResult.size());

    }

    static class TestData {
        private Test1 data;

            

Reported by PMD.

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

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

            public String process(Object source, String name, Object value) {
                if (value != null) {
                    Assert.assertTrue(value instanceof Byte);

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 23

                                  Assert.assertTrue(value instanceof Byte);
                }
                
                if (name.equals("id")) {
                    return "ID";
                }

                return name;
            }

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 23

                                  Assert.assertTrue(value instanceof Byte);
                }
                
                if (name.equals("id")) {
                    return "ID";
                }

                return name;
            }

            

Reported by PMD.

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

Line: 34

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

                      Assert.assertEquals("{\"ID\":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: 47

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

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

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

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


            

Reported by PMD.

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

Line: 16

              public class NameFilterTest_byte_field extends TestCase {

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

            public String process(Object source, String name, Object value) {
                if (value != null) {
                    Assert.assertTrue(value instanceof Byte);
                }

            

Reported by PMD.

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

Line: 16

              public class NameFilterTest_byte_field extends TestCase {

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

            public String process(Object source, String name, Object value) {
                if (value != null) {
                    Assert.assertTrue(value instanceof Byte);
                }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/writeClassName/WriteClassNameTest_Set3.java
12 issues
System.out.println is used
Design

Line: 26

                      set.add(new B1());
        a.setList(set);
        String text = JSON.toJSONString(a, SerializerFeature.WriteClassName);
        System.out.println(text);
//        Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set3$A\",\"list\":[{},{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set3$B1\"}]}",
//                            text);

        A a1 = (A) JSON.parse(text);


            

Reported by PMD.

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

Line: 15

              import com.alibaba.fastjson.serializer.SerializerFeature;

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

    public void test_list() throws Exception {
        A a = new A();

            

Reported by PMD.

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

Line: 16

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

    public void test_list() throws Exception {
        A a = new A();
        LinkedHashSet<B> set = new LinkedHashSet<B>();

            

Reported by PMD.

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

Line: 19

                      ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set3");
    }

    public void test_list() throws Exception {
        A a = new A();
        LinkedHashSet<B> set = new LinkedHashSet<B>();
        set.add(new B());
        set.add(new B1());
        a.setList(set);

            

Reported by PMD.

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

Line: 32

              
        A a1 = (A) JSON.parse(text);

        Assert.assertEquals(2, a1.getList().size());
        Assert.assertTrue(new ArrayList<B>(a1.getList()).get(0) instanceof B);
        Assert.assertTrue(new ArrayList<B>(a1.getList()).get(1) instanceof B1);
    }

    private static class A {

            

Reported by PMD.

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

Line: 32

              
        A a1 = (A) JSON.parse(text);

        Assert.assertEquals(2, a1.getList().size());
        Assert.assertTrue(new ArrayList<B>(a1.getList()).get(0) instanceof B);
        Assert.assertTrue(new ArrayList<B>(a1.getList()).get(1) instanceof B1);
    }

    private static class A {

            

Reported by PMD.

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

Line: 33

                      A a1 = (A) JSON.parse(text);

        Assert.assertEquals(2, a1.getList().size());
        Assert.assertTrue(new ArrayList<B>(a1.getList()).get(0) instanceof B);
        Assert.assertTrue(new ArrayList<B>(a1.getList()).get(1) instanceof B1);
    }

    private static class A {


            

Reported by PMD.

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

Line: 34

              
        Assert.assertEquals(2, a1.getList().size());
        Assert.assertTrue(new ArrayList<B>(a1.getList()).get(0) instanceof B);
        Assert.assertTrue(new ArrayList<B>(a1.getList()).get(1) instanceof B1);
    }

    private static class A {

        private LinkedHashSet<B> list;

            

Reported by PMD.

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

Line: 39

              
    private static class A {

        private LinkedHashSet<B> list;

        public LinkedHashSet<B> getList() {
            return list;
        }


            

Reported by PMD.

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

Line: 41

              
        private LinkedHashSet<B> list;

        public LinkedHashSet<B> getList() {
            return list;
        }

        public void setList(LinkedHashSet<B> list) {
            this.list = list;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest_double_field.java
12 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_double_field 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.

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

Line: 16

              public class NameFilterTest_double_field 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.

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

Line: 16

              public class NameFilterTest_double_field 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.