The following issues were found

src/main/java/com/alibaba/fastjson/serializer/BigIntegerCodec.java
8 issues
Potential violation of Law of Demeter (object not created locally)
Design

Line: 51

                      }
        
        BigInteger val = (BigInteger) object;
        String str = val.toString();
        if (str.length() >= 16
                && SerializerFeature.isEnabled(features, out.features, SerializerFeature.BrowserCompatible)
                && (val.compareTo(LOW) < 0
                    || val.compareTo(HIGH) > 0))
        {

            

Reported by PMD.

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

Line: 52

                      
        BigInteger val = (BigInteger) object;
        String str = val.toString();
        if (str.length() >= 16
                && SerializerFeature.isEnabled(features, out.features, SerializerFeature.BrowserCompatible)
                && (val.compareTo(LOW) < 0
                    || val.compareTo(HIGH) > 0))
        {
            out.writeString(str);

            

Reported by PMD.

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

Line: 54

                      String str = val.toString();
        if (str.length() >= 16
                && SerializerFeature.isEnabled(features, out.features, SerializerFeature.BrowserCompatible)
                && (val.compareTo(LOW) < 0
                    || val.compareTo(HIGH) > 0))
        {
            out.writeString(str);
            return;
        }

            

Reported by PMD.

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

Line: 55

                      if (str.length() >= 16
                && SerializerFeature.isEnabled(features, out.features, SerializerFeature.BrowserCompatible)
                && (val.compareTo(LOW) < 0
                    || val.compareTo(HIGH) > 0))
        {
            out.writeString(str);
            return;
        }
        out.write(str);

            

Reported by PMD.

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

Line: 60

                          out.writeString(str);
            return;
        }
        out.write(str);
    }

    @SuppressWarnings("unchecked")
    public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
        return (T) deserialze(parser);

            

Reported by PMD.

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

