The following issues were found

src/test/java/com/alibaba/fastjson/deserializer/issues569/parser/ParserConfigBug569.java
36 issues
Avoid reassigning parameters such as 'type'
Design

Line: 55

                      return new DefaultFieldDeserializerBug569(mapping, clazz, fieldInfo);
    }

    public ObjectDeserializer getDeserializer(Class<?> clazz, Type type) {
        com.alibaba.fastjson.util.IdentityHashMap<Type, ObjectDeserializer> deserializers = super.getDeserializers();
        ObjectDeserializer deserializer = deserializers.get(type);
        if (deserializer != null) {
            return deserializer;
        }

            

Reported by PMD.

The class 'ParserConfigBug569' has a Standard Cyclomatic Complexity of 17 (Highest = 29).
Design

Line: 27

               * Author : BlackShadowWalker
 * Date   : 2016-10-10
 */
public class ParserConfigBug569 extends ParserConfig {

    private static boolean                                  awtError    = false;
    private static boolean                                  jdk8Error   = false;
    private String[]                                        denyList    = new String[] { "java.lang.Thread" };


            

Reported by PMD.

The class 'ParserConfigBug569' has a Modified Cyclomatic Complexity of 17 (Highest = 29).
Design

Line: 27

               * Author : BlackShadowWalker
 * Date   : 2016-10-10
 */
public class ParserConfigBug569 extends ParserConfig {

    private static boolean                                  awtError    = false;
    private static boolean                                  jdk8Error   = false;
    private String[]                                        denyList    = new String[] { "java.lang.Thread" };


            

Reported by PMD.

Avoid using redundant field initializer for 'awtError'
Performance

Line: 29

               */
public class ParserConfigBug569 extends ParserConfig {

    private static boolean                                  awtError    = false;
    private static boolean                                  jdk8Error   = false;
    private String[]                                        denyList    = new String[] { "java.lang.Thread" };

    public FieldDeserializer createFieldDeserializer(ParserConfig mapping, //
                                                     JavaBeanInfo beanInfo, //

            

Reported by PMD.

Avoid using redundant field initializer for 'jdk8Error'
Performance

Line: 30

              public class ParserConfigBug569 extends ParserConfig {

    private static boolean                                  awtError    = false;
    private static boolean                                  jdk8Error   = false;
    private String[]                                        denyList    = new String[] { "java.lang.Thread" };

    public FieldDeserializer createFieldDeserializer(ParserConfig mapping, //
                                                     JavaBeanInfo beanInfo, //
                                                     FieldInfo fieldInfo) {

            

Reported by PMD.

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

Line: 31

              
    private static boolean                                  awtError    = false;
    private static boolean                                  jdk8Error   = false;
    private String[]                                        denyList    = new String[] { "java.lang.Thread" };

    public FieldDeserializer createFieldDeserializer(ParserConfig mapping, //
                                                     JavaBeanInfo beanInfo, //
                                                     FieldInfo fieldInfo) {
        Class<?> clazz = beanInfo.clazz;

            

Reported by PMD.

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

Line: 31

              
    private static boolean                                  awtError    = false;
    private static boolean                                  jdk8Error   = false;
    private String[]                                        denyList    = new String[] { "java.lang.Thread" };

    public FieldDeserializer createFieldDeserializer(ParserConfig mapping, //
                                                     JavaBeanInfo beanInfo, //
                                                     FieldInfo fieldInfo) {
        Class<?> clazz = beanInfo.clazz;

            

Reported by PMD.

Assigning an Object to null is a code smell. Consider refactoring.
Error

Line: 44

                      if (annotation != null) {
            deserializeUsing = annotation.deserializeUsing();
            if (deserializeUsing == Void.class) {
                deserializeUsing = null;
            }
        }

        if (deserializeUsing == null && (fieldClass == List.class || fieldClass == ArrayList.class)) {
            return new ArrayListTypeFieldDeserializer(mapping, clazz, fieldInfo);

            

Reported by PMD.

Avoid using implementation types like 'ArrayList'; use the interface instead
Design

Line: 48

                          }
        }

        if (deserializeUsing == null && (fieldClass == List.class || fieldClass == ArrayList.class)) {
            return new ArrayListTypeFieldDeserializer(mapping, clazz, fieldInfo);
        }

        return new DefaultFieldDeserializerBug569(mapping, clazz, fieldInfo);
    }

            

Reported by PMD.

Avoid really long methods.
Design

Line: 55

                      return new DefaultFieldDeserializerBug569(mapping, clazz, fieldInfo);
    }

    public ObjectDeserializer getDeserializer(Class<?> clazz, Type type) {
        com.alibaba.fastjson.util.IdentityHashMap<Type, ObjectDeserializer> deserializers = super.getDeserializers();
        ObjectDeserializer deserializer = deserializers.get(type);
        if (deserializer != null) {
            return deserializer;
        }

            

Reported by PMD.

src/test/java/com/alibaba/json/test/FNV32_CollisionTest_All.java
36 issues
Avoid instantiating FileInputStream, FileOutputStream, FileReader, or FileWriter
Performance

Line: 38

                  FileOutputStream out;

    protected void setUp() throws Exception {
        out = new FileOutputStream(file);

        for (int i = 0; i < bits.length; ++i) {
            bits[i] = new BitSet(Integer.MAX_VALUE);
        }
    }

            

Reported by PMD.

System.out.println is used
Design

Line: 89

                                  long now = System.currentTimeMillis();
                    long millis = now - time;
                    time = now;
                    System.out.println("millis : " + millis + ", collision " + format.format(collisionCount) + ", " + format.format(v));
                }
            }

            System.out.println("end : " + len);
        }

            

Reported by PMD.

System.out.println is used
Design

Line: 93

                              }
            }

            System.out.println("end : " + len);
        }
    }

    String build(long v, int len) {
        char[] chars = new char[len];

            

Reported by PMD.

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

Line: 21

               */
public class FNV32_CollisionTest_All extends TestCase {

    char[] digLetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_".toCharArray();
    //char[] digLetters = "0123456789".toCharArray();
    Random r = new Random();
    int[] powers = new int[10];

    {

            

Reported by PMD.

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

Line: 24

                  char[] digLetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_".toCharArray();
    //char[] digLetters = "0123456789".toCharArray();
    Random r = new Random();
    int[] powers = new int[10];

    {
        for (int i = 0; i < powers.length; ++i) {
            powers[i] = (int) Math.pow(digLetters.length, i);
        }

            

Reported by PMD.

Non-static initializers are confusing
Error

Line: 26

                  Random r = new Random();
    int[] powers = new int[10];

    {
        for (int i = 0; i < powers.length; ++i) {
            powers[i] = (int) Math.pow(digLetters.length, i);
        }
    }


            

Reported by PMD.

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

Line: 32

                      }
    }

    private BitSet[] bits = new BitSet[16];

    private File file = new File("/Users/wenshao/Downloads/fnv/hash.bin");
    FileOutputStream out;

    protected void setUp() throws Exception {

            

Reported by PMD.

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

Line: 34

              
    private BitSet[] bits = new BitSet[16];

    private File file = new File("/Users/wenshao/Downloads/fnv/hash.bin");
    FileOutputStream out;

    protected void setUp() throws Exception {
        out = new FileOutputStream(file);


            

Reported by PMD.

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

Line: 34

              
    private BitSet[] bits = new BitSet[16];

    private File file = new File("/Users/wenshao/Downloads/fnv/hash.bin");
    FileOutputStream out;

    protected void setUp() throws Exception {
        out = new FileOutputStream(file);


            

Reported by PMD.

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

Line: 35

                  private BitSet[] bits = new BitSet[16];

    private File file = new File("/Users/wenshao/Downloads/fnv/hash.bin");
    FileOutputStream out;

    protected void setUp() throws Exception {
        out = new FileOutputStream(file);

        for (int i = 0; i < bits.length; ++i) {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/path/JSONPath_reverse_test.java
36 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 11

              
public class JSONPath_reverse_test extends TestCase
{
    public void test_reserve() throws Exception {
        JSONObject object = JSON.parseObject("{\"id\":1001,\"name\":\"ljw\",\"age\":50}");

        assertEquals("[1001,\"ljw\"]", JSONPath.reserveToArray(object, "id", "name").toString());
        assertEquals("[\"ljw\",1001]", JSONPath.reserveToArray(object, "name", "id").toString());
        String text = JSON.toJSONString(JSONPath.reserveToArray(object, "name", "*"), SerializerFeature.MapSortField);

            

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 JSONPath_reverse_test extends TestCase
{
    public void test_reserve() throws Exception {
        JSONObject object = JSON.parseObject("{\"id\":1001,\"name\":\"ljw\",\"age\":50}");

        assertEquals("[1001,\"ljw\"]", JSONPath.reserveToArray(object, "id", "name").toString());
        assertEquals("[\"ljw\",1001]", JSONPath.reserveToArray(object, "name", "id").toString());
        String text = JSON.toJSONString(JSONPath.reserveToArray(object, "name", "*"), SerializerFeature.MapSortField);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

                  public void test_reserve() throws Exception {
        JSONObject object = JSON.parseObject("{\"id\":1001,\"name\":\"ljw\",\"age\":50}");

        assertEquals("[1001,\"ljw\"]", JSONPath.reserveToArray(object, "id", "name").toString());
        assertEquals("[\"ljw\",1001]", JSONPath.reserveToArray(object, "name", "id").toString());
        String text = JSON.toJSONString(JSONPath.reserveToArray(object, "name", "*"), SerializerFeature.MapSortField);
        assertTrue(text.equals("[\"ljw\",[\"ljw\",1001,50]]")
                || text.equals("[\"ljw\",[\"ljw\",50,1001]]")
                || text.equals("[\"ljw\",[50,1001,\"ljw\"]]")

            

Reported by PMD.

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

Line: 14

                  public void test_reserve() throws Exception {
        JSONObject object = JSON.parseObject("{\"id\":1001,\"name\":\"ljw\",\"age\":50}");

        assertEquals("[1001,\"ljw\"]", JSONPath.reserveToArray(object, "id", "name").toString());
        assertEquals("[\"ljw\",1001]", JSONPath.reserveToArray(object, "name", "id").toString());
        String text = JSON.toJSONString(JSONPath.reserveToArray(object, "name", "*"), SerializerFeature.MapSortField);
        assertTrue(text.equals("[\"ljw\",[\"ljw\",1001,50]]")
                || text.equals("[\"ljw\",[\"ljw\",50,1001]]")
                || text.equals("[\"ljw\",[50,1001,\"ljw\"]]")

            

Reported by PMD.

The String literal 'name' appears 5 times in this file; the first occurrence is on line 14
Error

Line: 14

                  public void test_reserve() throws Exception {
        JSONObject object = JSON.parseObject("{\"id\":1001,\"name\":\"ljw\",\"age\":50}");

        assertEquals("[1001,\"ljw\"]", JSONPath.reserveToArray(object, "id", "name").toString());
        assertEquals("[\"ljw\",1001]", JSONPath.reserveToArray(object, "name", "id").toString());
        String text = JSON.toJSONString(JSONPath.reserveToArray(object, "name", "*"), SerializerFeature.MapSortField);
        assertTrue(text.equals("[\"ljw\",[\"ljw\",1001,50]]")
                || text.equals("[\"ljw\",[\"ljw\",50,1001]]")
                || text.equals("[\"ljw\",[50,1001,\"ljw\"]]")

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 15

                      JSONObject object = JSON.parseObject("{\"id\":1001,\"name\":\"ljw\",\"age\":50}");

        assertEquals("[1001,\"ljw\"]", JSONPath.reserveToArray(object, "id", "name").toString());
        assertEquals("[\"ljw\",1001]", JSONPath.reserveToArray(object, "name", "id").toString());
        String text = JSON.toJSONString(JSONPath.reserveToArray(object, "name", "*"), SerializerFeature.MapSortField);
        assertTrue(text.equals("[\"ljw\",[\"ljw\",1001,50]]")
                || text.equals("[\"ljw\",[\"ljw\",50,1001]]")
                || text.equals("[\"ljw\",[50,1001,\"ljw\"]]")
                || text.equals("[\"ljw\",[1001,50,\"ljw\"]]")

            

Reported by PMD.

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

Line: 15

                      JSONObject object = JSON.parseObject("{\"id\":1001,\"name\":\"ljw\",\"age\":50}");

        assertEquals("[1001,\"ljw\"]", JSONPath.reserveToArray(object, "id", "name").toString());
        assertEquals("[\"ljw\",1001]", JSONPath.reserveToArray(object, "name", "id").toString());
        String text = JSON.toJSONString(JSONPath.reserveToArray(object, "name", "*"), SerializerFeature.MapSortField);
        assertTrue(text.equals("[\"ljw\",[\"ljw\",1001,50]]")
                || text.equals("[\"ljw\",[\"ljw\",50,1001]]")
                || text.equals("[\"ljw\",[50,1001,\"ljw\"]]")
                || text.equals("[\"ljw\",[1001,50,\"ljw\"]]")

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 17

                      assertEquals("[1001,\"ljw\"]", JSONPath.reserveToArray(object, "id", "name").toString());
        assertEquals("[\"ljw\",1001]", JSONPath.reserveToArray(object, "name", "id").toString());
        String text = JSON.toJSONString(JSONPath.reserveToArray(object, "name", "*"), SerializerFeature.MapSortField);
        assertTrue(text.equals("[\"ljw\",[\"ljw\",1001,50]]")
                || text.equals("[\"ljw\",[\"ljw\",50,1001]]")
                || text.equals("[\"ljw\",[50,1001,\"ljw\"]]")
                || text.equals("[\"ljw\",[1001,50,\"ljw\"]]")
                || text.equals("[\"ljw\",[1001,\"ljw\",50]]")
                || text.equals("[\"ljw\",[50,\"ljw\",1001]]"));

            

Reported by PMD.

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

Line: 17

                      assertEquals("[1001,\"ljw\"]", JSONPath.reserveToArray(object, "id", "name").toString());
        assertEquals("[\"ljw\",1001]", JSONPath.reserveToArray(object, "name", "id").toString());
        String text = JSON.toJSONString(JSONPath.reserveToArray(object, "name", "*"), SerializerFeature.MapSortField);
        assertTrue(text.equals("[\"ljw\",[\"ljw\",1001,50]]")
                || text.equals("[\"ljw\",[\"ljw\",50,1001]]")
                || text.equals("[\"ljw\",[50,1001,\"ljw\"]]")
                || text.equals("[\"ljw\",[1001,50,\"ljw\"]]")
                || text.equals("[\"ljw\",[1001,\"ljw\",50]]")
                || text.equals("[\"ljw\",[50,\"ljw\",1001]]"));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                      assertEquals("[1001,\"ljw\"]", JSONPath.reserveToArray(object, "id", "name").toString());
        assertEquals("[\"ljw\",1001]", JSONPath.reserveToArray(object, "name", "id").toString());
        String text = JSON.toJSONString(JSONPath.reserveToArray(object, "name", "*"), SerializerFeature.MapSortField);
        assertTrue(text.equals("[\"ljw\",[\"ljw\",1001,50]]")
                || text.equals("[\"ljw\",[\"ljw\",50,1001]]")
                || text.equals("[\"ljw\",[50,1001,\"ljw\"]]")
                || text.equals("[\"ljw\",[1001,50,\"ljw\"]]")
                || text.equals("[\"ljw\",[1001,\"ljw\",50]]")
                || text.equals("[\"ljw\",[50,\"ljw\",1001]]"));

            

Reported by PMD.

src/test/java/com/alibaba/china/bolt/biz/daili/merchants/vo/MerchantsVO.java
36 issues
Avoid reassigning parameters such as 'minarea'
Design

Line: 160

              		return minarea;
	}

	public void setMinarea(Integer minarea) {
		if (null == minarea) {
			minarea = -1; //opensearch 搜索空问题 ,设置默认值
		}
		this.minarea = minarea;
	}

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 1

              package com.alibaba.china.bolt.biz.daili.merchants.vo;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.commons.lang.builder.ToStringBuilder;

import com.alibaba.fastjson.JSON;

            

Reported by PMD.

The class 'MerchantsVO' has a total cyclomatic complexity of 103 (highest 2).
Design

Line: 17

               * @author hongwei.quhw
 *
 */
public class MerchantsVO implements Serializable {
	/**
     * 
     */
    private static final long serialVersionUID = 1L;
    

            

Reported by PMD.

Too many fields
Design

Line: 17

               * @author hongwei.quhw
 *
 */
public class MerchantsVO implements Serializable {
	/**
     * 
     */
    private static final long serialVersionUID = 1L;
    

            

Reported by PMD.

Returning 'region' may expose an internal array.
Design

Line: 141

                  }

    public String[] getRegion() {
        return region;
    }

    public void setRegionArray(String[] region) {
        this.region = region;
    }

            

Reported by PMD.

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

Line: 144

                      return region;
    }

    public void setRegionArray(String[] region) {
        this.region = region;
    }

    public String[] getRegionname() {
        return regionname;

            

Reported by PMD.

Returning 'regionname' may expose an internal array.
Design

Line: 149

                  }

    public String[] getRegionname() {
        return regionname;
    }

    public void setRegionnameArray(String[] regionname) {
        this.regionname = regionname;
    }

            

Reported by PMD.

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

Line: 152

                      return regionname;
    }

    public void setRegionnameArray(String[] regionname) {
        this.regionname = regionname;
    }

    public Integer getMinarea() {
		return minarea;

            

Reported by PMD.

Returning 'shoptype' may expose an internal array.
Design

Line: 192

                  }

    public String[] getShoptype() {
        return shoptype;
    }

    public void setShoptypeArray(String[] shoptype) {
        this.shoptype = shoptype;
    }

            

Reported by PMD.

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

Line: 195

                      return shoptype;
    }

    public void setShoptypeArray(String[] shoptype) {
        this.shoptype = shoptype;
    }

    public String[] getShoptypename() {
        return shoptypename;

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/util/RyuFloat.java
35 issues
The class 'RyuFloat' has a Standard Cyclomatic Complexity of 24 (Highest = 46).
Design

Line: 20

              /**
 * An implementation of Ryu for float.
 */
public final class RyuFloat {
    private static final int[][] POW5_SPLIT = {
            {536870912, 0},
            {671088640, 0},
            {838860800, 0},
            {1048576000, 0},

            

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

              /**
 * An implementation of Ryu for float.
 */
public final class RyuFloat {
    private static final int[][] POW5_SPLIT = {
            {536870912, 0},
            {671088640, 0},
            {838860800, 0},
            {1048576000, 0},

            

Reported by PMD.

The class 'RyuFloat' has a Modified Cyclomatic Complexity of 24 (Highest = 46).
Design

Line: 20

              /**
 * An implementation of Ryu for float.
 */
public final class RyuFloat {
    private static final int[][] POW5_SPLIT = {
            {536870912, 0},
            {671088640, 0},
            {838860800, 0},
            {1048576000, 0},

            

Reported by PMD.

The method toString() has an NCSS line count of 210
Design

Line: 111

                      return new String(result, 0, len);
    }

    public static int toString(float value, char[] result, int off) {
        final int FLOAT_MANTISSA_MASK = 8388607; // (1 << 23) - 1;
        final int FLOAT_EXPONENT_MASK = 255; // (1 << 8) - 1;
        final int FLOAT_EXPONENT_BIAS = 127; // (1 << (8 - 1)) - 1;
        final long LOG10_2_NUMERATOR = 3010299; // (long) (10000000L * Math.log10(2));
        final long LOG10_5_DENOMINATOR = 10000000L;

            

Reported by PMD.

The method 'toString(float, char, int)' has an NPath complexity of 1801289728, current threshold is 200
Design

Line: 111

                      return new String(result, 0, len);
    }

    public static int toString(float value, char[] result, int off) {
        final int FLOAT_MANTISSA_MASK = 8388607; // (1 << 23) - 1;
        final int FLOAT_EXPONENT_MASK = 255; // (1 << 8) - 1;
        final int FLOAT_EXPONENT_BIAS = 127; // (1 << (8 - 1)) - 1;
        final long LOG10_2_NUMERATOR = 3010299; // (long) (10000000L * Math.log10(2));
        final long LOG10_5_DENOMINATOR = 10000000L;

            

Reported by PMD.

The method 'toString(float, char, int)' has a cyclomatic complexity of 58.
Design

Line: 111

                      return new String(result, 0, len);
    }

    public static int toString(float value, char[] result, int off) {
        final int FLOAT_MANTISSA_MASK = 8388607; // (1 << 23) - 1;
        final int FLOAT_EXPONENT_MASK = 255; // (1 << 8) - 1;
        final int FLOAT_EXPONENT_BIAS = 127; // (1 << (8 - 1)) - 1;
        final long LOG10_2_NUMERATOR = 3010299; // (long) (10000000L * Math.log10(2));
        final long LOG10_5_DENOMINATOR = 10000000L;

            

Reported by PMD.

The method 'toString(float, char, int)' has a NCSS line count of 210.
Design

Line: 111

                      return new String(result, 0, len);
    }

    public static int toString(float value, char[] result, int off) {
        final int FLOAT_MANTISSA_MASK = 8388607; // (1 << 23) - 1;
        final int FLOAT_EXPONENT_MASK = 255; // (1 << 8) - 1;
        final int FLOAT_EXPONENT_BIAS = 127; // (1 << (8 - 1)) - 1;
        final long LOG10_2_NUMERATOR = 3010299; // (long) (10000000L * Math.log10(2));
        final long LOG10_5_DENOMINATOR = 10000000L;

            

Reported by PMD.

The method 'toString' has a Standard Cyclomatic Complexity of 46.
Design

Line: 111

                      return new String(result, 0, len);
    }

    public static int toString(float value, char[] result, int off) {
        final int FLOAT_MANTISSA_MASK = 8388607; // (1 << 23) - 1;
        final int FLOAT_EXPONENT_MASK = 255; // (1 << 8) - 1;
        final int FLOAT_EXPONENT_BIAS = 127; // (1 << (8 - 1)) - 1;
        final long LOG10_2_NUMERATOR = 3010299; // (long) (10000000L * Math.log10(2));
        final long LOG10_5_DENOMINATOR = 10000000L;

            

Reported by PMD.

The method 'toString' has a Modified Cyclomatic Complexity of 46.
Design

Line: 111

                      return new String(result, 0, len);
    }

    public static int toString(float value, char[] result, int off) {
        final int FLOAT_MANTISSA_MASK = 8388607; // (1 << 23) - 1;
        final int FLOAT_EXPONENT_MASK = 255; // (1 << 8) - 1;
        final int FLOAT_EXPONENT_BIAS = 127; // (1 << (8 - 1)) - 1;
        final long LOG10_2_NUMERATOR = 3010299; // (long) (10000000L * Math.log10(2));
        final long LOG10_5_DENOMINATOR = 10000000L;

            

Reported by PMD.

Avoid really long methods.
Design

Line: 111

                      return new String(result, 0, len);
    }

    public static int toString(float value, char[] result, int off) {
        final int FLOAT_MANTISSA_MASK = 8388607; // (1 << 23) - 1;
        final int FLOAT_EXPONENT_MASK = 255; // (1 << 8) - 1;
        final int FLOAT_EXPONENT_BIAS = 127; // (1 << (8 - 1)) - 1;
        final long LOG10_2_NUMERATOR = 3010299; // (long) (10000000L * Math.log10(2));
        final long LOG10_5_DENOMINATOR = 10000000L;

            

Reported by PMD.

src/test/java/com/alibaba/fastjson/support/jaxrs/TestIssue885.java
35 issues
The String literal 'user' appears 4 times in this file; the first occurrence is on line 19
Error

Line: 19

              
public class TestIssue885 extends JerseyTest {

    @Path("user")
    public static class UserResource {
        @GET
        public User getUser() {
            User user = new User();
            user.setId(12345L);

            

Reported by PMD.

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

Line: 49

                  }

    @Test
    public void testWriteTo() {
        final String user = target("user").request().accept("application/json").get(String.class);
        // {"createdOn":1412036891919,"id":12345,"name":"smallnest"}]
        assertTrue(user.indexOf("createdOn") > 0);
        assertTrue(user.indexOf("\"id\":12345") > 0);
        assertTrue(user.indexOf("\"name\":\"smallnest\"") > 0);

            

Reported by PMD.

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

Line: 50

              
    @Test
    public void testWriteTo() {
        final String user = target("user").request().accept("application/json").get(String.class);
        // {"createdOn":1412036891919,"id":12345,"name":"smallnest"}]
        assertTrue(user.indexOf("createdOn") > 0);
        assertTrue(user.indexOf("\"id\":12345") > 0);
        assertTrue(user.indexOf("\"name\":\"smallnest\"") > 0);
    }

            

Reported by PMD.

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

Line: 50

              
    @Test
    public void testWriteTo() {
        final String user = target("user").request().accept("application/json").get(String.class);
        // {"createdOn":1412036891919,"id":12345,"name":"smallnest"}]
        assertTrue(user.indexOf("createdOn") > 0);
        assertTrue(user.indexOf("\"id\":12345") > 0);
        assertTrue(user.indexOf("\"name\":\"smallnest\"") > 0);
    }

            

Reported by PMD.

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

Line: 50

              
    @Test
    public void testWriteTo() {
        final String user = target("user").request().accept("application/json").get(String.class);
        // {"createdOn":1412036891919,"id":12345,"name":"smallnest"}]
        assertTrue(user.indexOf("createdOn") > 0);
        assertTrue(user.indexOf("\"id\":12345") > 0);
        assertTrue(user.indexOf("\"name\":\"smallnest\"") > 0);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 52

                  public void testWriteTo() {
        final String user = target("user").request().accept("application/json").get(String.class);
        // {"createdOn":1412036891919,"id":12345,"name":"smallnest"}]
        assertTrue(user.indexOf("createdOn") > 0);
        assertTrue(user.indexOf("\"id\":12345") > 0);
        assertTrue(user.indexOf("\"name\":\"smallnest\"") > 0);
    }

    @Test

            

Reported by PMD.

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

Line: 52

                  public void testWriteTo() {
        final String user = target("user").request().accept("application/json").get(String.class);
        // {"createdOn":1412036891919,"id":12345,"name":"smallnest"}]
        assertTrue(user.indexOf("createdOn") > 0);
        assertTrue(user.indexOf("\"id\":12345") > 0);
        assertTrue(user.indexOf("\"name\":\"smallnest\"") > 0);
    }

    @Test

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 53

                      final String user = target("user").request().accept("application/json").get(String.class);
        // {"createdOn":1412036891919,"id":12345,"name":"smallnest"}]
        assertTrue(user.indexOf("createdOn") > 0);
        assertTrue(user.indexOf("\"id\":12345") > 0);
        assertTrue(user.indexOf("\"name\":\"smallnest\"") > 0);
    }

    @Test
    public void testWriteToWithPretty() {

            

Reported by PMD.

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

Line: 53

                      final String user = target("user").request().accept("application/json").get(String.class);
        // {"createdOn":1412036891919,"id":12345,"name":"smallnest"}]
        assertTrue(user.indexOf("createdOn") > 0);
        assertTrue(user.indexOf("\"id\":12345") > 0);
        assertTrue(user.indexOf("\"name\":\"smallnest\"") > 0);
    }

    @Test
    public void testWriteToWithPretty() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 54

                      // {"createdOn":1412036891919,"id":12345,"name":"smallnest"}]
        assertTrue(user.indexOf("createdOn") > 0);
        assertTrue(user.indexOf("\"id\":12345") > 0);
        assertTrue(user.indexOf("\"name\":\"smallnest\"") > 0);
    }

    @Test
    public void testWriteToWithPretty() {
        //System.out.println("@@@@@Test Pretty");

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/JSONScannerTest_false.java
35 issues
This class has too many methods, consider refactoring it.
Design

Line: 9

              import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.parser.JSONScanner;

public class JSONScannerTest_false extends TestCase {

    public void test_scan_false_0() throws Exception {
        JSONScanner lexer = new JSONScanner("false");
        lexer.scanFalse();
    }

            

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

    public void test_scan_false_0() throws Exception {
        JSONScanner lexer = new JSONScanner("false");
        lexer.scanFalse();
    }

    public void test_scan_false_1() throws Exception {

            

Reported by PMD.

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

Line: 11

              
public class JSONScannerTest_false extends TestCase {

    public void test_scan_false_0() throws Exception {
        JSONScanner lexer = new JSONScanner("false");
        lexer.scanFalse();
    }

    public void test_scan_false_1() throws Exception {

            

Reported by PMD.

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

Line: 16

                      lexer.scanFalse();
    }

    public void test_scan_false_1() throws Exception {
        JSONException error = null;
        try {
            JSONScanner lexer = new JSONScanner("zalse");
            lexer.scanFalse();
        } catch (JSONException e) {

            

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.assertNotNull(error);
    }

    public void test_scan_false_2() throws Exception {
        JSONException error = null;
        try {
            JSONScanner lexer = new JSONScanner("fzlse");
            lexer.scanFalse();
        } catch (JSONException e) {

            

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.assertNotNull(error);
    }

    public void test_scan_false_3() throws Exception {
        JSONException error = null;
        try {
            JSONScanner lexer = new JSONScanner("fazse");
            lexer.scanFalse();
        } catch (JSONException e) {

            

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

                      Assert.assertNotNull(error);
    }

    public void test_scan_false_4() throws Exception {
        JSONException error = null;
        try {
            JSONScanner lexer = new JSONScanner("falze");
            lexer.scanFalse();
        } catch (JSONException e) {

            

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

                      Assert.assertNotNull(error);
    }

    public void test_scan_false_5() throws Exception {
        JSONException error = null;
        try {
            JSONScanner lexer = new JSONScanner("falsz");
            lexer.scanFalse();
        } catch (JSONException e) {

            

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

                      Assert.assertNotNull(error);
    }

    public void test_scan_false_6_1() throws Exception {
        JSONException error = null;
        try {
            JSONScanner lexer = new JSONScanner("falsee");
            lexer.scanFalse();
        } catch (JSONException e) {

            

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

                      Assert.assertNotNull(error);
    }

    public void test_scan_false_6() throws Exception {
        JSONException error = null;
        try {
            JSONScanner lexer = new JSONScanner("false\"");
            lexer.scanFalse();
        } catch (JSONException e) {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/validate/JSONValidatorTest.java
35 issues
This class has too many methods, consider refactoring it.
Design

Line: 13

              
import static org.junit.Assert.*;

public class JSONValidatorTest {

    @Test
    public void validate_test_accurate() throws Throwable {
        boolean isValidate = JSONValidator.from("{\"string\":\"a\",\"nums\":[0,-1,10,0.123,1e5,-1e+6,0.1e-7],\"object\":{\"empty\":{},\"list\":[]},\"list\":[\"object\",{\"true\":true,\"false\":false,\"null\":null}]}").validate();
        assertTrue(isValidate);

            

Reported by PMD.

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

Line: 17

              
    @Test
    public void validate_test_accurate() throws Throwable {
        boolean isValidate = JSONValidator.from("{\"string\":\"a\",\"nums\":[0,-1,10,0.123,1e5,-1e+6,0.1e-7],\"object\":{\"empty\":{},\"list\":[]},\"list\":[\"object\",{\"true\":true,\"false\":false,\"null\":null}]}").validate();
        assertTrue(isValidate);
    }

    @Test
    public void validate_test_quotation() throws Throwable {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                  @Test
    public void validate_test_accurate() throws Throwable {
        boolean isValidate = JSONValidator.from("{\"string\":\"a\",\"nums\":[0,-1,10,0.123,1e5,-1e+6,0.1e-7],\"object\":{\"empty\":{},\"list\":[]},\"list\":[\"object\",{\"true\":true,\"false\":false,\"null\":null}]}").validate();
        assertTrue(isValidate);
    }

    @Test
    public void validate_test_quotation() throws Throwable {
        boolean isValidate = JSONValidator.from("{noQuotationMarksError}").validate();

            

Reported by PMD.

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

Line: 23

              
    @Test
    public void validate_test_quotation() throws Throwable {
        boolean isValidate = JSONValidator.from("{noQuotationMarksError}").validate();
        assertFalse(isValidate);
    }

    @Test
    public void validate_test_colon() throws Throwable {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 24

                  @Test
    public void validate_test_quotation() throws Throwable {
        boolean isValidate = JSONValidator.from("{noQuotationMarksError}").validate();
        assertFalse(isValidate);
    }

    @Test
    public void validate_test_colon() throws Throwable {
        boolean isValidate = JSONValidator.from("{\"colonError\"}").validate();

            

Reported by PMD.

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

Line: 29

              
    @Test
    public void validate_test_colon() throws Throwable {
        boolean isValidate = JSONValidator.from("{\"colonError\"}").validate();
        assertFalse(isValidate);

    }

    @Test

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

                  @Test
    public void validate_test_colon() throws Throwable {
        boolean isValidate = JSONValidator.from("{\"colonError\"}").validate();
        assertFalse(isValidate);

    }

    @Test
    public void validate_test_bracket() throws Throwable {

            

Reported by PMD.

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

Line: 36

              
    @Test
    public void validate_test_bracket() throws Throwable {
        boolean isValidate = JSONValidator.from("[1}").validate();
        assertFalse(isValidate);
    }

    @Test
    public void validate_test_num1() throws Throwable {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 37

                  @Test
    public void validate_test_bracket() throws Throwable {
        boolean isValidate = JSONValidator.from("[1}").validate();
        assertFalse(isValidate);
    }

    @Test
    public void validate_test_num1() throws Throwable {
        boolean isValidate = JSONValidator.from("-a").validate();

            

Reported by PMD.

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

Line: 42

              
    @Test
    public void validate_test_num1() throws Throwable {
        boolean isValidate = JSONValidator.from("-a").validate();
        assertFalse(isValidate);
    }

    @Test
    public void validate_test_num2() throws Throwable {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/JSONScannerTest_scanFieldFloat.java
34 issues
This class has too many methods, consider refactoring it.
Design

Line: 10

              import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.parser.JSONScanner;

public class JSONScannerTest_scanFieldFloat extends TestCase {

    public void test_0() throws Exception {
        String text = "{\"value\":1.0}";
        VO obj = JSON.parseObject(text, VO.class);
        Assert.assertTrue(1F == obj.getValue());

            

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

    public void test_0() throws Exception {
        String text = "{\"value\":1.0}";
        VO obj = JSON.parseObject(text, VO.class);
        Assert.assertTrue(1F == obj.getValue());
    }


            

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\":1.0}";
        VO obj = JSON.parseObject(text, VO.class);
        Assert.assertTrue(1F == obj.getValue());
    }

    @SuppressWarnings("resource")
    public void test_isBlank() throws Exception {
        String text = "   {\"value\":1.0}";

            

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

                      Assert.assertTrue(1F == obj.getValue());
    }

    @SuppressWarnings("resource")
    public void test_isBlank() throws Exception {
        String text = "   {\"value\":1.0}";
        Assert.assertTrue(!new JSONScanner(text).isBlankInput());
    }


            

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

                      Assert.assertTrue(!new JSONScanner(text).isBlankInput());
    }

    public void test_1() throws Exception {
        String text = "{\"value\":\"1\"}";
        VO obj = JSON.parseObject(text, VO.class);
        Assert.assertTrue(1F == obj.getValue());
    }


            

Reported by PMD.

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

Line: 27

                  public void test_1() throws Exception {
        String text = "{\"value\":\"1\"}";
        VO obj = JSON.parseObject(text, VO.class);
        Assert.assertTrue(1F == obj.getValue());
    }

    public void test_2() throws Exception {
        String text = "{\"f1\":2,\"value\":1.0}";
        VO obj = JSON.parseObject(text, VO.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.assertTrue(1F == obj.getValue());
    }

    public void test_2() throws Exception {
        String text = "{\"f1\":2,\"value\":1.0}";
        VO obj = JSON.parseObject(text, VO.class);
        Assert.assertTrue(1F == obj.getValue());
    }


            

Reported by PMD.

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

Line: 33

                  public void test_2() throws Exception {
        String text = "{\"f1\":2,\"value\":1.0}";
        VO obj = JSON.parseObject(text, VO.class);
        Assert.assertTrue(1F == obj.getValue());
    }

    public void test_3() throws Exception {
        String text = "{\"value\":1.01}";
        VO obj = JSON.parseObject(text, VO.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: 36

                      Assert.assertTrue(1F == obj.getValue());
    }

    public void test_3() throws Exception {
        String text = "{\"value\":1.01}";
        VO obj = JSON.parseObject(text, VO.class);
        Assert.assertTrue(1.01F == obj.getValue());
    }


            

Reported by PMD.

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

Line: 39

                  public void test_3() throws Exception {
        String text = "{\"value\":1.01}";
        VO obj = JSON.parseObject(text, VO.class);
        Assert.assertTrue(1.01F == obj.getValue());
    }

    public void test_4() throws Exception {
        String text = "{\"value\":1.}";
        VO obj = JSON.parseObject(text, VO.class);

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/path/JSONPath_field_access_filter_compare_string.java
34 issues
System.out.println is used
Design

Line: 137

              
        JSONArray array = JSON.parseArray("[{\"id\":\"1\",\"name\":\"a\"},{\"id\":\"2\",\"name\":\"b\"}]");
        Object result = path.eval(array);
        System.out.println(result);
    }

    public static class Entity {

        private Integer id;

            

Reported by PMD.

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

Line: 16

              
public class JSONPath_field_access_filter_compare_string extends TestCase {

    public void test_list_eq() throws Exception {
        JSONPath path = new JSONPath("$[?(@.name = 'ljw2083')]");

        List<Entity> entities = new ArrayList<Entity>();
        entities.add(new Entity(1001, "ljw2083"));
        entities.add(new Entity(1002, "wenshao"));

            

Reported by PMD.

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

Line: 20

                      JSONPath path = new JSONPath("$[?(@.name = 'ljw2083')]");

        List<Entity> entities = new ArrayList<Entity>();
        entities.add(new Entity(1001, "ljw2083"));
        entities.add(new Entity(1002, "wenshao"));
        entities.add(new Entity(1003, null));
        entities.add(new Entity(null, null));

        List<Object> result = (List<Object>) path.eval(entities);

            

Reported by PMD.

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

Line: 21

              
        List<Entity> entities = new ArrayList<Entity>();
        entities.add(new Entity(1001, "ljw2083"));
        entities.add(new Entity(1002, "wenshao"));
        entities.add(new Entity(1003, null));
        entities.add(new Entity(null, null));

        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(1, result.size());

            

Reported by PMD.

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

Line: 26

                      entities.add(new Entity(null, null));

        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(1, result.size());
        Assert.assertSame(entities.get(0), result.get(0));
    }
    
    public void test_list_eq_x() throws Exception {
        JSONPath path = new JSONPath("$[?(name = 'ljw2083')]");

            

Reported by PMD.

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

Line: 27

              
        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(1, result.size());
        Assert.assertSame(entities.get(0), result.get(0));
    }
    
    public void test_list_eq_x() throws Exception {
        JSONPath path = new JSONPath("$[?(name = 'ljw2083')]");
        

            

Reported by PMD.

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

Line: 30

                      Assert.assertSame(entities.get(0), result.get(0));
    }
    
    public void test_list_eq_x() throws Exception {
        JSONPath path = new JSONPath("$[?(name = 'ljw2083')]");
        
        List<Entity> entities = new ArrayList<Entity>();
        entities.add(new Entity(1001, "ljw2083"));
        entities.add(new Entity(1002, "wenshao"));

            

Reported by PMD.

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

Line: 40

                      entities.add(new Entity(null, null));
        
        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(1, result.size());
        Assert.assertSame(entities.get(0), result.get(0));
    }
    
    public void test_list_eq_null() throws Exception {
        JSONPath path = new JSONPath("$[?(@.name = null)]");

            

Reported by PMD.

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

Line: 41

                      
        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(1, result.size());
        Assert.assertSame(entities.get(0), result.get(0));
    }
    
    public void test_list_eq_null() throws Exception {
        JSONPath path = new JSONPath("$[?(@.name = 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: 44

                      Assert.assertSame(entities.get(0), result.get(0));
    }
    
    public void test_list_eq_null() throws Exception {
        JSONPath path = new JSONPath("$[?(@.name = null)]");

        List<Entity> entities = new ArrayList<Entity>();
        entities.add(new Entity(1001, "ljw2083"));
        entities.add(new Entity(1002, "wenshao"));

            

Reported by PMD.