The following issues were found

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/EnumerationSeriliazerTest.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 EnumerationSeriliazerTest extends TestCase {

    public void test_nullAsEmtpyList() throws Exception {
        VO e = new VO();
        Assert.assertEquals("{\"elements\":[]}", JSON.toJSONString(e, SerializerFeature.WriteMapNullValue,
                                                                   SerializerFeature.WriteNullListAsEmpty));
    }


            

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

                                                                                 SerializerFeature.WriteNullListAsEmpty));
    }

    public void test_null() throws Exception {
        VO e = new VO();
        Assert.assertEquals("{\"elements\":null}", JSON.toJSONString(e, SerializerFeature.WriteMapNullValue));
    }

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

                      Assert.assertEquals("{\"elements\":null}", JSON.toJSONString(e, SerializerFeature.WriteMapNullValue));
    }

    public void test_1() throws Exception {
        VO e = new VO(new Entity(), new Entity());
        Assert.assertEquals("{\"elements\":[{},{}]}", JSON.toJSONString(e, SerializerFeature.WriteMapNullValue));
    }

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

                      Assert.assertEquals("{\"elements\":[{},{}]}", JSON.toJSONString(e, SerializerFeature.WriteMapNullValue));
    }

    public void test_2() throws Exception {
        VO e = new VO(new Entity(), new Entity2());
        Assert.assertEquals("{\"elements\":[{},{\"@type\":\"com.alibaba.json.bvt.serializer.EnumerationSeriliazerTest$Entity2\"}]}",
                            JSON.toJSONString(e, SerializerFeature.WriteClassName,
                                              SerializerFeature.NotWriteRootClassName));
    }

            

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

                                                            SerializerFeature.NotWriteRootClassName));
    }

    public void test_3() throws Exception {
        VO2 e = new VO2(new Entity(), new Entity());
        Assert.assertEquals("{\"elements\":[{},{}]}", JSON.toJSONString(e, SerializerFeature.WriteClassName,
                                                                        SerializerFeature.NotWriteRootClassName));
    }
    

            

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

                                                                                      SerializerFeature.NotWriteRootClassName));
    }
    
    public void test_4() throws Exception {
        VO3 e = new VO3(new Entity(), new Entity2());
        Assert.assertEquals("{\"elements\":[{\"@type\":\"com.alibaba.json.bvt.serializer.EnumerationSeriliazerTest$Entity\"},{\"@type\":\"com.alibaba.json.bvt.serializer.EnumerationSeriliazerTest$Entity2\"}]}", JSON.toJSONString(e, SerializerFeature.WriteClassName,
                                                                        SerializerFeature.NotWriteRootClassName));
    }


            

Reported by PMD.

Consider replacing this Vector with the newer java.util.List
Design

Line: 56

              
        public VO(Entity... array){
            if (array.length > 0) {
                Vector<Entity> vector = new Vector<Entity>();
                for (Entity item : array) {
                    vector.add(item);
                }
                this.elements = vector.elements();
            }

            

Reported by PMD.

Use ArrayList instead of Vector
Performance

Line: 56

              
        public VO(Entity... array){
            if (array.length > 0) {
                Vector<Entity> vector = new Vector<Entity>();
                for (Entity item : array) {
                    vector.add(item);
                }
                this.elements = vector.elements();
            }

            

Reported by PMD.

Use ArrayList instead of Vector
Performance

Line: 78

              
        public VO2(Entity... array){
            if (array.length > 0) {
                Vector<Entity> vector = new Vector<Entity>();
                for (Entity item : array) {
                    vector.add(item);
                }
                this.elements = vector.elements();
            }

            

Reported by PMD.

Consider replacing this Vector with the newer java.util.List
Design

Line: 78

              
        public VO2(Entity... array){
            if (array.length > 0) {
                Vector<Entity> vector = new Vector<Entity>();
                for (Entity item : array) {
                    vector.add(item);
                }
                this.elements = vector.elements();
            }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest_double.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_double 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 double  id;
        private String name;

        public double getId() {

            

Reported by PMD.

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

Line: 16

              public class NameFilterTest_double 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/fastjson/validate/JSONValidateTest_0.java
13 issues
System.out.println is used
Design

Line: 20

                              JSONValidator validator = JSONValidator.from(json);
                validator.validate(); // 518
            }
            System.out.println("millis : " + (System.currentTimeMillis() - start));
        }
    }




            

Reported by PMD.

System.out.println is used
Design

Line: 36

                              JSONValidator validator = JSONValidator.fromUtf8(json);
                validator.validate();
            }
            System.out.println("millis : " + (System.currentTimeMillis() - start));
        }
    }
}

            

Reported by PMD.

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

Line: 11

              import java.io.ByteArrayInputStream;

