The following issues were found

src/test/java/com/alibaba/json/bvt/parser/number/NumberValueTest_error_7.java
4 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 NumberValueTest_error_7 extends TestCase {

    public void test_0() throws Exception {
        Exception error = null;
        try {
            String text = "{\"value\":-";
            JSON.parse(text);
        } catch (Exception e) {

            

Reported by PMD.

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

Line: 17

                      try {
            String text = "{\"value\":-";
            JSON.parse(text);
        } catch (Exception e) {
            error = e;
        }
        Assert.assertNotNull(error);
    }
}

            

Reported by PMD.

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

Line: 6

              import org.junit.Assert;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;

import junit.framework.TestCase;

public class NumberValueTest_error_7 extends TestCase {


            

Reported by PMD.

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

Line: 13

              public class NumberValueTest_error_7 extends TestCase {

    public void test_0() throws Exception {
        Exception error = null;
        try {
            String text = "{\"value\":-";
            JSON.parse(text);
        } catch (Exception e) {
            error = e;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/number/NumberValueTest.java
4 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 NumberValueTest extends TestCase {

    public void test_0() throws Exception {
        String text = "{\"value\":3D}";
        JSONObject obj = (JSONObject) JSON.parse(text);
        Assert.assertTrue(3D == ((Double)obj.get("value")).doubleValue()); 

    }

            

Reported by PMD.

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

Line: 15

                  public void test_0() throws Exception {
        String text = "{\"value\":3D}";
        JSONObject obj = (JSONObject) JSON.parse(text);
        Assert.assertTrue(3D == ((Double)obj.get("value")).doubleValue()); 

    }
    
    public void test_1() throws Exception {
        String text = "{\"value\":3.e3D}";

            

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

              
    }
    
    public void test_1() throws Exception {
        String text = "{\"value\":3.e3D}";
        JSONObject obj = (JSONObject) JSON.parse(text);
        Assert.assertTrue(3.e3D == ((Double)obj.get("value")).doubleValue()); 

    }

            

Reported by PMD.

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

Line: 22

                  public void test_1() throws Exception {
        String text = "{\"value\":3.e3D}";
        JSONObject obj = (JSONObject) JSON.parse(text);
        Assert.assertTrue(3.e3D == ((Double)obj.get("value")).doubleValue()); 

    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/DupSetterTest6.java
4 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: 21

              
public class DupSetterTest6 extends TestCase {

    public void testDupSetter() {
        VO vo = new VO();
        vo.status = 3;
        String json = JSONObject.toJSONString(vo);
        VO vo2 = JSONObject.parseObject(json, VO.class);
        Assert.assertEquals(3, vo2.status3);

            

Reported by PMD.

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

Line: 29

                      Assert.assertEquals(3, vo2.status3);
    }

    public static class VO {

        public int status;
        private int status2;
        private int status3;


            

Reported by PMD.

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

Line: 32

                  public static class VO {

        public int status;
        private int status2;
        private int status3;

        public Integer getStatus() {
            return status;
        }

            

Reported by PMD.

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

Line: 33

              
        public int status;
        private int status2;
        private int status3;

        public Integer getStatus() {
            return status;
        }


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/FloatArraySerializerTest.java
4 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 FloatArraySerializerTest extends TestCase {

    public void test_0() {
        Assert.assertEquals("[]", JSON.toJSONString(new float[0]));
        Assert.assertEquals("{\"value\":null}", JSON.toJSONString(new Entity(), SerializerFeature.WriteMapNullValue));
        Assert.assertEquals("{\"value\":[]}", JSON.toJSONString(new Entity(), SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty));
        Assert.assertEquals("[1.0,2.0]", JSON.toJSONString(new float[] { 1, 2 }));
        Assert.assertEquals("[1.0,2.0,3.0]", JSON.toJSONString(new float[] { 1, 2, 3 }));

            

Reported by PMD.

Returning 'value' may expose an internal array.
Design

Line: 26

                      private float[] value;

        public float[] getValue() {
            return value;
        }

        public void setValue(float[] value) {
            this.value = value;
        }

            

Reported by PMD.

The user-supplied array 'value' is stored directly.
Design

Line: 29

                          return value;
        }

        public void setValue(float[] value) {
            this.value = value;
        }

    }
}

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 29

                          return value;
        }

        public void setValue(float[] value) {
            this.value = value;
        }

    }
}

            

Reported by PMD.

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

Line: 12

               * Created by wenshao on 10/02/2017.
 */
public class GenericTypeNotMatchTest2 extends TestCase {
    public void test_for_notMatch() throws Exception {
        Model model = new Model();

        Base base = model;
        base.setId(BigInteger.valueOf(3));


            

Reported by PMD.

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

Line: 12

               * Created by wenshao on 10/02/2017.
 */
public class GenericTypeNotMatchTest2 extends TestCase {
    public void test_for_notMatch() throws Exception {
        Model model = new Model();

        Base base = model;
        base.setId(BigInteger.valueOf(3));


            

Reported by PMD.

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

Line: 16

                      Model model = new Model();

        Base base = model;
        base.setId(BigInteger.valueOf(3));

        JSON.toJSONString(base);
    }



            

Reported by PMD.

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

Line: 27

                  }

    public static class Base<T> {
        private T xid;

        public void setId(T id) {
            this.xid = id;
        }


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/GenericTypeTest2.java
4 issues
JUnit tests should include assert() or fail()
Design

Line: 11

              
public class GenericTypeTest2 extends TestCase {
    
    public void test_gerneric() throws Exception {
        MyResultResult result = new MyResultResult();
        JSON.toJSONString(result);
    }
    
    public static class MyResultResult extends BaseResult<String> {

            

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

              
public class GenericTypeTest2 extends TestCase {
    
    public void test_gerneric() throws Exception {
        MyResultResult result = new MyResultResult();
        JSON.toJSONString(result);
    }
    
    public static class MyResultResult extends BaseResult<String> {

            

Reported by PMD.

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

Line: 20

                  }
    
    public static class BaseResult<T>  {
        private T data;
        public T getData() {
            return data;
        }
    }
}

            

Reported by PMD.

Avoid unused imports such as 'java.io.Serializable'
Design

Line: 3

              package com.alibaba.json.bvt.serializer;

import java.io.Serializable;

import com.alibaba.fastjson.JSON;

import junit.framework.TestCase;

public class GenericTypeTest2 extends TestCase {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/IgnoreGetMethodTest.java
4 issues
Avoid throwing raw exception types.
Design

Line: 25

                  public static class PayDO {

        public Integer getCurrentSubPayOrder() {
            throw new RuntimeException("non getter getXXX method should not be called");
        }
    }

}

            

Reported by PMD.

System.out.println is used
Design

Line: 19

                  public void test() {
        PayDO result = new PayDO();
        String json = JSON.toJSONString(result, SerializerFeature.IgnoreNonFieldGetter);
        System.out.println(json);
    }
    
    public static class PayDO {

        public Integer getCurrentSubPayOrder() {

            

Reported by PMD.

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

Line: 16

              //        System.out.println(json);
//    }

    public void test() {
        PayDO result = new PayDO();
        String json = JSON.toJSONString(result, SerializerFeature.IgnoreNonFieldGetter);
        System.out.println(json);
    }
    

            

Reported by PMD.

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

Line: 16

              //        System.out.println(json);
//    }

    public void test() {
        PayDO result = new PayDO();
        String json = JSON.toJSONString(result, SerializerFeature.IgnoreNonFieldGetter);
        System.out.println(json);
    }
    

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/typeRef/TypeReferenceTest4.java
4 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

              
public class TypeReferenceTest4 extends TestCase {

    public void test_typeRef() throws Exception {
        TypeReference<VO<List<A>>> typeRef = new TypeReference<VO<List<A>>>() {
        };

        VO<List<A>> vo = JSON.parseObject("{\"list\":[{\"id\":123}]}", typeRef);


            

Reported by PMD.

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

Line: 19

              
        VO<List<A>> vo = JSON.parseObject("{\"list\":[{\"id\":123}]}", typeRef);

        Assert.assertEquals(123, vo.getList().get(0).getId());
    }

    public static class VO<T> {

        private T list;

            

Reported by PMD.

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

Line: 19

              
        VO<List<A>> vo = JSON.parseObject("{\"list\":[{\"id\":123}]}", typeRef);

        Assert.assertEquals(123, vo.getList().get(0).getId());
    }

    public static class VO<T> {

        private T list;

            

Reported by PMD.

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

Line: 19

              
        VO<List<A>> vo = JSON.parseObject("{\"list\":[{\"id\":123}]}", typeRef);

        Assert.assertEquals(123, vo.getList().get(0).getId());
    }

    public static class VO<T> {

        private T list;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/IntArrayEncodeTest.java
4 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: 11

              
public class IntArrayEncodeTest extends TestCase {

    public void test_0_s() throws Exception {
        SerializeWriter out = new SerializeWriter(1);

        JSONSerializer serializer = new JSONSerializer(out);
        serializer.write(new int[] { 0, 1 });


            

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

                      Assert.assertEquals("[0,1]", out.toString());
    }

    public void test_1_s() throws Exception {
        SerializeWriter out = new SerializeWriter();

        JSONSerializer serializer = new JSONSerializer(out);
        serializer.write(new int[] {});


            

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

                      Assert.assertEquals("[]", out.toString());
    }

    public void test_2_s() throws Exception {
        SerializeWriter out = new SerializeWriter();

        JSONSerializer serializer = new JSONSerializer(out);
        serializer.write(new int[] { -2147483648 });


            

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("[-2147483648]", out.toString());
    }

    public void test_3_s() throws Exception {
        SerializeWriter out = new SerializeWriter();

        JSONSerializer serializer = new JSONSerializer(out);

        StringBuilder sb = new StringBuilder();

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/JSONFieldTest3.java
4 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 com.alibaba.fastjson.annotation.JSONField;

public class JSONFieldTest3 extends TestCase {
	public void test_jsonField() throws Exception {
		VO vo = new VO();

		vo.setId(123);
		vo.setFlag(true);


            

Reported by PMD.

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

Line: 20

              		Assert.assertEquals("{\"id\":123}", text);
	}

	public static class VO {
		private int id;

		@JSONField(serialize = false)
		private boolean _flag;
		

            

Reported by PMD.

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

Line: 24

              		private int id;

		@JSONField(serialize = false)
		private boolean _flag;
		
		@JSONField(serialize = false)
		private int _id2;

		public int getId() {

            

Reported by PMD.

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

Line: 27

              		private boolean _flag;
		
		@JSONField(serialize = false)
		private int _id2;

		public int getId() {
			return id;
		}


            

Reported by PMD.