The following issues were found

src/test/java/com/alibaba/json/bvt/ArmoryTest.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: 14

              
public class ArmoryTest extends TestCase {
    
    public void test_item() throws Exception {
        Item item = new Item();
        String text = JSON.toJSONString(item, SerializerFeature.SortField, SerializerFeature.UseSingleQuotes);
        Assert.assertEquals("{'id':0,'name':'xx'}", 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: 20

                      Assert.assertEquals("{'id':0,'name':'xx'}", text);
    }

    public void test_0() throws Exception {
        List<Object> message = new ArrayList<Object>();
        MessageBody body = new MessageBody();
        Item item = new Item();
        body.getItems().add(item);
        

            

Reported by PMD.

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

Line: 24

                      List<Object> message = new ArrayList<Object>();
        MessageBody body = new MessageBody();
        Item item = new Item();
        body.getItems().add(item);
        
        message.add(new MessageHead());
        message.add(body);

        String text = JSON.toJSONString(message, SerializerFeature.SortField, SerializerFeature.UseSingleQuotes);

            

Reported by PMD.

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

Line: 33

                      Assert.assertEquals("[{},{'items':[{'id':0,'name':'xx'}]}]", text);
    }
    
    public static class Item {
        private int id;
        private String name = "xx";
        
        public int getId() {
            return id;

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/serializer/LongCodec.java
4 issues
Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
Design

Line: 85

                                  return null;
                }
            }
        } catch (Exception ex) {
            throw new JSONException("parseLong error, field : " + fieldName, ex);
        }
        