public class JSONValidateTest_0 extends TestCase {
    public void test_validate_benchmark() throws Exception {
        String json = JSON.toJSONString(EishayDecodeBytes.instance.getContent());

        for (int n = 0; n < 10; ++n) {
            long start = System.currentTimeMillis();
            for (int i = 0; i < 1000 * 1000 * 1; ++i) {

            

Reported by PMD.

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

Line: 11

              import java.io.ByteArrayInputStream;

public class JSONValidateTest_0 extends TestCase {
    public void test_validate_benchmark() throws Exception {
        String json = JSON.toJSONString(EishayDecodeBytes.instance.getContent());

        for (int n = 0; n < 10; ++n) {
            long start = System.currentTimeMillis();
            for (int i = 0; i < 1000 * 1000 * 1; ++i) {

            

Reported by PMD.

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

Line: 12

              
public class JSONValidateTest_0 extends TestCase {
    public void test_validate_benchmark() throws Exception {
        String json = JSON.toJSONString(EishayDecodeBytes.instance.getContent());

        for (int n = 0; n < 10; ++n) {
            long start = System.currentTimeMillis();
            for (int i = 0; i < 1000 * 1000 * 1; ++i) {
                JSONValidator validator = JSONValidator.from(json);

            

Reported by PMD.

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

Line: 18

                          long start = System.currentTimeMillis();
            for (int i = 0; i < 1000 * 1000 * 1; ++i) {
                JSONValidator validator = JSONValidator.from(json);
                validator.validate(); // 518
            }
            System.out.println("millis : " + (System.currentTimeMillis() - start));
        }
    }


            

Reported by PMD.

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

Line: 27

              


    public void test_validate_utf8_benchmark() throws Exception {
        byte[] json = JSON.toJSONBytes(EishayDecodeBytes.instance.getContent());

        for (int n = 0; n < 5; ++n) {
            long start = System.currentTimeMillis();
            for (int i = 0; i < 1000 * 1000 * 1; ++i) {

            

Reported by PMD.

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

Line: 27

              


    public void test_validate_utf8_benchmark() throws Exception {
        byte[] json = JSON.toJSONBytes(EishayDecodeBytes.instance.getContent());

        for (int n = 0; n < 5; ++n) {
            long start = System.currentTimeMillis();
            for (int i = 0; i < 1000 * 1000 * 1; ++i) {

            

Reported by PMD.

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

Line: 28

              

    public void test_validate_utf8_benchmark() throws Exception {
        byte[] json = JSON.toJSONBytes(EishayDecodeBytes.instance.getContent());

        for (int n = 0; n < 5; ++n) {
            long start = System.currentTimeMillis();
            for (int i = 0; i < 1000 * 1000 * 1; ++i) {
                JSONValidator validator = JSONValidator.fromUtf8(json);

            

Reported by PMD.

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

Line: 34

                          long start = System.currentTimeMillis();
            for (int i = 0; i < 1000 * 1000 * 1; ++i) {
                JSONValidator validator = JSONValidator.fromUtf8(json);
                validator.validate();
            }
            System.out.println("millis : " + (System.currentTimeMillis() - start));
        }
    }
}

            

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.

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/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/path/JSONPath_size.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 JSONPath_size extends TestCase {

    public void test_root() throws Exception {
        List list = new ArrayList();
        list.add(new Entity(101, "kiki"));
        list.add(new Entity(102, "ljw2083"));
        list.add(new Entity(103, "ljw2083"));


            

Reported by PMD.

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

Line: 19

              
    public void test_root() throws Exception {
        List list = new ArrayList();
        list.add(new Entity(101, "kiki"));
        list.add(new Entity(102, "ljw2083"));
        list.add(new Entity(103, "ljw2083"));

        Assert.assertEquals(3, JSONPath.size(list, "$"));
    }

            

Reported by PMD.

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

Line: 20

                  public void test_root() throws Exception {
        List list = new ArrayList();
        list.add(new Entity(101, "kiki"));
        list.add(new Entity(102, "ljw2083"));
        list.add(new Entity(103, "ljw2083"));

        Assert.assertEquals(3, JSONPath.size(list, "$"));
    }


            

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

                      Assert.assertEquals(3, JSONPath.size(list, "$"));
    }

    public void test_path() throws Exception {
        List list = new ArrayList();
        list.add(new Entity(101, "kiki"));
        list.add(new Entity(102, "ljw2083"));
        list.add(new Entity(103, "ljw2083"));


            

Reported by PMD.

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

Line: 38

                      Assert.assertEquals(3, JSONPath.size(root, "$.values"));
    }

    public void test_path_size() throws Exception {
        JSONPath path = JSONPath.compile("$");

        Assert.assertEquals(-1, path.size(null));
    }


            

Reported by PMD.

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

Line: 41

                  public void test_path_size() throws Exception {
        JSONPath path = JSONPath.compile("$");

        Assert.assertEquals(-1, path.size(null));
    }

    public void test_path_size_1() throws Exception {
        List list = new ArrayList();
        list.add(new Entity(101, "kiki"));

            

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(-1, path.size(null));
    }

    public void test_path_size_1() throws Exception {
        List list = new ArrayList();
        list.add(new Entity(101, "kiki"));
        list.add(new Entity(102, "ljw2083"));
        list.add(new Entity(103, "ljw2083"));


            

Reported by PMD.

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

Line: 52

              
        JSONPath path = JSONPath.compile("$");

        Assert.assertEquals(3, path.size(list));
    }

    public void test_path_size_2() throws Exception {
        List list = new ArrayList();
        list.add(new Entity(101, "kiki"));

            

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

                      Assert.assertEquals(3, path.size(list));
    }

    public void test_path_size_2() throws Exception {
        List list = new ArrayList();
        list.add(new Entity(101, "kiki"));
        list.add(new Entity(102, "ljw2083"));
        list.add(new Entity(103, "ljw2083"));


            

Reported by PMD.

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

Line: 66

              
        JSONPath path = JSONPath.compile("$.values");

        Assert.assertEquals(3, path.size(root));
    }

    public void test_error() throws Exception {
        ErrorSizeBean obj = new ErrorSizeBean();


            

Reported by PMD.