The following issues were found

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

Line: 46

                          text = JSON.toJSONString(groups);
        }

        System.out.println(text);

        List<Group> groups = JSON.parseObject(text, new TypeReference<List<Group>>() {
        });
        Group g0 = groups.get(0);
        Group g1 = groups.get(1);

            

Reported by PMD.

System.out.println is used
Design

Line: 53

                      Group g0 = groups.get(0);
        Group g1 = groups.get(1);

        System.out.println(JSON.toJSONString(groups));
    }

    public static class Group {

        private String        name;

            

Reported by PMD.

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

Line: 13

              
public class Bug_for_42283905 extends TestCase {

    public void test_0() throws Exception {

        String text;
        {
            List<Group> groups = new ArrayList<Group>();


            

Reported by PMD.

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

Line: 13

              
public class Bug_for_42283905 extends TestCase {

    public void test_0() throws Exception {

        String text;
        {
            List<Group> groups = new ArrayList<Group>();


            

Reported by PMD.

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

Line: 28

              
            {
                Group group = new Group("g0");
                group.getBattleCommandList().add(c0);
                groups.add(group);
            }

            {
                Group group = new Group("g1");

            

Reported by PMD.

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

Line: 34

              
            {
                Group group = new Group("g1");
                group.getBattleCommandList().add(c1);
                groups.add(group);
            }
            
            {
                Group group = new Group("g2");

            

Reported by PMD.

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

Line: 40

                          
            {
                Group group = new Group("g2");
                group.getBattleCommandList().add(c2);
                groups.add(group);
            }
            text = JSON.toJSONString(groups);
        }


            

Reported by PMD.

Avoid unused local variables such as 'g0'.
Design

Line: 50

              
        List<Group> groups = JSON.parseObject(text, new TypeReference<List<Group>>() {
        });
        Group g0 = groups.get(0);
        Group g1 = groups.get(1);

        System.out.println(JSON.toJSONString(groups));
    }


            

Reported by PMD.

Avoid unused local variables such as 'g1'.
Design

Line: 51

                      List<Group> groups = JSON.parseObject(text, new TypeReference<List<Group>>() {
        });
        Group g0 = groups.get(0);
        Group g1 = groups.get(1);

        System.out.println(JSON.toJSONString(groups));
    }

    public static class Group {

            

Reported by PMD.

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

Line: 56

                      System.out.println(JSON.toJSONString(groups));
    }

    public static class Group {

        private String        name;

        private List<Command> battleCommandList = new ArrayList<Command>();


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/writeClassName/StrictAutoTypeTest_0.java
13 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 10

              import junit.framework.TestCase;

public class StrictAutoTypeTest_0 extends TestCase {
    private ParserConfig config = new ParserConfig();

    public void test_0() throws Exception {
        JSON.parseObject("{\"@type\":\"com.alibaba.fastjson.JSONObject\"}", Object.class, config);
        JSON.parseObject("{\"@type\":\"com.alibaba.fastjson.JSONObject\"}", Object.class, config, Feature.SupportAutoType);
    }

            

Reported by PMD.

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

Line: 10

              import junit.framework.TestCase;

public class StrictAutoTypeTest_0 extends TestCase {
    private ParserConfig config = new ParserConfig();

    public void test_0() throws Exception {
        JSON.parseObject("{\"@type\":\"com.alibaba.fastjson.JSONObject\"}", Object.class, config);
        JSON.parseObject("{\"@type\":\"com.alibaba.fastjson.JSONObject\"}", Object.class, config, Feature.SupportAutoType);
    }

            

Reported by PMD.

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

Line: 12

              public class StrictAutoTypeTest_0 extends TestCase {
    private ParserConfig config = new ParserConfig();

    public void test_0() throws Exception {
        JSON.parseObject("{\"@type\":\"com.alibaba.fastjson.JSONObject\"}", Object.class, config);
        JSON.parseObject("{\"@type\":\"com.alibaba.fastjson.JSONObject\"}", Object.class, config, Feature.SupportAutoType);
    }

    public void test_1() throws Exception {

            

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 StrictAutoTypeTest_0 extends TestCase {
    private ParserConfig config = new ParserConfig();

    public void test_0() throws Exception {
        JSON.parseObject("{\"@type\":\"com.alibaba.fastjson.JSONObject\"}", Object.class, config);
        JSON.parseObject("{\"@type\":\"com.alibaba.fastjson.JSONObject\"}", Object.class, config, Feature.SupportAutoType);
    }

    public void test_1() throws Exception {

            

Reported by PMD.

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

Line: 17

                      JSON.parseObject("{\"@type\":\"com.alibaba.fastjson.JSONObject\"}", Object.class, config, Feature.SupportAutoType);
    }

    public void test_1() throws Exception {
        JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.writeClassName.StrictAutoTypeTest_0$VO\"}", Object.class, config, Feature.SupportAutoType);
    }

    public void test_2() throws Exception {
        {

            

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

                      JSON.parseObject("{\"@type\":\"com.alibaba.fastjson.JSONObject\"}", Object.class, config, Feature.SupportAutoType);
    }

    public void test_1() throws Exception {
        JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.writeClassName.StrictAutoTypeTest_0$VO\"}", Object.class, config, Feature.SupportAutoType);
    }

    public void test_2() throws Exception {
        {

            

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

                      JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.writeClassName.StrictAutoTypeTest_0$VO\"}", Object.class, config, Feature.SupportAutoType);
    }

    public void test_2() throws Exception {
        {
            Exception error = null;
            try {
                JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.writeClassName.StrictAutoTypeTest_0$V1\"}", Object.class, config);
            } catch (JSONException ex) {

            

Reported by PMD.

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

Line: 21

                      JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.writeClassName.StrictAutoTypeTest_0$VO\"}", Object.class, config, Feature.SupportAutoType);
    }

    public void test_2() throws Exception {
        {
            Exception error = null;
            try {
                JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.writeClassName.StrictAutoTypeTest_0$V1\"}", Object.class, config);
            } catch (JSONException ex) {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

                          } catch (JSONException ex) {
                error = ex;
            }
            assertNotNull(error);
        }
        {
            Exception error = null;
            try {
                JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.writeClassName.StrictAutoTypeTest_0$V1\"}", Object.class, config);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 38

                          } catch (JSONException ex) {
                error = ex;
            }
            assertNotNull(error);
        }
    }

    public void test_3() throws Exception {
        int features = JSON.DEFAULT_PARSER_FEATURE | Feature.SupportAutoType.mask;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest_long.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_long 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.

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

Line: 65

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

    public static class Bean {

        private long   id;
        private String name;

        public long getId() {

            

Reported by PMD.

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

Line: 16

              public class NameFilterTest_long 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/bvt/writeClassName/WriteClassNameTest_Map.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: 17

              
public class WriteClassNameTest_Map extends TestCase {

    public void test_list() throws Exception {
        Model model = new Model();
        Map tables = new LinkedHashMap();
        tables.put("1001", new ExtTable(1001));
        tables.put("1002", new Table());
        model.setTables(tables);

            

Reported by PMD.

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

Line: 17

              
public class WriteClassNameTest_Map extends TestCase {

    public void test_list() throws Exception {
        Model model = new Model();
        Map tables = new LinkedHashMap();
        tables.put("1001", new ExtTable(1001));
        tables.put("1002", new Table());
        model.setTables(tables);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 25

                      model.setTables(tables);

        String json = JSON.toJSONString(model);
        assertEquals("{\"tables\":{\"1001\":{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Map$ExtTable\",\"id\":1001},\"1002\":{}}}", json);

        JSONObject jsonObject = JSON.parseObject(json, Feature.IgnoreAutoType);
        assertEquals("{\"tables\":{\"1002\":{},\"1001\":{\"id\":1001}}}", jsonObject.toJSONString());

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

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 28

                      assertEquals("{\"tables\":{\"1001\":{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Map$ExtTable\",\"id\":1001},\"1002\":{}}}", json);

        JSONObject jsonObject = JSON.parseObject(json, Feature.IgnoreAutoType);
        assertEquals("{\"tables\":{\"1002\":{},\"1001\":{\"id\":1001}}}", jsonObject.toJSONString());

        Model model2 = JSON.parseObject(json, Model.class);
        assertEquals(ExtTable.class, model2.getTables().get("1001").getClass());
    }


            

Reported by PMD.

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

Line: 28

                      assertEquals("{\"tables\":{\"1001\":{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Map$ExtTable\",\"id\":1001},\"1002\":{}}}", json);

        JSONObject jsonObject = JSON.parseObject(json, Feature.IgnoreAutoType);
        assertEquals("{\"tables\":{\"1002\":{},\"1001\":{\"id\":1001}}}", jsonObject.toJSONString());

        Model model2 = JSON.parseObject(json, Model.class);
        assertEquals(ExtTable.class, model2.getTables().get("1001").getClass());
    }


            

Reported by PMD.

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

Line: 31

                      assertEquals("{\"tables\":{\"1002\":{},\"1001\":{\"id\":1001}}}", jsonObject.toJSONString());

        Model model2 = JSON.parseObject(json, Model.class);
        assertEquals(ExtTable.class, model2.getTables().get("1001").getClass());
    }

    public static class Model {
        @JSONField(serialzeFeatures = SerializerFeature.WriteClassName)
        private Map<String, ? extends Table> tables;

            

Reported by PMD.

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

Line: 31

                      assertEquals("{\"tables\":{\"1002\":{},\"1001\":{\"id\":1001}}}", jsonObject.toJSONString());

        Model model2 = JSON.parseObject(json, Model.class);
        assertEquals(ExtTable.class, model2.getTables().get("1001").getClass());
    }

    public static class Model {
        @JSONField(serialzeFeatures = SerializerFeature.WriteClassName)
        private Map<String, ? extends Table> tables;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 31

                      assertEquals("{\"tables\":{\"1002\":{},\"1001\":{\"id\":1001}}}", jsonObject.toJSONString());

        Model model2 = JSON.parseObject(json, Model.class);
        assertEquals(ExtTable.class, model2.getTables().get("1001").getClass());
    }

    public static class Model {
        @JSONField(serialzeFeatures = SerializerFeature.WriteClassName)
        private Map<String, ? extends Table> tables;

            

Reported by PMD.

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

Line: 31

                      assertEquals("{\"tables\":{\"1002\":{},\"1001\":{\"id\":1001}}}", jsonObject.toJSONString());

        Model model2 = JSON.parseObject(json, Model.class);
        assertEquals(ExtTable.class, model2.getTables().get("1001").getClass());
    }

    public static class Model {
        @JSONField(serialzeFeatures = SerializerFeature.WriteClassName)
        private Map<String, ? extends Table> tables;

            

Reported by PMD.

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

Line: 52

                  }

    public static class ExtTable extends Table {
        public int id;

        public ExtTable() {

        }


            

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.

src/test/java/com/alibaba/json/bvt/parser/array/BeanToArrayAutoTypeTest3.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: 12

              
public class BeanToArrayAutoTypeTest3
        extends TestCase {
    public void test_beanToArray() throws Exception {
        Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\"]]}", Topology.class);
        assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
    }

    public void test_beanToArray1() throws Exception {

            

Reported by PMD.

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

Line: 14

                      extends TestCase {
    public void test_beanToArray() throws Exception {
        Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\"]]}", Topology.class);
        assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
    }

    public void test_beanToArray1() throws Exception {
        Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\",123]]}", Topology.class);
        assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

                      extends TestCase {
    public void test_beanToArray() throws Exception {
        Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\"]]}", Topology.class);
        assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
    }

    public void test_beanToArray1() throws Exception {
        Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\",123]]}", Topology.class);
        assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());

            

Reported by PMD.

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

Line: 14

                      extends TestCase {
    public void test_beanToArray() throws Exception {
        Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\"]]}", Topology.class);
        assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
    }

    public void test_beanToArray1() throws Exception {
        Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\",123]]}", Topology.class);
        assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());

            

Reported by PMD.

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

Line: 17

                      assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
    }

    public void test_beanToArray1() throws Exception {
        Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\",123]]}", Topology.class);
        assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
        assertEquals(123, ((LogSourceMeta) topology.maps.get(0)).id);
    }


            

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

                      assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
    }

    public void test_beanToArray1() throws Exception {
        Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\",123]]}", Topology.class);
        assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
        assertEquals(123, ((LogSourceMeta) topology.maps.get(0)).id);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

              
    public void test_beanToArray1() throws Exception {
        Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\",123]]}", Topology.class);
        assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
        assertEquals(123, ((LogSourceMeta) topology.maps.get(0)).id);
    }

    @JSONType(typeName = "Log")
    public static class LogSourceMeta extends MapTaskMeta {

            

Reported by PMD.

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

Line: 19

              
    public void test_beanToArray1() throws Exception {
        Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\",123]]}", Topology.class);
        assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
        assertEquals(123, ((LogSourceMeta) topology.maps.get(0)).id);
    }

    @JSONType(typeName = "Log")
    public static class LogSourceMeta extends MapTaskMeta {

            

Reported by PMD.

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

Line: 19

              
    public void test_beanToArray1() throws Exception {
        Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\",123]]}", Topology.class);
        assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
        assertEquals(123, ((LogSourceMeta) topology.maps.get(0)).id);
    }

    @JSONType(typeName = "Log")
    public static class LogSourceMeta extends MapTaskMeta {

            

Reported by PMD.

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

Line: 20

                  public void test_beanToArray1() throws Exception {
        Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\",123]]}", Topology.class);
        assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
        assertEquals(123, ((LogSourceMeta) topology.maps.get(0)).id);
    }

    @JSONType(typeName = "Log")
    public static class LogSourceMeta extends MapTaskMeta {
        public int id;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest_short_field.java
13 issues
Do not use the short type
Performance

Line: 72

              
    public static class Bean {

        public short    id;
        public String name;

    }
}

            

Reported by PMD.

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

Line: 16

              
public class NameFilterTest_short_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 Short);

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 24

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

                return name;
            }

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 24

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

                return name;
            }

            

Reported by PMD.

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

Line: 35

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

                      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")) {
                    Assert.assertTrue(value instanceof Short);

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 48

                      NameFilter filter = new NameFilter() {

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

                return name;

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 48

                      NameFilter filter = new NameFilter() {

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

                return name;

            

Reported by PMD.

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

Line: 60

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

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


            

Reported by PMD.

Found 'DU'-anomaly for variable 'filter' (lines '17'-'42').
Error

Line: 17

              public class NameFilterTest_short_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 Short);
                }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest_int.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_int 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 Integer);

            

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 Integer);
                    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 Integer);
                    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.

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

Line: 65

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

    public static class Bean {

        private int    id;
        private String name;

        public int getId() {

            

Reported by PMD.

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

Line: 16

              public class NameFilterTest_int 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 Integer);
                    return "ID";

            

Reported by PMD.

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

              
public class Bug_for_wangran extends TestCase {

    public void test_for_wangran() throws Exception {
        String resource = "json/wangran.json";
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
        String text = IOUtils.toString(new InputStreamReader(is,"UTF-8"));



            

Reported by PMD.

Ensure that resources like this InputStream object are closed after use
Error

Line: 19

              
    public void test_for_wangran() throws Exception {
        String resource = "json/wangran.json";
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
        String text = IOUtils.toString(new InputStreamReader(is,"UTF-8"));


        QueueEntity qe = JSON.parseObject(text, QueueEntity.class);
        

            

Reported by PMD.

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

Line: 19

              
    public void test_for_wangran() throws Exception {
        String resource = "json/wangran.json";
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
        String text = IOUtils.toString(new InputStreamReader(is,"UTF-8"));


        QueueEntity qe = JSON.parseObject(text, QueueEntity.class);
        

            

Reported by PMD.

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

Line: 19

              
    public void test_for_wangran() throws Exception {
        String resource = "json/wangran.json";
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
        String text = IOUtils.toString(new InputStreamReader(is,"UTF-8"));


        QueueEntity qe = JSON.parseObject(text, QueueEntity.class);
        

            

Reported by PMD.

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

Line: 26

                      QueueEntity qe = JSON.parseObject(text, QueueEntity.class);
        
        Assert.assertNotNull(qe);
        Assert.assertNotNull(qe.getPhysicalQueueMap());
        Assert.assertEquals(4, qe.getPhysicalQueueMap().size());
        
        for (PhysicalQueue q : qe.getPhysicalQueueMap().values()) {
            q.getInRate();
            Assert.assertEquals(qe, q.getQueue());

            

Reported by PMD.

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

Line: 27

                      
        Assert.assertNotNull(qe);
        Assert.assertNotNull(qe.getPhysicalQueueMap());
        Assert.assertEquals(4, qe.getPhysicalQueueMap().size());
        
        for (PhysicalQueue q : qe.getPhysicalQueueMap().values()) {
            q.getInRate();
            Assert.assertEquals(qe, q.getQueue());
        }

            

Reported by PMD.

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

Line: 27

                      
        Assert.assertNotNull(qe);
        Assert.assertNotNull(qe.getPhysicalQueueMap());
        Assert.assertEquals(4, qe.getPhysicalQueueMap().size());
        
        for (PhysicalQueue q : qe.getPhysicalQueueMap().values()) {
            q.getInRate();
            Assert.assertEquals(qe, q.getQueue());
        }

            

Reported by PMD.

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

Line: 29

                      Assert.assertNotNull(qe.getPhysicalQueueMap());
        Assert.assertEquals(4, qe.getPhysicalQueueMap().size());
        
        for (PhysicalQueue q : qe.getPhysicalQueueMap().values()) {
            q.getInRate();
            Assert.assertEquals(qe, q.getQueue());
        }
        
        Assert.assertEquals(qe.getPhysicalQueueMap(), qe.getPqMap());

            

Reported by PMD.

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

Line: 34

                          Assert.assertEquals(qe, q.getQueue());
        }
        
        Assert.assertEquals(qe.getPhysicalQueueMap(), qe.getPqMap());
        Assert.assertEquals(true, qe.getPhysicalQueueMap() == qe.getPqMap());
        Assert.assertEquals("amq", qe.getDescription());
        
    }
}

            

Reported by PMD.

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

Line: 34

                          Assert.assertEquals(qe, q.getQueue());
        }
        
        Assert.assertEquals(qe.getPhysicalQueueMap(), qe.getPqMap());
        Assert.assertEquals(true, qe.getPhysicalQueueMap() == qe.getPqMap());
        Assert.assertEquals("amq", qe.getDescription());
        
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest_char.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_char 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")) {

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 20

              
            public String process(Object source, String name, Object value) {

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

                return name;

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 20

              
            public String process(Object source, String name, Object value) {

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

                return name;

            

Reported by PMD.

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

Line: 32

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

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

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

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

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

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

    public static class Bean {

        private char   id = '0';
        private String name;

        public char getId() {

            

Reported by PMD.

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

Line: 16

              public class NameFilterTest_char 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 Character);

            

Reported by PMD.