        return clazz == AtomicLong.class //
            ? (T) new AtomicLong(longObject.longValue()) //

            

Reported by PMD.

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

Line: 90

                      }
        
        return clazz == AtomicLong.class //
            ? (T) new AtomicLong(longObject.longValue()) //
            : (T) longObject;
    }

    public int getFastMatchToken() {
        return JSONToken.LITERAL_INT;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'longObject' (lines '66'-'92').
Error

Line: 66

                          if (token == JSONToken.LITERAL_INT) {
                long longValue = lexer.longValue();
                lexer.nextToken(JSONToken.COMMA);
                longObject = Long.valueOf(longValue);
            } else if (token == JSONToken.LITERAL_FLOAT) {
                BigDecimal number = lexer.decimalValue();
                longObject = TypeUtils.longValue(number);
                lexer.nextToken(JSONToken.COMMA);
            } else {

            

Reported by PMD.

Found 'DU'-anomaly for variable 'longObject' (lines '69'-'92').
Error

Line: 69

                              longObject = Long.valueOf(longValue);
            } else if (token == JSONToken.LITERAL_FLOAT) {
                BigDecimal number = lexer.decimalValue();
                longObject = TypeUtils.longValue(number);
                lexer.nextToken(JSONToken.COMMA);
            } else {
                if (token == JSONToken.LBRACE) {
                    JSONObject jsonObject = new JSONObject(true);
                    parser.parseObject(jsonObject);

            

Reported by PMD.

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

Line: 15

                      Foo excepted = new Foo();
        excepted.setName("mock");
        String json;
        System.out.println(json = JSON.toJSONString(excepted, true));
        Foo actually = JSON.parseObject(json, Foo.class);
        assertEquals(excepted.getName(), actually.getName());
    }

    public static class Foo {

            

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

               * Created by wenshao on 2016/11/10.
 */
public class Issue887 extends TestCase {
    public void test_for_issue() throws Exception {
        Foo excepted = new Foo();
        excepted.setName("mock");
        String json;
        System.out.println(json = JSON.toJSONString(excepted, true));
        Foo actually = JSON.parseObject(json, Foo.class);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                      String json;
        System.out.println(json = JSON.toJSONString(excepted, true));
        Foo actually = JSON.parseObject(json, Foo.class);
        assertEquals(excepted.getName(), actually.getName());
    }

    public static class Foo {
        @JSONField(name = "foo.name")
        private String name;

            

Reported by PMD.

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

Line: 17

                      String json;
        System.out.println(json = JSON.toJSONString(excepted, true));
        Foo actually = JSON.parseObject(json, Foo.class);
        assertEquals(excepted.getName(), actually.getName());
    }

    public static class Foo {
        @JSONField(name = "foo.name")
        private String name;

            

Reported by PMD.

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

    public void test_codec_null() throws Exception {
        V0 v = new V0(123);

        String text = JSON.toJSONString(v);
        Assert.assertEquals("{\"value\":123}", text);


            

Reported by PMD.

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

Line: 21

              
        V0 v1 = JSON.parseObject(text, V0.class);

        Assert.assertEquals(v1.getValue().intValue(), v.getValue().intValue());
    }

    public static class V0 {

        private final AtomicLong value;

            

Reported by PMD.

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

Line: 21

              
        V0 v1 = JSON.parseObject(text, V0.class);

        Assert.assertEquals(v1.getValue().intValue(), v.getValue().intValue());
    }

    public static class V0 {

        private final AtomicLong value;

            

Reported by PMD.

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

Line: 21

              
        V0 v1 = JSON.parseObject(text, V0.class);

        Assert.assertEquals(v1.getValue().intValue(), v.getValue().intValue());
    }

    public static class V0 {

        private final AtomicLong value;

            

Reported by PMD.

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

Line: 21

              
		final String newJsonString = JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue,
				SerializerFeature.WriteClassName);
		System.out.println(newJsonString);

		final Object newObject = JSON.parse(newJsonString);

		System.out.println(newObject);
	}

            

Reported by PMD.

System.out.println is used
Design

Line: 25

              
		final Object newObject = JSON.parse(newJsonString);

		System.out.println(newObject);
	}
}

            

Reported by PMD.

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

Line: 13

              
public class Bug_for_lenolix_5 extends TestCase {

	public void test_for_objectKey() throws Exception {
		final Map<Object, Object> obj = new HashMap<Object, Object>();
		final Object obja = new Object();
		final Object objb = new Object();
		obj.put(obja, objb);


            

Reported by PMD.

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

Line: 13

              
public class Bug_for_lenolix_5 extends TestCase {

	public void test_for_objectKey() throws Exception {
		final Map<Object, Object> obj = new HashMap<Object, Object>();
		final Object obja = new Object();
		final Object objb = new Object();
		obj.put(obja, objb);


            

Reported by PMD.

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

Line: 12

              

public class Bug_for_issue_676 extends TestCase {
    public void test_for_issue() throws Exception {
        JSON.parseObject("{\"modelType\":\"\"}", MenuExpend.class);
    }
    
    public static class MenuExpend {
        public ModelType modelType;

            

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 Bug_for_issue_676 extends TestCase {
    public void test_for_issue() throws Exception {
        JSON.parseObject("{\"modelType\":\"\"}", MenuExpend.class);
    }
    
    public static class MenuExpend {
        public ModelType modelType;

            

Reported by PMD.

Avoid unused imports such as 'org.junit.Assert'
Design

Line: 5

              
import junit.framework.TestCase;

import org.junit.Assert;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.util.ASMUtils;



            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.util.ASMUtils'
Design

Line: 8

              import org.junit.Assert;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.util.ASMUtils;


public class Bug_for_issue_676 extends TestCase {
    public void test_for_issue() throws Exception {
        JSON.parseObject("{\"modelType\":\"\"}", MenuExpend.class);

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/JSONObjectTest2.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: 14

              
public class JSONObjectTest2 extends TestCase {

    public void test_0() throws Exception {
        Map<String, Object> map = new LinkedHashMap<String, Object>();
        JSONObject obj = new JSONObject(map);

        Assert.assertEquals(obj.size(), map.size());


            

Reported by PMD.

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

Line: 26

              
        map.put("b", new int[] { 1 });
        JSONArray array = obj.getJSONArray("b");
        Assert.assertEquals(array.size(), 1);

        map.put("c", new JSONArray());
        JSONArray array2 = obj.getJSONArray("b");
        Assert.assertEquals(array2.size(), 1);


            

Reported by PMD.

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

Line: 30

              
        map.put("c", new JSONArray());
        JSONArray array2 = obj.getJSONArray("b");
        Assert.assertEquals(array2.size(), 1);

        Assert.assertEquals(obj.getByteValue("d"), 0);
        Assert.assertEquals(obj.getShortValue("d"), 0);
        Assert.assertTrue(obj.getFloatValue("d") == 0F);
        Assert.assertTrue(obj.getDoubleValue("d") == 0D);

            

Reported by PMD.

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

Line: 41

                      Assert.assertEquals(obj.getTimestamp("d"), null);

        JSONObject obj2 = (JSONObject) obj.clone();
        Assert.assertEquals(obj.size(), obj2.size());
    }
}

            

Reported by PMD.

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

              
public class Bug_10 extends TestCase {

    public void test_0() throws Exception {
        String text = "{'jdbcUrl':\"jdbc:wrap-jdbc:filters=default:name=com.alibaba.dragoon.monitor:jdbc:mysql:\\/\\/10.20.129.167\\/dragoon_v25monitordb?useUnicode=true&characterEncoding=UTF-8\"}";

        JSON.parse(text);
    }


            

Reported by PMD.

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

Line: 9

              
public class Bug_10 extends TestCase {

    public void test_0() throws Exception {
        String text = "{'jdbcUrl':\"jdbc:wrap-jdbc:filters=default:name=com.alibaba.dragoon.monitor:jdbc:mysql:\\/\\/10.20.129.167\\/dragoon_v25monitordb?useUnicode=true&characterEncoding=UTF-8\"}";

        JSON.parse(text);
    }


            

Reported by PMD.

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

Line: 15

                      JSON.parse(text);
    }

    public void test_1() throws Exception {
        String text = "{'jdbcUrl':'jdbc:wrap-jdbc:filters=default:name=com.alibaba.dragoon.monitor:jdbc:mysql:\\/\\/10.20.129.167\\/dragoon_v25monitordb?useUnicode=true&characterEncoding=UTF-8'}";

        JSON.parse(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: 15

                      JSON.parse(text);
    }

    public void test_1() throws Exception {
        String text = "{'jdbcUrl':'jdbc:wrap-jdbc:filters=default:name=com.alibaba.dragoon.monitor:jdbc:mysql:\\/\\/10.20.129.167\\/dragoon_v25monitordb?useUnicode=true&characterEncoding=UTF-8'}";

        JSON.parse(text);
    }


            

Reported by PMD.

src/main/java/com/alibaba/fastjson/support/geo/Geometry.java
4 issues
This abstract class does not have any abstract methods
Design

Line: 18

                      , Feature.class
        , FeatureCollection.class}
    , typeKey = "type")
public abstract class Geometry {
    private final String type;
    private double[] bbox;

    protected Geometry(String type) {
        this.type = type;

            

Reported by PMD.

Returning 'bbox' may expose an internal array.
Design

Line: 31

                  }

    public double[] getBbox() {
        return bbox;
    }

    public void setBbox(double[] bbox) {
        this.bbox = bbox;
    }

            

Reported by PMD.

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

Line: 34

                      return bbox;
    }

    public void setBbox(double[] bbox) {
        this.bbox = bbox;
    }
}

            

Reported by PMD.

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

Line: 34

                      return bbox;
    }

    public void setBbox(double[] bbox) {
        this.bbox = bbox;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/CharsetFieldTest.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: 14

              
public class CharsetFieldTest extends TestCase {

    public void test_codec() throws Exception {
        User user = new User();
        user.setValue(Charset.forName("UTF-8"));

        SerializeConfig mapping = new SerializeConfig();
        mapping.setAsmEnable(false);

            

Reported by PMD.

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

Line: 24

              
        User user1 = JSON.parseObject(text, User.class);

        Assert.assertEquals(user1.getValue(), user.getValue());
    }

    public void test_codec_null() throws Exception {
        User user = new User();
        user.setValue(null);

            

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

                      Assert.assertEquals(user1.getValue(), user.getValue());
    }

    public void test_codec_null() throws Exception {
        User user = new User();
        user.setValue(null);

        SerializeConfig mapping = new SerializeConfig();
        mapping.setAsmEnable(false);

            

Reported by PMD.

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

Line: 37

              
        User user1 = JSON.parseObject(text, User.class);

        Assert.assertEquals(user1.getValue(), user.getValue());
    }

    public static class User {

        private Charset value;

            

Reported by PMD.