Line: 71

                  @SuppressWarnings("unchecked")
    public static <T> T deserialze(DefaultJSONParser parser) {
        final JSONLexer lexer = parser.lexer;
        if (lexer.token() == JSONToken.LITERAL_INT) {
            String val = lexer.numberString();
            lexer.nextToken(JSONToken.COMMA);

            if (val.length() > 65535) {
                throw new JSONException("decimal overflow");

            

Reported by PMD.

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

Line: 75

                          String val = lexer.numberString();
            lexer.nextToken(JSONToken.COMMA);

            if (val.length() > 65535) {
                throw new JSONException("decimal overflow");
            }

            return (T) new BigInteger(val);
        }

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 75

                          String val = lexer.numberString();
            lexer.nextToken(JSONToken.COMMA);

            if (val.length() > 65535) {
                throw new JSONException("decimal overflow");
            }

            return (T) new BigInteger(val);
        }

            

Reported by PMD.

src/test/java/com/alibaba/fastjson/deserializer/issues3796/bean/ObjectP1_B.java
8 issues
The class 'ObjectP1_B' is suspected to be a Data Class (WOC=0.000%, NOPA=0, NOAM=16, WMC=16)
Design

Line: 8

              


public class ObjectP1_B {
    
    private long a = 0;
    
    private int b = 0;
	

            

Reported by PMD.

Avoid using redundant field initializer for 'a'
Performance

Line: 10

              
public class ObjectP1_B {
    
    private long a = 0;
    
    private int b = 0;
	
	private int c = 0;
    

            

Reported by PMD.

Avoid using redundant field initializer for 'b'
Performance

Line: 12

                  
    private long a = 0;
    
    private int b = 0;
	
	private int c = 0;
    
    private int d = 0;
	

            

Reported by PMD.

Avoid using redundant field initializer for 'c'
Performance

Line: 14

                  
    private int b = 0;
	
	private int c = 0;
    
    private int d = 0;
	
	private int e = 0;
	

            

Reported by PMD.

Avoid using redundant field initializer for 'd'
Performance

Line: 16

              	
	private int c = 0;
    
    private int d = 0;
	
	private int e = 0;
	
	private int f = 0;
    

            

Reported by PMD.

Avoid using redundant field initializer for 'e'
Performance

Line: 18

                  
    private int d = 0;
	
	private int e = 0;
	
	private int f = 0;
    
    private long g = 0;
    

            

Reported by PMD.

Avoid using redundant field initializer for 'f'
Performance

Line: 20

              	
	private int e = 0;
	
	private int f = 0;
    
    private long g = 0;
    
    private boolean h = true;


            

Reported by PMD.

Avoid using redundant field initializer for 'g'
Performance

Line: 22

              	
	private int f = 0;
    
    private long g = 0;
    
    private boolean h = true;

    public long getA() {
        return a;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_102_for_rongganlin.java
8 issues
JUnit tests should include assert() or fail()
Design

Line: 10

              
public class Bug_102_for_rongganlin extends TestCase {

    public void test_bug() throws Exception {
        TestBean testProcessInfo = new TestBean();
        com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject();
        jo.put("id", 121);
        ParserConfig config = new ParserConfig();
        testProcessInfo = TypeUtils.cast(jo, TestBean.class, config);

            

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

              
public class Bug_102_for_rongganlin extends TestCase {

    public void test_bug() throws Exception {
        TestBean testProcessInfo = new TestBean();
        com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject();
        jo.put("id", 121);
        ParserConfig config = new ParserConfig();
        testProcessInfo = TypeUtils.cast(jo, TestBean.class, config);

            

Reported by PMD.

The initializer for variable 'testProcessInfo' is never used (overwritten on line 15)
Design

Line: 11

              public class Bug_102_for_rongganlin extends TestCase {

    public void test_bug() throws Exception {
        TestBean testProcessInfo = new TestBean();
        com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject();
        jo.put("id", 121);
        ParserConfig config = new ParserConfig();
        testProcessInfo = TypeUtils.cast(jo, TestBean.class, config);
    }

            

Reported by PMD.

Avoid unused local variables such as 'testProcessInfo'.
Design

Line: 11

              public class Bug_102_for_rongganlin extends TestCase {

    public void test_bug() throws Exception {
        TestBean testProcessInfo = new TestBean();
        com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject();
        jo.put("id", 121);
        ParserConfig config = new ParserConfig();
        testProcessInfo = TypeUtils.cast(jo, TestBean.class, config);
    }

            

Reported by PMD.

The value assigned to variable 'testProcessInfo' is never used
Design

Line: 15

                      com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject();
        jo.put("id", 121);
        ParserConfig config = new ParserConfig();
        testProcessInfo = TypeUtils.cast(jo, TestBean.class, config);
    }

    public static class TestBean {

        private double id;

            

Reported by PMD.

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

Line: 18

                      testProcessInfo = TypeUtils.cast(jo, TestBean.class, config);
    }

    public static class TestBean {

        private double id;
        private double name;

        public double getId() {

            

Reported by PMD.

Found 'DD'-anomaly for variable 'testProcessInfo' (lines '11'-'15').
Error

Line: 11

              public class Bug_102_for_rongganlin extends TestCase {

    public void test_bug() throws Exception {
        TestBean testProcessInfo = new TestBean();
        com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject();
        jo.put("id", 121);
        ParserConfig config = new ParserConfig();
        testProcessInfo = TypeUtils.cast(jo, TestBean.class, config);
    }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'testProcessInfo' (lines '15'-'16').
Error

Line: 15

                      com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject();
        jo.put("id", 121);
        ParserConfig config = new ParserConfig();
        testProcessInfo = TypeUtils.cast(jo, TestBean.class, config);
    }

    public static class TestBean {

        private double id;

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/serializer/BooleanCodec.java
8 issues
Potential violation of Law of Demeter (object not created locally)
Design

Line: 45

                          return;
        }

        if (value.booleanValue()) {
            out.write("true");
        } else {
            out.write("false");
        }
    }

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 69

                              int intValue = lexer.intValue();
                lexer.nextToken(JSONToken.COMMA);

                if (intValue == 1) {
                    boolObj = Boolean.TRUE;
                } else {
                    boolObj = Boolean.FALSE;
                }
            } else {

            

Reported by PMD.

Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
Design

Line: 83

              
                boolObj = TypeUtils.castToBoolean(value);
            }
        } catch (Exception ex) {
            throw new JSONException("parseBoolean error, field : " + fieldName, ex);
        }

        if (clazz == AtomicBoolean.class) {
            return (T) new AtomicBoolean(boolObj.booleanValue());

            

Reported by PMD.

Found 'DU'-anomaly for variable 'boolObj' (lines '61'-'92').
Error

Line: 61

                      try {
            if (lexer.token() == JSONToken.TRUE) {
                lexer.nextToken(JSONToken.COMMA);
                boolObj = Boolean.TRUE;
            } else if (lexer.token() == JSONToken.FALSE) {
                lexer.nextToken(JSONToken.COMMA);
                boolObj = Boolean.FALSE;
            } else if (lexer.token() == JSONToken.LITERAL_INT) {
                int intValue = lexer.intValue();

            

Reported by PMD.

Found 'DU'-anomaly for variable 'boolObj' (lines '64'-'92').
Error

Line: 64

                              boolObj = Boolean.TRUE;
            } else if (lexer.token() == JSONToken.FALSE) {
                lexer.nextToken(JSONToken.COMMA);
                boolObj = Boolean.FALSE;
            } else if (lexer.token() == JSONToken.LITERAL_INT) {
                int intValue = lexer.intValue();
                lexer.nextToken(JSONToken.COMMA);

                if (intValue == 1) {

            

Reported by PMD.

Found 'DU'-anomaly for variable 'boolObj' (lines '70'-'92').
Error

Line: 70

                              lexer.nextToken(JSONToken.COMMA);

                if (intValue == 1) {
                    boolObj = Boolean.TRUE;
                } else {
                    boolObj = Boolean.FALSE;
                }
            } else {
                Object value = parser.parse();

            

Reported by PMD.

Found 'DU'-anomaly for variable 'boolObj' (lines '72'-'92').
Error

Line: 72

                              if (intValue == 1) {
                    boolObj = Boolean.TRUE;
                } else {
                    boolObj = Boolean.FALSE;
                }
            } else {
                Object value = parser.parse();

                if (value == null) {

            

Reported by PMD.

Found 'DU'-anomaly for variable 'boolObj' (lines '81'-'92').
Error

Line: 81

                                  return null;
                }

                boolObj = TypeUtils.castToBoolean(value);
            }
        } catch (Exception ex) {
            throw new JSONException("parseBoolean error, field : " + fieldName, ex);
        }


            

Reported by PMD.

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

Line: 28

                      MyObj o = JSON.parseObject(s, MyObj.class, Feature.AllowISO8601DateFormat);
        MyObj o2 = JSON.parseObject(s2, MyObj.class, Feature.AllowISO8601DateFormat);

        System.out.println(DateFormat.getDateTimeInstance().format(o.getDate()));
        System.out.println(DateFormat.getDateTimeInstance().format(o2.getDate()));

        // 修复之前输出
        // 2015-7-22 19:13:42
        // 2015-7-23 3:13:42

            

Reported by PMD.

System.out.println is used
Design

Line: 29

                      MyObj o2 = JSON.parseObject(s2, MyObj.class, Feature.AllowISO8601DateFormat);

        System.out.println(DateFormat.getDateTimeInstance().format(o.getDate()));
        System.out.println(DateFormat.getDateTimeInstance().format(o2.getDate()));

        // 修复之前输出
        // 2015-7-22 19:13:42
        // 2015-7-23 3:13:42


            

Reported by PMD.

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

Line: 20

              
public class Bug_376_for_iso8601 extends TestCase {

    public void test_fix() {

        String s = "{date: \"2015-07-22T19:13:42Z\"}";
        String s2 = "{date: \"2015-07-22T19:13:42.000Z\"}";

        MyObj o = JSON.parseObject(s, MyObj.class, Feature.AllowISO8601DateFormat);

            

Reported by PMD.

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

Line: 20

              
public class Bug_376_for_iso8601 extends TestCase {

    public void test_fix() {

        String s = "{date: \"2015-07-22T19:13:42Z\"}";
        String s2 = "{date: \"2015-07-22T19:13:42.000Z\"}";

        MyObj o = JSON.parseObject(s, MyObj.class, Feature.AllowISO8601DateFormat);

            

Reported by PMD.

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

Line: 28

                      MyObj o = JSON.parseObject(s, MyObj.class, Feature.AllowISO8601DateFormat);
        MyObj o2 = JSON.parseObject(s2, MyObj.class, Feature.AllowISO8601DateFormat);

        System.out.println(DateFormat.getDateTimeInstance().format(o.getDate()));
        System.out.println(DateFormat.getDateTimeInstance().format(o2.getDate()));

        // 修复之前输出
        // 2015-7-22 19:13:42
        // 2015-7-23 3:13:42

            

Reported by PMD.

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

Line: 28

                      MyObj o = JSON.parseObject(s, MyObj.class, Feature.AllowISO8601DateFormat);
        MyObj o2 = JSON.parseObject(s2, MyObj.class, Feature.AllowISO8601DateFormat);

        System.out.println(DateFormat.getDateTimeInstance().format(o.getDate()));
        System.out.println(DateFormat.getDateTimeInstance().format(o2.getDate()));

        // 修复之前输出
        // 2015-7-22 19:13:42
        // 2015-7-23 3:13:42

            

Reported by PMD.

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

Line: 29

                      MyObj o2 = JSON.parseObject(s2, MyObj.class, Feature.AllowISO8601DateFormat);

        System.out.println(DateFormat.getDateTimeInstance().format(o.getDate()));
        System.out.println(DateFormat.getDateTimeInstance().format(o2.getDate()));

        // 修复之前输出
        // 2015-7-22 19:13:42
        // 2015-7-23 3:13:42


            

Reported by PMD.

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

Line: 29

                      MyObj o2 = JSON.parseObject(s2, MyObj.class, Feature.AllowISO8601DateFormat);

        System.out.println(DateFormat.getDateTimeInstance().format(o.getDate()));
        System.out.println(DateFormat.getDateTimeInstance().format(o2.getDate()));

        // 修复之前输出
        // 2015-7-22 19:13:42
        // 2015-7-23 3:13:42


            

Reported by PMD.

src/test/java/com/alibaba/json/test/a/SpecialTest.java
8 issues
System.out.println is used
Design

Line: 16

                              count++;
            }
        }
        System.out.println(count);
    }
    static boolean isSpecial(char ch, int features) {
        // if (ch > ']') {
        // return false;
        // }

            

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, 0)) {

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 23

                      // 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: 27

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

                          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, 0)) {
                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, 0)) {
                count++;
            }
        }
        System.out.println(count);
    }
    static boolean isSpecial(char ch, int features) {

            

Reported by PMD.

src/test/java/com/alibaba/json/test/dubbo/Person.java
8 issues
The class 'Person' is suspected to be a Data Class (WOC=12.500%, NOPA=0, NOAM=12, WMC=41)
Design

Line: 25

               * 
 * @author tony.chenl
 */
public class Person implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

            

Reported by PMD.

The class 'Person' has a Modified Cyclomatic Complexity of 3 (Highest = 20).
Design

Line: 25

               * 
 * @author tony.chenl
 */
public class Person implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

            

Reported by PMD.

The class 'Person' has a Standard Cyclomatic Complexity of 3 (Highest = 20).
Design

Line: 25

               * 
 * @author tony.chenl
 */
public class Person implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

            

Reported by PMD.

The method 'equals(Object)' has an NPath complexity of 16384, current threshold is 200
Design

Line: 114

                  }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())

            

Reported by PMD.

The method 'equals' has a Standard Cyclomatic Complexity of 20.
Design

Line: 114

                  }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())

            

Reported by PMD.

The method 'equals' has a Modified Cyclomatic Complexity of 20.
Design

Line: 114

                  }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())

            

Reported by PMD.

The method 'equals(Object)' has a cyclomatic complexity of 20.
Design

Line: 114

                  }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())

            

