The following issues were found

src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest_double_obj.java
10 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: 14

              
public class JSONCreatorTest_double_obj extends TestCase {

    public void test_create() throws Exception {
        Entity entity = new Entity(123.45D, "菜姐");
        String text = JSON.toJSONString(entity);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());

            

Reported by PMD.

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

Line: 19

                      String text = JSON.toJSONString(entity);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public void test_create_2() throws Exception {
        Entity entity = new Entity(123.45D, "菜姐");

            

Reported by PMD.

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

Line: 19

                      String text = JSON.toJSONString(entity);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public void test_create_2() throws Exception {
        Entity entity = new Entity(123.45D, "菜姐");

            

Reported by PMD.

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

Line: 19

                      String text = JSON.toJSONString(entity);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public void test_create_2() throws Exception {
        Entity entity = new Entity(123.45D, "菜姐");

            

Reported by PMD.

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

Line: 20

              
        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public void test_create_2() throws Exception {
        Entity entity = new Entity(123.45D, "菜姐");
        String text = JSON.toJSONString(entity);

            

Reported by PMD.

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

Line: 23

                      Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public void test_create_2() throws Exception {
        Entity entity = new Entity(123.45D, "菜姐");
        String text = JSON.toJSONString(entity);

        ParserConfig config = new ParserConfig();


            

Reported by PMD.

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

Line: 30

                      ParserConfig config = new ParserConfig();

        Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
        Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public static class Entity {


            

Reported by PMD.

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

Line: 30

                      ParserConfig config = new ParserConfig();

        Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
        Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public static class Entity {


            

Reported by PMD.

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

Line: 30

                      ParserConfig config = new ParserConfig();

        Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
        Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public static class Entity {


            

Reported by PMD.

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

Line: 31

              
        Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
        Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public static class Entity {

        private final Double  id;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest_float_obj.java
10 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: 14

              
public class JSONCreatorTest_float_obj extends TestCase {

    public void test_create() throws Exception {
        Entity entity = new Entity(123.45F, "菜姐");
        String text = JSON.toJSONString(entity);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertTrue(entity.getId().floatValue() == entity2.getId().floatValue());

            

Reported by PMD.

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

Line: 19

                      String text = JSON.toJSONString(entity);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertTrue(entity.getId().floatValue() == entity2.getId().floatValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public void test_create_2() throws Exception {
        Entity entity = new Entity(123.45F, "菜姐");

            

Reported by PMD.

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

Line: 19

                      String text = JSON.toJSONString(entity);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertTrue(entity.getId().floatValue() == entity2.getId().floatValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public void test_create_2() throws Exception {
        Entity entity = new Entity(123.45F, "菜姐");

            

Reported by PMD.

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

Line: 19

                      String text = JSON.toJSONString(entity);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertTrue(entity.getId().floatValue() == entity2.getId().floatValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public void test_create_2() throws Exception {
        Entity entity = new Entity(123.45F, "菜姐");

            

Reported by PMD.

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

Line: 20

              
        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertTrue(entity.getId().floatValue() == entity2.getId().floatValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public void test_create_2() throws Exception {
        Entity entity = new Entity(123.45F, "菜姐");
        String text = JSON.toJSONString(entity);

            

Reported by PMD.

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

Line: 23

                      Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public void test_create_2() throws Exception {
        Entity entity = new Entity(123.45F, "菜姐");
        String text = JSON.toJSONString(entity);

        ParserConfig config = new ParserConfig();


            

Reported by PMD.

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

Line: 30

                      ParserConfig config = new ParserConfig();

        Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
        Assert.assertTrue(entity.getId().floatValue() == entity2.getId().floatValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public static class Entity {


            

Reported by PMD.

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

Line: 30

                      ParserConfig config = new ParserConfig();

        Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
        Assert.assertTrue(entity.getId().floatValue() == entity2.getId().floatValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public static class Entity {


            

Reported by PMD.

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

Line: 30

                      ParserConfig config = new ParserConfig();

        Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
        Assert.assertTrue(entity.getId().floatValue() == entity2.getId().floatValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public static class Entity {


            

Reported by PMD.

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

Line: 31

              
        Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
        Assert.assertTrue(entity.getId().floatValue() == entity2.getId().floatValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public static class Entity {

        private final Float  id;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_2300/Issue2343.java
10 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: 9

              import junit.framework.TestCase;

public class Issue2343 extends TestCase {
    public void test_for_issue() throws Exception {
        A a = new A();
        a.f1 = 101;
        a.f2 = 102;
        a.f3 = 103;


            

Reported by PMD.

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

Line: 9

              import junit.framework.TestCase;

public class Issue2343 extends TestCase {
    public void test_for_issue() throws Exception {
        A a = new A();
        a.f1 = 101;
        a.f2 = 102;
        a.f3 = 103;


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                      a.f3 = 103;

        String str = JSON.toJSONString(a);
        assertEquals("{\"f2\":102,\"f1\":101,\"f3\":103}", str);

        JSONObject object = JSON.parseObject(str);
        A a1 = object.toJavaObject(A.class);
        assertEquals(a.f1, a1.f1);
        assertEquals(a.f2, a1.f2);

            

Reported by PMD.

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

Line: 19

                      assertEquals("{\"f2\":102,\"f1\":101,\"f3\":103}", str);

        JSONObject object = JSON.parseObject(str);
        A a1 = object.toJavaObject(A.class);
        assertEquals(a.f1, a1.f1);
        assertEquals(a.f2, a1.f2);
        assertEquals(a.f3, a1.f3);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

              
        JSONObject object = JSON.parseObject(str);
        A a1 = object.toJavaObject(A.class);
        assertEquals(a.f1, a1.f1);
        assertEquals(a.f2, a1.f2);
        assertEquals(a.f3, a1.f3);
    }

    public static class A {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 21

                      JSONObject object = JSON.parseObject(str);
        A a1 = object.toJavaObject(A.class);
        assertEquals(a.f1, a1.f1);
        assertEquals(a.f2, a1.f2);
        assertEquals(a.f3, a1.f3);
    }

    public static class A {
        @JSONField(ordinal = 1)

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

                      A a1 = object.toJavaObject(A.class);
        assertEquals(a.f1, a1.f1);
        assertEquals(a.f2, a1.f2);
        assertEquals(a.f3, a1.f3);
    }

    public static class A {
        @JSONField(ordinal = 1)
        public int f1;

            

Reported by PMD.

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

Line: 27

              
    public static class A {
        @JSONField(ordinal = 1)
        public int f1;

        @JSONField(ordinal = 0)
        public int f2;

        @JSONField(ordinal = 2)

            

Reported by PMD.

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

Line: 30

                      public int f1;

        @JSONField(ordinal = 0)
        public int f2;

        @JSONField(ordinal = 2)
        public int f3;
    }
}

            

Reported by PMD.

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

Line: 33

                      public int f2;

        @JSONField(ordinal = 2)
        public int f3;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/mixins/MixinSerForFieldsTest.java
10 issues
No abstract method which means that the keyword is most likely used to prevent instantiation. Use a private or protected constructor instead.
Design

Line: 20

                      }
    }

    abstract class MixIn {
        @JSONField(serialize = false)
        public String a;
        @JSONField(name = "banana")
        public String b;
    }

            

Reported by PMD.

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

Line: 11

              
public class MixinSerForFieldsTest extends TestCase {
    static class BeanClass {
        public String a;
        public String b;

        public BeanClass(String a, String b) {
            this.a = a;
            this.b = b;

            

Reported by PMD.

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

Line: 12

              public class MixinSerForFieldsTest extends TestCase {
    static class BeanClass {
        public String a;
        public String b;

        public BeanClass(String a, String b) {
            this.a = a;
            this.b = b;
        }

            

Reported by PMD.

This abstract class does not have any abstract methods
Design

Line: 20

                      }
    }

    abstract class MixIn {
        @JSONField(serialize = false)
        public String a;
        @JSONField(name = "banana")
        public String b;
    }

            

Reported by PMD.

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

Line: 27

                      public String b;
    }

    public void test() throws Exception{
        BeanClass bean = new BeanClass("1", "2");

        JSON.addMixInAnnotations(BeanClass.class, MixIn.class);
        String jsonString = JSON.toJSONString(bean);
        JSONObject result = JSON.parseObject(jsonString);

            

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 String b;
    }

    public void test() throws Exception{
        BeanClass bean = new BeanClass("1", "2");

        JSON.addMixInAnnotations(BeanClass.class, MixIn.class);
        String jsonString = JSON.toJSONString(bean);
        JSONObject result = JSON.parseObject(jsonString);

            

Reported by PMD.

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

Line: 33

                      JSON.addMixInAnnotations(BeanClass.class, MixIn.class);
        String jsonString = JSON.toJSONString(bean);
        JSONObject result = JSON.parseObject(jsonString);
        assertEquals(1, result.size());
        assertEquals("2", result.get("banana"));
        JSON.removeMixInAnnotations(BeanClass.class);
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 33

                      JSON.addMixInAnnotations(BeanClass.class, MixIn.class);
        String jsonString = JSON.toJSONString(bean);
        JSONObject result = JSON.parseObject(jsonString);
        assertEquals(1, result.size());
        assertEquals("2", result.get("banana"));
        JSON.removeMixInAnnotations(BeanClass.class);
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 34

                      String jsonString = JSON.toJSONString(bean);
        JSONObject result = JSON.parseObject(jsonString);
        assertEquals(1, result.size());
        assertEquals("2", result.get("banana"));
        JSON.removeMixInAnnotations(BeanClass.class);
    }
}

            

Reported by PMD.

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

Line: 34

                      String jsonString = JSON.toJSONString(bean);
        JSONObject result = JSON.parseObject(jsonString);
        assertEquals(1, result.size());
        assertEquals("2", result.get("banana"));
        JSON.removeMixInAnnotations(BeanClass.class);
    }
}

            

Reported by PMD.

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

Line: 13

               * Created by wenshao on 20/03/2017.
 */
public class AtomicLongComptableAndroidTest extends TestCase {
    public void test_for_compatible_zero() throws Exception {
        String text = "{\"andIncrement\":-1,\"andDecrement\":0}";

        assertEquals(0, JSON.parseObject(text, AtomicLong.class).intValue());
    }


            

Reported by PMD.

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

Line: 16

                  public void test_for_compatible_zero() throws Exception {
        String text = "{\"andIncrement\":-1,\"andDecrement\":0}";

        assertEquals(0, JSON.parseObject(text, AtomicLong.class).intValue());
    }

    public void test_for_compatible_six() throws Exception {
        String text = "{\"andIncrement\":5,\"andDecrement\":6}";


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                  public void test_for_compatible_zero() throws Exception {
        String text = "{\"andIncrement\":-1,\"andDecrement\":0}";

        assertEquals(0, JSON.parseObject(text, AtomicLong.class).intValue());
    }

    public void test_for_compatible_six() throws Exception {
        String text = "{\"andIncrement\":5,\"andDecrement\":6}";


            

Reported by PMD.

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

Line: 19

                      assertEquals(0, JSON.parseObject(text, AtomicLong.class).intValue());
    }

    public void test_for_compatible_six() throws Exception {
        String text = "{\"andIncrement\":5,\"andDecrement\":6}";

        assertEquals(6, JSON.parseObject(text, AtomicLong.class).intValue());
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

                  public void test_for_compatible_six() throws Exception {
        String text = "{\"andIncrement\":5,\"andDecrement\":6}";

        assertEquals(6, JSON.parseObject(text, AtomicLong.class).intValue());
    }

    public void test_for_compatible_five() throws Exception {
        String text = "{\"andDecrement\":6,\"andIncrement\":5}";


            

Reported by PMD.

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

Line: 22

                  public void test_for_compatible_six() throws Exception {
        String text = "{\"andIncrement\":5,\"andDecrement\":6}";

        assertEquals(6, JSON.parseObject(text, AtomicLong.class).intValue());
    }

    public void test_for_compatible_five() throws Exception {
        String text = "{\"andDecrement\":6,\"andIncrement\":5}";


            

Reported by PMD.

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

Line: 25

                      assertEquals(6, JSON.parseObject(text, AtomicLong.class).intValue());
    }

    public void test_for_compatible_five() throws Exception {
        String text = "{\"andDecrement\":6,\"andIncrement\":5}";

        assertEquals(5, JSON.parseObject(text, AtomicLong.class).intValue());
    }
}

            

Reported by PMD.

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

Line: 28

                  public void test_for_compatible_five() throws Exception {
        String text = "{\"andDecrement\":6,\"andIncrement\":5}";

        assertEquals(5, JSON.parseObject(text, AtomicLong.class).intValue());
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 28

                  public void test_for_compatible_five() throws Exception {
        String text = "{\"andDecrement\":6,\"andIncrement\":5}";

        assertEquals(5, JSON.parseObject(text, AtomicLong.class).intValue());
    }
}

            

Reported by PMD.

Avoid unused imports such as 'java.util.concurrent.atomic.AtomicInteger'
Design

Line: 6

              import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

/**
 * Created by wenshao on 20/03/2017.
 */

            

Reported by PMD.

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

Line: 10

              import junit.framework.TestCase;

public class JSONCreatorTest10 extends TestCase {
    public void test_for_yk() throws Exception {
        String jsonString = "{\"link\":\"http://lqgzs.org/fsqhwlnf\",\"text\":\"乐动力专享\"}";
        JSONObject headerJSON = JSONObject.parseObject(jsonString);
        HeaderDTO headerDTO = headerJSON.toJavaObject(HeaderDTO.class);

        assertEquals("http://lqgzs.org/fsqhwlnf", headerDTO.link);

            

Reported by PMD.

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

Line: 10

              import junit.framework.TestCase;

public class JSONCreatorTest10 extends TestCase {
    public void test_for_yk() throws Exception {
        String jsonString = "{\"link\":\"http://lqgzs.org/fsqhwlnf\",\"text\":\"乐动力专享\"}";
        JSONObject headerJSON = JSONObject.parseObject(jsonString);
        HeaderDTO headerDTO = headerJSON.toJavaObject(HeaderDTO.class);

        assertEquals("http://lqgzs.org/fsqhwlnf", headerDTO.link);

            

Reported by PMD.

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

Line: 13

                  public void test_for_yk() throws Exception {
        String jsonString = "{\"link\":\"http://lqgzs.org/fsqhwlnf\",\"text\":\"乐动力专享\"}";
        JSONObject headerJSON = JSONObject.parseObject(jsonString);
        HeaderDTO headerDTO = headerJSON.toJavaObject(HeaderDTO.class);

        assertEquals("http://lqgzs.org/fsqhwlnf", headerDTO.link);
        assertEquals("乐动力专享", headerDTO.title);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 15

                      JSONObject headerJSON = JSONObject.parseObject(jsonString);
        HeaderDTO headerDTO = headerJSON.toJavaObject(HeaderDTO.class);

        assertEquals("http://lqgzs.org/fsqhwlnf", headerDTO.link);
        assertEquals("乐动力专享", headerDTO.title);
    }

    public static class HeaderDTO {
        private String title;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                      HeaderDTO headerDTO = headerJSON.toJavaObject(HeaderDTO.class);

        assertEquals("http://lqgzs.org/fsqhwlnf", headerDTO.link);
        assertEquals("乐动力专享", headerDTO.title);
    }

    public static class HeaderDTO {
        private String title;
        private String link;

            

Reported by PMD.

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

Line: 20

                  }

    public static class HeaderDTO {
        private String title;
        private String link;

        @JSONCreator
        public HeaderDTO(@JSONField(name = "text") String title,@JSONField(name = "link") String link) {
            this.title = title;

            

Reported by PMD.

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

Line: 20

                  }

    public static class HeaderDTO {
        private String title;
        private String link;

        @JSONCreator
        public HeaderDTO(@JSONField(name = "text") String title,@JSONField(name = "link") String link) {
            this.title = title;

            

Reported by PMD.

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

Line: 21

              
    public static class HeaderDTO {
        private String title;
        private String link;

        @JSONCreator
        public HeaderDTO(@JSONField(name = "text") String title,@JSONField(name = "link") String link) {
            this.title = title;
            this.link = link;

            

Reported by PMD.

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

Line: 21

              
    public static class HeaderDTO {
        private String title;
        private String link;

        @JSONCreator
        public HeaderDTO(@JSONField(name = "text") String title,@JSONField(name = "link") String link) {
            this.title = title;
            this.link = link;

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.JSON'
Design

Line: 3

              package com.alibaba.json.bvt.parser.creator;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONField;
import junit.framework.TestCase;

public class JSONCreatorTest10 extends TestCase {

            

Reported by PMD.

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

Line: 26

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

        ParserConfig parserConfig = new ParserConfig();
        parserConfig.addAccept("com.alibaba.json.bvt");

            

Reported by PMD.

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

Line: 15

              import com.alibaba.fastjson.serializer.SerializerFeature;

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

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

            

Reported by PMD.

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

Line: 16

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

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

            

Reported by PMD.

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

Line: 19

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

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

            

Reported by PMD.

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

Line: 34

                      parserConfig.addAccept("com.alibaba.json.bvt");
        A a1 = (A) JSON.parseObject(text, Object.class, parserConfig);

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

    private static class A {

            

Reported by PMD.

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

Line: 34

                      parserConfig.addAccept("com.alibaba.json.bvt");
        A a1 = (A) JSON.parseObject(text, Object.class, parserConfig);

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

    private static class A {

            

Reported by PMD.

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

Line: 35

                      A a1 = (A) JSON.parseObject(text, Object.class, parserConfig);

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

    private static class A {


            

Reported by PMD.

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

Line: 35

                      A a1 = (A) JSON.parseObject(text, Object.class, parserConfig);

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

    private static class A {


            

Reported by PMD.

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

Line: 36

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

    private static class A {

        private Set<B> list;

            

Reported by PMD.

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

Line: 36

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

    private static class A {

        private Set<B> list;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/JSONObjectTest_getObj.java
10 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: 16

              
public class JSONObjectTest_getObj extends TestCase {

    public void test_get_empty() throws Exception {
        JSONObject obj = new JSONObject();
        obj.put("value", "");
        Assert.assertEquals("", obj.get("value"));
        Assert.assertNull(obj.getObject("value", Model.class));
    }

            

Reported by PMD.

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

Line: 18

              
    public void test_get_empty() throws Exception {
        JSONObject obj = new JSONObject();
        obj.put("value", "");
        Assert.assertEquals("", obj.get("value"));
        Assert.assertNull(obj.getObject("value", Model.class));
    }
    
    public void test_get_null() 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: 23

                      Assert.assertNull(obj.getObject("value", Model.class));
    }
    
    public void test_get_null() throws Exception {
        JSONObject obj = new JSONObject();
        obj.put("value", "null");
        Assert.assertEquals("null", obj.get("value"));
        Assert.assertNull(obj.getObject("value", Model.class));
    }

            

Reported by PMD.

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

Line: 30

                      Assert.assertNull(obj.getObject("value", Model.class));
    }

    public void test_get_obj() throws Exception {
        JSONObject obj = new JSONObject();
        obj.put("value", new HashMap());
        Assert.assertEquals(new JSONObject(), obj.getObject("value", JSONObject.class));
    }


            

Reported by PMD.

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

Line: 36

                      Assert.assertEquals(new JSONObject(), obj.getObject("value", JSONObject.class));
    }

    public void test_get_obj2() throws Exception {
        List<JSONObject> json = JSON.parseArray("[{\"values\":[{}]}]", JSONObject.class);

        for (JSONObject obj : json) {
            Object values = obj.getObject("values", new TypeReference<List<JSONObject>>() {});
        }

            

Reported by PMD.

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

Line: 36

                      Assert.assertEquals(new JSONObject(), obj.getObject("value", JSONObject.class));
    }

    public void test_get_obj2() throws Exception {
        List<JSONObject> json = JSON.parseArray("[{\"values\":[{}]}]", JSONObject.class);

        for (JSONObject obj : json) {
            Object values = obj.getObject("values", new TypeReference<List<JSONObject>>() {});
        }

            

Reported by PMD.

Avoid unused local variables such as 'values'.
Design

Line: 40

                      List<JSONObject> json = JSON.parseArray("[{\"values\":[{}]}]", JSONObject.class);

        for (JSONObject obj : json) {
            Object values = obj.getObject("values", new TypeReference<List<JSONObject>>() {});
        }
    }
    
    public static class Model {
        

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 40

                      List<JSONObject> json = JSON.parseArray("[{\"values\":[{}]}]", JSONObject.class);

        for (JSONObject obj : json) {
            Object values = obj.getObject("values", new TypeReference<List<JSONObject>>() {});
        }
    }
    
    public static class Model {
        

            

Reported by PMD.

Found 'DD'-anomaly for variable 'values' (lines '40'-'40').
Error

Line: 40

                      List<JSONObject> json = JSON.parseArray("[{\"values\":[{}]}]", JSONObject.class);

        for (JSONObject obj : json) {
            Object values = obj.getObject("values", new TypeReference<List<JSONObject>>() {});
        }
    }
    
    public static class Model {
        

            

Reported by PMD.

Found 'DU'-anomaly for variable 'values' (lines '40'-'42').
Error

Line: 40

                      List<JSONObject> json = JSON.parseArray("[{\"values\":[{}]}]", JSONObject.class);

        for (JSONObject obj : json) {
            Object values = obj.getObject("values", new TypeReference<List<JSONObject>>() {});
        }
    }
    
    public static class Model {
        

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/SpecialTest.java
10 issues
System.out.println is used
Design

Line: 16

                              count++;
            }
        }
        System.out.println(count);
    }
    
    final static long flags;
    static {
        long val = 0L;

            

Reported by PMD.

All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
Design

Line: 5

              
import com.alibaba.fastjson.serializer.SerializerFeature;

public class SpecialTest {
    
    public static void main(String[] args) throws Exception {
        
        int count = 0;
        for (int i = 0; i < 1000; ++i) {

            

Reported by PMD.

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

Line: 7

              
public class SpecialTest {
    
    public static void main(String[] args) throws Exception {
        
        int count = 0;
        for (int i = 0; i < 1000; ++i) {
            char ch = (char) i;
            if(isSpecial(ch)) {

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 28

                  }
    
    static boolean isSpecial(char ch) {
        if (ch <= 31) {
            return true;
        }
        
        if (ch > '\\') { // 92
            return false;

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 32

                          return true;
        }
        
        if (ch > '\\') { // 92
            return false;
        }
        
        return ((1L << (ch - 31)) & flags) != 0;
    }

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 44

                      // return false;
        // }
        
        if (ch == ' ') { // 32
            return false;
        }

        if (ch == '/') { // 47
            return SerializerFeature.isEnabled(features, SerializerFeature.WriteSlashAsSpecial);

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 48

                          return false;
        }

        if (ch == '/') { // 47
            return SerializerFeature.isEnabled(features, SerializerFeature.WriteSlashAsSpecial);
        }

        if (ch > '#' // 35
            && ch != '\\' // 92

            

Reported by PMD.

Avoid unnecessary if..then..else statements when returning booleans
Design

Line: 58

                          return false;
        }

        if (ch <= 0x1F // 31
                || ch == '\\' // 92
                || ch == '"' // 34
                ) {
            return true;
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'count' (lines '9'-'13').
Error

Line: 9

                  
    public static void main(String[] args) throws Exception {
        
        int count = 0;
        for (int i = 0; i < 1000; ++i) {
            char ch = (char) i;
            if(isSpecial(ch)) {
                count++;
            }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'count' (lines '13'-'13').
Error

Line: 13

                      for (int i = 0; i < 1000; ++i) {
            char ch = (char) i;
            if(isSpecial(ch)) {
                count++;
            }
        }
        System.out.println(count);
    }
    

            

Reported by PMD.

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

Line: 23

              		in.setTB_PR_INFO(tb_pr_infos);

		String text = JSON.toJSONString(in);
		System.out.println(text);

		assertEquals(
				"{\"IM_PREQ_NO\":\"111111\",\"TB_PR_INFO\":[{\"PREQ_NO\":\"t1\"},{\"PREQ_NO\":\"t2\"}]}",
				text);


            

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

	public void test_0() throws Exception {
		Z_OA_MM_PR_INFO_IN in = new Z_OA_MM_PR_INFO_IN();
		in.setIM_PREQ_NO("111111");
		TB_PR_INFO t1 = new TB_PR_INFO("t1");
		TB_PR_INFO t2 = new TB_PR_INFO("t2");
		List<TB_PR_INFO> tb_pr_infos = new ArrayList<TB_PR_INFO>();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 25

              		String text = JSON.toJSONString(in);
		System.out.println(text);

		assertEquals(
				"{\"IM_PREQ_NO\":\"111111\",\"TB_PR_INFO\":[{\"PREQ_NO\":\"t1\"},{\"PREQ_NO\":\"t2\"}]}",
				text);

	}


            

Reported by PMD.

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

Line: 31

              
	}

	public void test_1() throws Exception {
		String text = "{\"IM_PREQ_NO\":\"111111\",\"TB_PR_INFO\":[{\"pREQ_NO\":\"t1\"},{\"pREQ_NO\":\"t2\"}]}";
		Z_OA_MM_PR_INFO_IN in = JSON
				.parseObject(text, Z_OA_MM_PR_INFO_IN.class);
		assertEquals("111111", in.getIM_PREQ_NO());
		assertNotNull(in.getTB_PR_INFO());

            

Reported by PMD.

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

Line: 31

              
	}

	public void test_1() throws Exception {
		String text = "{\"IM_PREQ_NO\":\"111111\",\"TB_PR_INFO\":[{\"pREQ_NO\":\"t1\"},{\"pREQ_NO\":\"t2\"}]}";
		Z_OA_MM_PR_INFO_IN in = JSON
				.parseObject(text, Z_OA_MM_PR_INFO_IN.class);
		assertEquals("111111", in.getIM_PREQ_NO());
		assertNotNull(in.getTB_PR_INFO());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 35

              		String text = "{\"IM_PREQ_NO\":\"111111\",\"TB_PR_INFO\":[{\"pREQ_NO\":\"t1\"},{\"pREQ_NO\":\"t2\"}]}";
		Z_OA_MM_PR_INFO_IN in = JSON
				.parseObject(text, Z_OA_MM_PR_INFO_IN.class);
		assertEquals("111111", in.getIM_PREQ_NO());
		assertNotNull(in.getTB_PR_INFO());

	}

	public static class Z_OA_MM_PR_INFO_IN {

            

Reported by PMD.

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

Line: 35

              		String text = "{\"IM_PREQ_NO\":\"111111\",\"TB_PR_INFO\":[{\"pREQ_NO\":\"t1\"},{\"pREQ_NO\":\"t2\"}]}";
		Z_OA_MM_PR_INFO_IN in = JSON
				.parseObject(text, Z_OA_MM_PR_INFO_IN.class);
		assertEquals("111111", in.getIM_PREQ_NO());
		assertNotNull(in.getTB_PR_INFO());

	}

	public static class Z_OA_MM_PR_INFO_IN {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 36

              		Z_OA_MM_PR_INFO_IN in = JSON
				.parseObject(text, Z_OA_MM_PR_INFO_IN.class);
		assertEquals("111111", in.getIM_PREQ_NO());
		assertNotNull(in.getTB_PR_INFO());

	}

	public static class Z_OA_MM_PR_INFO_IN {
		@JSONField(name = "IM_PREQ_NO")

            

Reported by PMD.

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

Line: 36

              		Z_OA_MM_PR_INFO_IN in = JSON
				.parseObject(text, Z_OA_MM_PR_INFO_IN.class);
		assertEquals("111111", in.getIM_PREQ_NO());
		assertNotNull(in.getTB_PR_INFO());

	}

	public static class Z_OA_MM_PR_INFO_IN {
		@JSONField(name = "IM_PREQ_NO")

            

Reported by PMD.

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

Line: 40

              
	}

	public static class Z_OA_MM_PR_INFO_IN {
		@JSONField(name = "IM_PREQ_NO")
		private String IM_PREQ_NO;
		@JSONField(name = "TB_PR_INFO")
		private List<TB_PR_INFO> TB_PR_INFO;


            

Reported by PMD.