Reported by PMD.

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

Line: 147

                              return false;
        } else if (!personId.equals(other.personId))
            return false;
        if (status != other.status)
            return false;
        return true;
    }

}

            

Reported by PMD.

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

Line: 22

                      A a = new A();
        a.setList(Collections.singletonList(new B()));
        String text = JSON.toJSONString(a, SerializerFeature.WriteClassName);
        System.out.println(text);
        Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_List2$A\",\"list\":[{\"id\":0}]}",
                            text);

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


            

Reported by PMD.

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

Line: 14

              import com.alibaba.fastjson.serializer.SerializerFeature;

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

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

            

Reported by PMD.

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

Line: 15

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

    public void test_list() throws Exception {
        A a = new A();
        a.setList(Collections.singletonList(new 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: 18

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

    public void test_list() throws Exception {
        A a = new A();
        a.setList(Collections.singletonList(new B()));
        String text = JSON.toJSONString(a, SerializerFeature.WriteClassName);
        System.out.println(text);
        Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_List2$A\",\"list\":[{\"id\":0}]}",

            

Reported by PMD.

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

Line: 28

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

        Assert.assertEquals(1, a1.getList().size());
        Assert.assertTrue(a1.getList().get(0) instanceof B);
    }

    public static class A {


            

Reported by PMD.

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

Line: 28

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

        Assert.assertEquals(1, a1.getList().size());
        Assert.assertTrue(a1.getList().get(0) instanceof B);
    }

    public static class A {


            

Reported by PMD.

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

Line: 29

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

        Assert.assertEquals(1, a1.getList().size());
        Assert.assertTrue(a1.getList().get(0) instanceof B);
    }

    public static class A {

        private List<B> list;

            

Reported by PMD.

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

Line: 29

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

        Assert.assertEquals(1, a1.getList().size());
        Assert.assertTrue(a1.getList().get(0) instanceof B);
    }

    public static class A {

        private List<B> list;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/writeAsArray/WriteAsArray_float2_private.java
8 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

              import junit.framework.TestCase;

public class WriteAsArray_float2_private extends TestCase {
    public void test_0 () throws Exception {
        VO vo = new VO();
        vo.setId(123F);
        vo.setName("wenshao");
        
        String text = JSON.toJSONString(vo, SerializerFeature.BeanToArray);

            

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(vo.name, vo2.name);
    }
    
    public void test_error() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[123.A,\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;

            

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.assertNotNull(error);
    }
    
    public void test_error1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[\"A\",\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;

            

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

                      Assert.assertNotNull(error);
    }
    
    public void test_error2() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[123:\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

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

Line: 56

                      Assert.assertNotNull(error);
    }
    
    private static class VO {
        private float id;
        private String name;

        public float getId() {
            return id;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '27'-'31').
Error

Line: 27

                  }
    
    public void test_error() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[123.A,\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

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

Line: 37

                  }
    
    public void test_error1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[\"A\",\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '47'-'51').
Error

Line: 47

                  }
    
    public void test_error2() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[123:\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/writeAsArray/WriteAsArray_float2_public.java
8 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

              import junit.framework.TestCase;

public class WriteAsArray_float2_public extends TestCase {
    public void test_0 () throws Exception {
        VO vo = new VO();
        vo.setId(123F);
        vo.setName("wenshao");
        
        String text = JSON.toJSONString(vo, SerializerFeature.BeanToArray);

            

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(vo.name, vo2.name);
    }
    
    public void test_error() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[123.A,\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;

            

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.assertNotNull(error);
    }
    
    public void test_error1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[\"A\",\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;

            

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

                      Assert.assertNotNull(error);
    }
    
    public void test_error2() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[123:\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

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

Line: 56

                      Assert.assertNotNull(error);
    }
    
    public static class VO {
        private float id;
        private String name;

        public float getId() {
            return id;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '27'-'31').
Error

Line: 27

                  }
    
    public void test_error() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[123.A,\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

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

Line: 37

                  }
    
    public void test_error1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[\"A\",\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '47'-'51').
Error

Line: 47

                  }
    
    public void test_error2() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[123:\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.