The following issues were found

src/main/java/com/alibaba/fastjson/serializer/SerializeWriter.java
225 issues
Avoid reassigning parameters such as 'len'
Design

Line: 266

                   * @param off the start offset in the data
     * @param len the number of chars that are written
     */
    public void write(char c[], int off, int len) {
        if (off < 0 //
            || off > c.length //
            || len < 0 //
            || off + len > c.length //
            || off + len < 0) {

            

Reported by PMD.

Avoid reassigning parameters such as 'off'
Design

Line: 266

                   * @param off the start offset in the data
     * @param len the number of chars that are written
     */
    public void write(char c[], int off, int len) {
        if (off < 0 //
            || off > c.length //
            || len < 0 //
            || off + len > c.length //
            || off + len < 0) {

            

Reported by PMD.

Avoid reassigning parameters such as 'len'
Design

Line: 345

                   * @param off Offset from which to start reading characters
     * @param len Number of characters to be written
     */
    public void write(String str, int off, int len) {
        int newcount = count + len;
        if (newcount > buf.length) {
            if (writer == null) {
                expandCapacity(newcount);
            } else {

            

Reported by PMD.

Avoid reassigning parameters such as 'off'
Design

Line: 345

                   * @param off Offset from which to start reading characters
     * @param len Number of characters to be written
     */
    public void write(String str, int off, int len) {
        int newcount = count + len;
        if (newcount > buf.length) {
            if (writer == null) {
                expandCapacity(newcount);
            } else {

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 16

               * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.alibaba.fastjson.serializer;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.util.IOUtils;
import com.alibaba.fastjson.util.RyuDouble;

            

Reported by PMD.

Too many fields
Design

Line: 36

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public final class SerializeWriter extends Writer {
    private final static ThreadLocal<char[]> bufLocal         = new ThreadLocal<char[]>();
    private final static ThreadLocal<byte[]> bytesBufLocal    = new ThreadLocal<byte[]>();
    private static final char[] VALUE_TRUE = ":true".toCharArray();
    private static final char[] VALUE_FALSE = ":false".toCharArray();
    private static       int                 BUFFER_THRESHOLD = 1024 * 128;

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 36

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public final class SerializeWriter extends Writer {
    private final static ThreadLocal<char[]> bufLocal         = new ThreadLocal<char[]>();
    private final static ThreadLocal<byte[]> bytesBufLocal    = new ThreadLocal<byte[]>();
    private static final char[] VALUE_TRUE = ":true".toCharArray();
    private static final char[] VALUE_FALSE = ":false".toCharArray();
    private static       int                 BUFFER_THRESHOLD = 1024 * 128;

            

Reported by PMD.

The type has an NCSS line count of 1603
Design

Line: 36

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public final class SerializeWriter extends Writer {
    private final static ThreadLocal<char[]> bufLocal         = new ThreadLocal<char[]>();
    private final static ThreadLocal<byte[]> bytesBufLocal    = new ThreadLocal<byte[]>();
    private static final char[] VALUE_TRUE = ":true".toCharArray();
    private static final char[] VALUE_FALSE = ":false".toCharArray();
    private static       int                 BUFFER_THRESHOLD = 1024 * 128;

            

Reported by PMD.

The class 'SerializeWriter' has a total cyclomatic complexity of 561 (highest 95).
Design

Line: 36

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public final class SerializeWriter extends Writer {
    private final static ThreadLocal<char[]> bufLocal         = new ThreadLocal<char[]>();
    private final static ThreadLocal<byte[]> bytesBufLocal    = new ThreadLocal<byte[]>();
    private static final char[] VALUE_TRUE = ":true".toCharArray();
    private static final char[] VALUE_FALSE = ":false".toCharArray();
    private static       int                 BUFFER_THRESHOLD = 1024 * 128;

            

Reported by PMD.

The class 'SerializeWriter' has a Standard Cyclomatic Complexity of 5 (Highest = 50).
Design

Line: 36

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public final class SerializeWriter extends Writer {
    private final static ThreadLocal<char[]> bufLocal         = new ThreadLocal<char[]>();
    private final static ThreadLocal<byte[]> bytesBufLocal    = new ThreadLocal<byte[]>();
    private static final char[] VALUE_TRUE = ":true".toCharArray();
    private static final char[] VALUE_FALSE = ":false".toCharArray();
    private static       int                 BUFFER_THRESHOLD = 1024 * 128;

            

Reported by PMD.

src/test/java/com/alibaba/fastjson/parser/JSONScannerTest.java
213 issues
No need to import a type that lives in the same package
Error

Line: 20

              
package com.alibaba.fastjson.parser;

import com.alibaba.fastjson.parser.JSONScanner;
import com.diffblue.deeptestutils.Reflector;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

            

Reported by PMD.

Avoid really long classes.
Design

Line: 34

              import java.util.Locale;


public class JSONScannerTest {

  @Rule
  public ExpectedException thrown = ExpectedException.none();

  /* testedClasses: JSONScanner */

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 34

              import java.util.Locale;


public class JSONScannerTest {

  @Rule
  public ExpectedException thrown = ExpectedException.none();

  /* testedClasses: JSONScanner */

            

Reported by PMD.

The String literal 'com.alibaba.fastjson.parser.JSONScanner' appears 58 times in this file; the first occurrence is on line 57
Error

Line: 57

                  char[] dest = { '\u0000' };

    // Act
    Class<?> c = Reflector.forName("com.alibaba.fastjson.parser.JSONScanner");
    Method m = c.getDeclaredMethod("charArrayCompare", Reflector.forName("java.lang.String"), Reflector.forName("int"), Reflector.forName("char []"));
    m.setAccessible(true);
    boolean retval = (Boolean)m.invoke(null, src, offset, dest);

    // Assert result

            

Reported by PMD.

The String literal 'int' appears 37 times in this file; the first occurrence is on line 58
Error

Line: 58

              
    // Act
    Class<?> c = Reflector.forName("com.alibaba.fastjson.parser.JSONScanner");
    Method m = c.getDeclaredMethod("charArrayCompare", Reflector.forName("java.lang.String"), Reflector.forName("int"), Reflector.forName("char []"));
    m.setAccessible(true);
    boolean retval = (Boolean)m.invoke(null, src, offset, dest);

    // Assert result
    Assert.assertEquals(false, retval);

            

Reported by PMD.

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

Line: 58

              
    // Act
    Class<?> c = Reflector.forName("com.alibaba.fastjson.parser.JSONScanner");
    Method m = c.getDeclaredMethod("charArrayCompare", Reflector.forName("java.lang.String"), Reflector.forName("int"), Reflector.forName("char []"));
    m.setAccessible(true);
    boolean retval = (Boolean)m.invoke(null, src, offset, dest);

    // Assert result
    Assert.assertEquals(false, retval);

            

Reported by PMD.

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

Line: 59

                  // Act
    Class<?> c = Reflector.forName("com.alibaba.fastjson.parser.JSONScanner");
    Method m = c.getDeclaredMethod("charArrayCompare", Reflector.forName("java.lang.String"), Reflector.forName("int"), Reflector.forName("char []"));
    m.setAccessible(true);
    boolean retval = (Boolean)m.invoke(null, src, offset, dest);

    // Assert result
    Assert.assertEquals(false, retval);


            

Reported by PMD.

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

Line: 60

                  Class<?> c = Reflector.forName("com.alibaba.fastjson.parser.JSONScanner");
    Method m = c.getDeclaredMethod("charArrayCompare", Reflector.forName("java.lang.String"), Reflector.forName("int"), Reflector.forName("char []"));
    m.setAccessible(true);
    boolean retval = (Boolean)m.invoke(null, src, offset, dest);

    // Assert result
    Assert.assertEquals(false, retval);

  }

            

Reported by PMD.

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

Line: 99

              
    // Act
    Class<?> c = Reflector.forName("com.alibaba.fastjson.parser.JSONScanner");
    Method m = c.getDeclaredMethod("charArrayCompare", Reflector.forName("java.lang.String"), Reflector.forName("int"), Reflector.forName("char []"));
    m.setAccessible(true);
    boolean retval = (Boolean)m.invoke(null, src, offset, dest);

    // Assert result
    Assert.assertEquals(false, retval);

            

Reported by PMD.

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

Line: 100

                  // Act
    Class<?> c = Reflector.forName("com.alibaba.fastjson.parser.JSONScanner");
    Method m = c.getDeclaredMethod("charArrayCompare", Reflector.forName("java.lang.String"), Reflector.forName("int"), Reflector.forName("char []"));
    m.setAccessible(true);
    boolean retval = (Boolean)m.invoke(null, src, offset, dest);

    // Assert result
    Assert.assertEquals(false, retval);


            

Reported by PMD.

src/test/java/com/alibaba/json/test/Base64.java
199 issues
The class 'Base64' has a Modified Cyclomatic Complexity of 11 (Highest = 13).
Design

Line: 73

               *         Time: 11:31:11
 */

public class Base64
{
	private static final char[] CA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray();
	private static final int[] IA = new int[256];
	static {
		Arrays.fill(IA, -1);

            

Reported by PMD.

The class 'Base64' has a Standard Cyclomatic Complexity of 11 (Highest = 13).
Design

Line: 73

               *         Time: 11:31:11
 */

public class Base64
{
	private static final char[] CA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray();
	private static final int[] IA = new int[256];
	static {
		Arrays.fill(IA, -1);

            

Reported by PMD.

The class 'Base64' has a total cyclomatic complexity of 111 (highest 16).
Design

Line: 73

               *         Time: 11:31:11
 */

public class Base64
{
	private static final char[] CA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray();
	private static final int[] IA = new int[256];
	static {
		Arrays.fill(IA, -1);

            

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

               */

public class Base64
{
	private static final char[] CA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray();
	private static final int[] IA = new int[256];
	static {
		Arrays.fill(IA, -1);
		for (int i = 0, iS = CA.length; i < iS; i++)

            

Reported by PMD.

Too many control variables in the for statement
Design

Line: 79

              	private static final int[] IA = new int[256];
	static {
		Arrays.fill(IA, -1);
		for (int i = 0, iS = CA.length; i < iS; i++)
			IA[CA[i]] = i;
		IA['='] = 0;
	}

	// ****************************************************************************************

            

Reported by PMD.

The method 'encodeToChar(byte, boolean)' has an NPath complexity of 200, current threshold is 200
Design

Line: 95

              	 * little faster.
	 * @return A BASE64 encoded array. Never <code>null</code>.
	 */
	public final static char[] encodeToChar(byte[] bytes, boolean lineSep)
	{
		// Check special case
		int bytes_len = bytes != null ? bytes.length : 0;
		if (bytes_len == 0)
			return new char[0];

            

Reported by PMD.

The method 'encodeToChar(byte, boolean)' has a cyclomatic complexity of 11.
Design

Line: 95

              	 * little faster.
	 * @return A BASE64 encoded array. Never <code>null</code>.
	 */
	public final static char[] encodeToChar(byte[] bytes, boolean lineSep)
	{
		// Check special case
		int bytes_len = bytes != null ? bytes.length : 0;
		if (bytes_len == 0)
			return new char[0];

            

Reported by PMD.

Too many control variables in the for statement
Design

Line: 108

              		char[] chars = new char[chars_len];

		// Encode even 24-bits
		for (int s = 0, d = 0, cc = 0; s < eLen;) {
			// Copy next three bytes into lower 24 bits of int, paying attension to sign.
			int i = (bytes[s++] & 0xff) << 16 | (bytes[s++] & 0xff) << 8 | (bytes[s++] & 0xff);

			// Encode the int into four chars
			chars[d++] = CA[(i >>> 18) & 0x3f];

            

Reported by PMD.

Avoid reassigning the loop control variable 's'
Design

Line: 110

              		// Encode even 24-bits
		for (int s = 0, d = 0, cc = 0; s < eLen;) {
			// Copy next three bytes into lower 24 bits of int, paying attension to sign.
			int i = (bytes[s++] & 0xff) << 16 | (bytes[s++] & 0xff) << 8 | (bytes[s++] & 0xff);

			// Encode the int into four chars
			chars[d++] = CA[(i >>> 18) & 0x3f];
			chars[d++] = CA[(i >>> 12) & 0x3f];
			chars[d++] = CA[(i >>> 6) & 0x3f];

            

Reported by PMD.

Avoid reassigning the loop control variable 's'
Design

Line: 110

              		// Encode even 24-bits
		for (int s = 0, d = 0, cc = 0; s < eLen;) {
			// Copy next three bytes into lower 24 bits of int, paying attension to sign.
			int i = (bytes[s++] & 0xff) << 16 | (bytes[s++] & 0xff) << 8 | (bytes[s++] & 0xff);

			// Encode the int into four chars
			chars[d++] = CA[(i >>> 18) & 0x3f];
			chars[d++] = CA[(i >>> 12) & 0x3f];
			chars[d++] = CA[(i >>> 6) & 0x3f];

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/parser/ParserConfig.java
184 issues
Overridable constructor called during object construction
Error

Line: 361

                  }

    public ParserConfig(boolean fieldBase){
        this(null, null, fieldBase);
    }

    public ParserConfig(ClassLoader parentClassLoader){
        this(null, parentClassLoader, false);
    }

            

Reported by PMD.

Overridable constructor called during object construction
Error

Line: 365

                  }

    public ParserConfig(ClassLoader parentClassLoader){
        this(null, parentClassLoader, false);
    }

    public ParserConfig(ASMDeserializerFactory asmFactory){
        this(asmFactory, null, false);
    }

            

Reported by PMD.

Overridable constructor called during object construction
Error

Line: 369

                  }

    public ParserConfig(ASMDeserializerFactory asmFactory){
        this(asmFactory, null, false);
    }

    private ParserConfig(ASMDeserializerFactory asmFactory, ClassLoader parentClassLoader, boolean fieldBased){
        this.fieldBased = fieldBased;
        if (asmFactory == null && !ASMUtils.IS_ANDROID) {

            

Reported by PMD.

Return an empty array rather than null.
Error

Line: 487

                      deserializers.put(JSONPObject.class, new JSONPDeserializer());
    }

    private static String[] splitItemsFormProperty(final String property ){
        if (property != null && property.length() > 0) {
            return property.split(",");
        }
        return null;
    }

            

Reported by PMD.

Avoid reassigning parameters such as 'asmFactory'
Design

Line: 372

                      this(asmFactory, null, false);
    }

    private ParserConfig(ASMDeserializerFactory asmFactory, ClassLoader parentClassLoader, boolean fieldBased){
        this.fieldBased = fieldBased;
        if (asmFactory == null && !ASMUtils.IS_ANDROID) {
            try {
                if (parentClassLoader == null) {
                    asmFactory = new ASMDeserializerFactory(new ASMClassLoader());

            

Reported by PMD.

Avoid reassigning parameters such as 'asmFactory'
Design

Line: 372

                      this(asmFactory, null, false);
    }

    private ParserConfig(ASMDeserializerFactory asmFactory, ClassLoader parentClassLoader, boolean fieldBased){
        this.fieldBased = fieldBased;
        if (asmFactory == null && !ASMUtils.IS_ANDROID) {
            try {
                if (parentClassLoader == null) {
                    asmFactory = new ASMDeserializerFactory(new ASMClassLoader());

            

Reported by PMD.

Avoid reassigning parameters such as 'type'
Design

Line: 620

                      return JavaObjectDeserializer.instance;
    }

    public ObjectDeserializer getDeserializer(Class<?> clazz, Type type) {
        ObjectDeserializer deserializer = get(type);
        if (deserializer == null && type instanceof ParameterizedTypeImpl) {
            Type innerType = TypeReference.intern((ParameterizedTypeImpl) type);
            deserializer = get(innerType);
        }

            

Reported by PMD.

High amount of different objects as members denotes a high coupling
Design

Line: 16

               * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.alibaba.fastjson.parser;

import java.io.*;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.lang.reflect.*;

            

Reported by PMD.

A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 16

               * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.alibaba.fastjson.parser;

import java.io.*;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.lang.reflect.*;

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 67

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public class ParserConfig {

    public static final String    DENY_PROPERTY_INTERNAL    = "fastjson.parser.deny.internal";
    public static final String    DENY_PROPERTY             = "fastjson.parser.deny";
    public static final String    AUTOTYPE_ACCEPT           = "fastjson.parser.autoTypeAccept";
    public static final String    AUTOTYPE_SUPPORT_PROPERTY = "fastjson.parser.autoTypeSupport";

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/parser/deserializer/ASMDeserializerFactory.java
182 issues
High amount of different objects as members denotes a high coupling
Design

Line: 1

              package com.alibaba.fastjson.parser.deserializer;

import static com.alibaba.fastjson.util.ASMUtils.desc;
import static com.alibaba.fastjson.util.ASMUtils.type;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;

            

Reported by PMD.

A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 1

              package com.alibaba.fastjson.parser.deserializer;

import static com.alibaba.fastjson.util.ASMUtils.desc;
import static com.alibaba.fastjson.util.ASMUtils.type;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;

            

Reported by PMD.

Possible God Class (WMC=157, ATFD=364, TCC=28.854%)
Design

Line: 42

              import com.alibaba.fastjson.parser.SymbolTable;
import com.alibaba.fastjson.util.*;

public class ASMDeserializerFactory implements Opcodes {

    public final ASMClassLoader classLoader;
    protected final AtomicLong  seed              = new AtomicLong();

    final static String         DefaultJSONParser = type(DefaultJSONParser.class);

            

Reported by PMD.

The class 'ASMDeserializerFactory' has a Modified Cyclomatic Complexity of 6 (Highest = 50).
Design

Line: 42

              import com.alibaba.fastjson.parser.SymbolTable;
import com.alibaba.fastjson.util.*;

public class ASMDeserializerFactory implements Opcodes {

    public final ASMClassLoader classLoader;
    protected final AtomicLong  seed              = new AtomicLong();

    final static String         DefaultJSONParser = type(DefaultJSONParser.class);

            

Reported by PMD.

The class 'ASMDeserializerFactory' has a Standard Cyclomatic Complexity of 6 (Highest = 50).
Design

Line: 42

              import com.alibaba.fastjson.parser.SymbolTable;
import com.alibaba.fastjson.util.*;

public class ASMDeserializerFactory implements Opcodes {

    public final ASMClassLoader classLoader;
    protected final AtomicLong  seed              = new AtomicLong();

    final static String         DefaultJSONParser = type(DefaultJSONParser.class);

            

Reported by PMD.

The class 'ASMDeserializerFactory' has a total cyclomatic complexity of 157 (highest 55).
Design

Line: 42

              import com.alibaba.fastjson.parser.SymbolTable;
import com.alibaba.fastjson.util.*;

public class ASMDeserializerFactory implements Opcodes {

    public final ASMClassLoader classLoader;
    protected final AtomicLong  seed              = new AtomicLong();

    final static String         DefaultJSONParser = type(DefaultJSONParser.class);

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 42

              import com.alibaba.fastjson.parser.SymbolTable;
import com.alibaba.fastjson.util.*;

public class ASMDeserializerFactory implements Opcodes {

    public final ASMClassLoader classLoader;
    protected final AtomicLong  seed              = new AtomicLong();

    final static String         DefaultJSONParser = type(DefaultJSONParser.class);

            

Reported by PMD.

Avoid really long classes.
Design

Line: 42

              import com.alibaba.fastjson.parser.SymbolTable;
import com.alibaba.fastjson.util.*;

public class ASMDeserializerFactory implements Opcodes {

    public final ASMClassLoader classLoader;
    protected final AtomicLong  seed              = new AtomicLong();

    final static String         DefaultJSONParser = type(DefaultJSONParser.class);

            

Reported by PMD.

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

Line: 44

              
public class ASMDeserializerFactory implements Opcodes {

    public final ASMClassLoader classLoader;
    protected final AtomicLong  seed              = new AtomicLong();

    final static String         DefaultJSONParser = type(DefaultJSONParser.class);
    final static String         JSONLexerBase     = type(JSONLexerBase.class);


            

Reported by PMD.

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

Line: 45

              public class ASMDeserializerFactory implements Opcodes {

    public final ASMClassLoader classLoader;
    protected final AtomicLong  seed              = new AtomicLong();

    final static String         DefaultJSONParser = type(DefaultJSONParser.class);
    final static String         JSONLexerBase     = type(JSONLexerBase.class);

    public ASMDeserializerFactory(ClassLoader parentClassLoader){

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/serializer/JodaCodec.java
173 issues
Avoid reassigning parameters such as 'formatter'
Design

Line: 204

                      return null;
    }

    protected LocalDateTime parseDateTime(String text, DateTimeFormatter formatter) {
        if (formatter == null) {
            if (text.length() == 19) {
                char c4 = text.charAt(4);
                char c7 = text.charAt(7);
                char c10 = text.charAt(10);

            

Reported by PMD.

Avoid reassigning parameters such as 'formatter'
Design

Line: 204

                      return null;
    }

    protected LocalDateTime parseDateTime(String text, DateTimeFormatter formatter) {
        if (formatter == null) {
            if (text.length() == 19) {
                char c4 = text.charAt(4);
                char c7 = text.charAt(7);
                char c10 = text.charAt(10);

            

Reported by PMD.

Avoid reassigning parameters such as 'formatter'
Design

Line: 204

                      return null;
    }

    protected LocalDateTime parseDateTime(String text, DateTimeFormatter formatter) {
        if (formatter == null) {
            if (text.length() == 19) {
                char c4 = text.charAt(4);
                char c7 = text.charAt(7);
                char c10 = text.charAt(10);

            

Reported by PMD.

Avoid reassigning parameters such as 'formatter'
Design

Line: 204

                      return null;
    }

    protected LocalDateTime parseDateTime(String text, DateTimeFormatter formatter) {
        if (formatter == null) {
            if (text.length() == 19) {
                char c4 = text.charAt(4);
                char c7 = text.charAt(7);
                char c10 = text.charAt(10);

            

Reported by PMD.

Avoid reassigning parameters such as 'formatter'
Design

Line: 204

                      return null;
    }

    protected LocalDateTime parseDateTime(String text, DateTimeFormatter formatter) {
        if (formatter == null) {
            if (text.length() == 19) {
                char c4 = text.charAt(4);
                char c7 = text.charAt(7);
                char c10 = text.charAt(10);

            

Reported by PMD.

Avoid reassigning parameters such as 'formatter'
Design

Line: 204

                      return null;
    }

    protected LocalDateTime parseDateTime(String text, DateTimeFormatter formatter) {
        if (formatter == null) {
            if (text.length() == 19) {
                char c4 = text.charAt(4);
                char c7 = text.charAt(7);
                char c10 = text.charAt(10);

            

Reported by PMD.

Avoid reassigning parameters such as 'formatter'
Design

Line: 204

                      return null;
    }

    protected LocalDateTime parseDateTime(String text, DateTimeFormatter formatter) {
        if (formatter == null) {
            if (text.length() == 19) {
                char c4 = text.charAt(4);
                char c7 = text.charAt(7);
                char c10 = text.charAt(10);

            

Reported by PMD.

Avoid reassigning parameters such as 'formatter'
Design

Line: 204

                      return null;
    }

    protected LocalDateTime parseDateTime(String text, DateTimeFormatter formatter) {
        if (formatter == null) {
            if (text.length() == 19) {
                char c4 = text.charAt(4);
                char c7 = text.charAt(7);
                char c10 = text.charAt(10);

            

Reported by PMD.

Avoid reassigning parameters such as 'formatter'
Design

Line: 204

                      return null;
    }

    protected LocalDateTime parseDateTime(String text, DateTimeFormatter formatter) {
        if (formatter == null) {
            if (text.length() == 19) {
                char c4 = text.charAt(4);
                char c7 = text.charAt(7);
                char c10 = text.charAt(10);

            

Reported by PMD.

Avoid reassigning parameters such as 'formatter'
Design

Line: 204

                      return null;
    }

    protected LocalDateTime parseDateTime(String text, DateTimeFormatter formatter) {
        if (formatter == null) {
            if (text.length() == 19) {
                char c4 = text.charAt(4);
                char c7 = text.charAt(7);
                char c10 = text.charAt(10);

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/number/NumberValueTest_error_13.java
166 issues
Do not use the short type
Performance

Line: 379

              
    public static class Model {
        public byte v0;
        public short v1;
        public int v2;
        public long v3;
        public Byte v4;

        public Short v5;

            

Reported by PMD.

System.out.println is used
Design

Line: 372

                              "}");

        for(String key : object.keySet()) {
            System.out.println("key = " + key);
            System.out.println("vaue = " + object.getJSONObject(key).getIntValue("max_value"));
        }
    }

    public static class Model {

            

Reported by PMD.

System.out.println is used
Design

Line: 373

              
        for(String key : object.keySet()) {
            System.out.println("key = " + key);
            System.out.println("vaue = " + object.getJSONObject(key).getIntValue("max_value"));
        }
    }

    public static class Model {
        public byte v0;

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 1

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

import com.alibaba.fastjson.*;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
import org.junit.Assert;

import java.math.BigDecimal;
import java.math.BigInteger;

            

Reported by PMD.

Possible God Class (WMC=65, ATFD=67, TCC=0.000%)
Design

Line: 13

              import java.sql.Timestamp;
import java.util.concurrent.TimeUnit;

public class NumberValueTest_error_13 extends TestCase {

    public void test_0() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"v0\":49e99999999}", Model.class);

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 13

              import java.sql.Timestamp;
import java.util.concurrent.TimeUnit;

public class NumberValueTest_error_13 extends TestCase {

    public void test_0() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"v0\":49e99999999}", Model.class);

            

Reported by PMD.

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

Line: 15

              
public class NumberValueTest_error_13 extends TestCase {

    public void test_0() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"v0\":49e99999999}", Model.class);
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

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

Line: 15

              
public class NumberValueTest_error_13 extends TestCase {

    public void test_0() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"v0\":49e99999999}", Model.class);
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

                      } catch (JSONException ex) {
            error = ex;
        }
        assertNotNull(error);
        assertTrue(error.getCause() instanceof ArithmeticException);
    }

    public void test_1() throws Exception {
        Exception error = null;

            

Reported by PMD.

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

Line: 23

                          error = ex;
        }
        assertNotNull(error);
        assertTrue(error.getCause() instanceof ArithmeticException);
    }

    public void test_1() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/serializer/SerializeConfig.java
164 issues
High amount of different objects as members denotes a high coupling
Design

Line: 16

               * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.alibaba.fastjson.serializer;

import com.alibaba.fastjson.*;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.fastjson.parser.deserializer.Jdk8DateCodec;

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 51

               * 
 * @author wenshao[szujobs@hotmail.com]
 */
public class SerializeConfig {

    public final static SerializeConfig                   globalInstance  = new SerializeConfig();

    private static boolean                                awtError        = false;
    private static boolean                                jdk8Error       = false;

            

Reported by PMD.

Possible God Class (WMC=214, ATFD=228, TCC=6.061%)
Design

Line: 51

               * 
 * @author wenshao[szujobs@hotmail.com]
 */
public class SerializeConfig {

    public final static SerializeConfig                   globalInstance  = new SerializeConfig();

    private static boolean                                awtError        = false;
    private static boolean                                jdk8Error       = false;

            

Reported by PMD.

The class 'SerializeConfig' has a Modified Cyclomatic Complexity of 7 (Highest = 85).
Design

Line: 51

               * 
 * @author wenshao[szujobs@hotmail.com]
 */
public class SerializeConfig {

    public final static SerializeConfig                   globalInstance  = new SerializeConfig();

    private static boolean                                awtError        = false;
    private static boolean                                jdk8Error       = false;

            

Reported by PMD.

The class 'SerializeConfig' has a Standard Cyclomatic Complexity of 7 (Highest = 85).
Design

Line: 51

               * 
 * @author wenshao[szujobs@hotmail.com]
 */
public class SerializeConfig {

    public final static SerializeConfig                   globalInstance  = new SerializeConfig();

    private static boolean                                awtError        = false;
    private static boolean                                jdk8Error       = false;

            

Reported by PMD.

The class 'SerializeConfig' has a total cyclomatic complexity of 214 (highest 100).
Design

Line: 51

               * 
 * @author wenshao[szujobs@hotmail.com]
 */
public class SerializeConfig {

    public final static SerializeConfig                   globalInstance  = new SerializeConfig();

    private static boolean                                awtError        = false;
    private static boolean                                jdk8Error       = false;

            

Reported by PMD.

Avoid using redundant field initializer for 'awtError'
Performance

Line: 55

              
    public final static SerializeConfig                   globalInstance  = new SerializeConfig();

    private static boolean                                awtError        = false;
    private static boolean                                jdk8Error       = false;
    private static boolean                                oracleJdbcError = false;
    private static boolean                                springfoxError  = false;
    private static boolean                                guavaError      = false;
    

            

Reported by PMD.

Avoid using redundant field initializer for 'jdk8Error'
Performance

Line: 56

                  public final static SerializeConfig                   globalInstance  = new SerializeConfig();

    private static boolean                                awtError        = false;
    private static boolean                                jdk8Error       = false;
    private static boolean                                oracleJdbcError = false;
    private static boolean                                springfoxError  = false;
    private static boolean                                guavaError      = false;
    
    private static boolean                                jodaError       = false;

            

Reported by PMD.

Avoid using redundant field initializer for 'oracleJdbcError'
Performance

Line: 57

              
    private static boolean                                awtError        = false;
    private static boolean                                jdk8Error       = false;
    private static boolean                                oracleJdbcError = false;
    private static boolean                                springfoxError  = false;
    private static boolean                                guavaError      = false;
    
    private static boolean                                jodaError       = false;


            

Reported by PMD.

Avoid using redundant field initializer for 'springfoxError'
Performance

Line: 58

                  private static boolean                                awtError        = false;
    private static boolean                                jdk8Error       = false;
    private static boolean                                oracleJdbcError = false;
    private static boolean                                springfoxError  = false;
    private static boolean                                guavaError      = false;
    
    private static boolean                                jodaError       = false;

    private boolean                                       asm             = !ASMUtils.IS_ANDROID;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/jdk8/LocalDateTimeTest5.java
162 issues
This class has too many methods, consider refactoring it.
Design

Line: 13

              
import junit.framework.TestCase;

public class LocalDateTimeTest5 extends TestCase {

    private static Random random = new Random();

    private Locale origin;
    private TimeZone original = TimeZone.getDefault();

            

Reported by PMD.

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

Line: 17

              
    private static Random random = new Random();

    private Locale origin;
    private TimeZone original = TimeZone.getDefault();
    private String[] zoneIds = TimeZone.getAvailableIDs();

    @Override
    protected void setUp() throws Exception {

            

Reported by PMD.

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

Line: 18

                  private static Random random = new Random();

    private Locale origin;
    private TimeZone original = TimeZone.getDefault();
    private String[] zoneIds = TimeZone.getAvailableIDs();

    @Override
    protected void setUp() throws Exception {
        int index = random.nextInt(zoneIds.length);

            

Reported by PMD.

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

Line: 18

                  private static Random random = new Random();

    private Locale origin;
    private TimeZone original = TimeZone.getDefault();
    private String[] zoneIds = TimeZone.getAvailableIDs();

    @Override
    protected void setUp() throws Exception {
        int index = random.nextInt(zoneIds.length);

            

Reported by PMD.

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

Line: 19

              
    private Locale origin;
    private TimeZone original = TimeZone.getDefault();
    private String[] zoneIds = TimeZone.getAvailableIDs();

    @Override
    protected void setUp() throws Exception {
        int index = random.nextInt(zoneIds.length);
        TimeZone timeZone = TimeZone.getTimeZone(zoneIds[index]);

            

Reported by PMD.

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

Line: 19

              
    private Locale origin;
    private TimeZone original = TimeZone.getDefault();
    private String[] zoneIds = TimeZone.getAvailableIDs();

    @Override
    protected void setUp() throws Exception {
        int index = random.nextInt(zoneIds.length);
        TimeZone timeZone = TimeZone.getTimeZone(zoneIds[index]);

            

Reported by PMD.

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

Line: 21

                  private TimeZone original = TimeZone.getDefault();
    private String[] zoneIds = TimeZone.getAvailableIDs();

    @Override
    protected void setUp() throws Exception {
        int index = random.nextInt(zoneIds.length);
        TimeZone timeZone = TimeZone.getTimeZone(zoneIds[index]);
        TimeZone.setDefault(timeZone);
        JSON.defaultTimeZone = timeZone; // While running mvn tests defaultTimeZone might already be initialized

            

Reported by PMD.

JUnit 4 tests that clean up tests should use the @After annotation, JUnit5 tests should use @AfterEach or @AfterAll
Design

Line: 30

                      origin = Locale.getDefault();
    }

    @Override
    protected void tearDown() throws Exception {
        TimeZone.setDefault(original);
        JSON.defaultTimeZone = original;
        Locale.setDefault(origin);
    }

            

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

                      Locale.setDefault(origin);
    }

    public void test_for_long() throws Exception {
        long millis = 1322874196000L;
        // using localDataTime instance so that different timeZones are tested
        LocalDateTime localDateTime = LocalDateTime.ofInstant(
                Instant.ofEpochMilli(millis), TimeZone.getDefault().toZoneId());
        VO vo = JSON.parseObject("{\"date\":" + millis + "}", VO.class);

            

Reported by PMD.

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

Line: 37

                      Locale.setDefault(origin);
    }

    public void test_for_long() throws Exception {
        long millis = 1322874196000L;
        // using localDataTime instance so that different timeZones are tested
        LocalDateTime localDateTime = LocalDateTime.ofInstant(
                Instant.ofEpochMilli(millis), TimeZone.getDefault().toZoneId());
        VO vo = JSON.parseObject("{\"date\":" + millis + "}", VO.class);

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/serializer/AwtCodec.java
146 issues
Avoid reassigning parameters such as 'sep'
Design

Line: 84

              
    }

    protected char writeClassName(SerializeWriter out, Class<?> clazz, char sep) {
        if (out.isEnabled(SerializerFeature.WriteClassName)) {
            out.write('{');
            out.writeFieldName(JSON.DEFAULT_TYPE_KEY);
            out.writeString(clazz.getName());
            sep = ',';

            

Reported by PMD.

Possible God Class (WMC=80, ATFD=87, TCC=0.000%)
Design

Line: 18

              import com.alibaba.fastjson.parser.ParseContext;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;

public class AwtCodec implements ObjectSerializer, ObjectDeserializer {

    public final static AwtCodec instance = new AwtCodec();
    
    public static boolean support(Class<?> clazz) {
        return clazz == Point.class //

            

Reported by PMD.

The class 'AwtCodec' has a Modified Cyclomatic Complexity of 6 (Highest = 11).
Design

Line: 18

              import com.alibaba.fastjson.parser.ParseContext;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;

public class AwtCodec implements ObjectSerializer, ObjectDeserializer {

    public final static AwtCodec instance = new AwtCodec();
    
    public static boolean support(Class<?> clazz) {
        return clazz == Point.class //

            

Reported by PMD.

The class 'AwtCodec' has a Standard Cyclomatic Complexity of 6 (Highest = 11).
Design

Line: 18

              import com.alibaba.fastjson.parser.ParseContext;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;

public class AwtCodec implements ObjectSerializer, ObjectDeserializer {

    public final static AwtCodec instance = new AwtCodec();
    
    public static boolean support(Class<?> clazz) {
        return clazz == Point.class //

            

Reported by PMD.

The class 'AwtCodec' has a total cyclomatic complexity of 80 (highest 16).
Design

Line: 18

              import com.alibaba.fastjson.parser.ParseContext;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;

public class AwtCodec implements ObjectSerializer, ObjectDeserializer {

    public final static AwtCodec instance = new AwtCodec();
    
    public static boolean support(Class<?> clazz) {
        return clazz == Point.class //

            

Reported by PMD.

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

Line: 53

                          
            sep = writeClassName(out, Font.class, sep);
            
            out.writeFieldValue(sep, "name", font.getName());
            out.writeFieldValue(',', "style", font.getStyle());
            out.writeFieldValue(',', "size", font.getSize());
        } else if (object instanceof Rectangle) {
            Rectangle rectangle = (Rectangle) object;
            

            

Reported by PMD.

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

Line: 54

                          sep = writeClassName(out, Font.class, sep);
            
            out.writeFieldValue(sep, "name", font.getName());
            out.writeFieldValue(',', "style", font.getStyle());
            out.writeFieldValue(',', "size", font.getSize());
        } else if (object instanceof Rectangle) {
            Rectangle rectangle = (Rectangle) object;
            
            sep = writeClassName(out, Rectangle.class, sep);

            

Reported by PMD.

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

Line: 55

                          
            out.writeFieldValue(sep, "name", font.getName());
            out.writeFieldValue(',', "style", font.getStyle());
            out.writeFieldValue(',', "size", font.getSize());
        } else if (object instanceof Rectangle) {
            Rectangle rectangle = (Rectangle) object;
            
            sep = writeClassName(out, Rectangle.class, sep);
            

            

Reported by PMD.

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

Line: 70

                          
            sep = writeClassName(out, Color.class, sep);
            
            out.writeFieldValue(sep, "r", color.getRed());
            out.writeFieldValue(',', "g", color.getGreen());
            out.writeFieldValue(',', "b", color.getBlue());
            if (color.getAlpha() > 0) {
                out.writeFieldValue(',', "alpha", color.getAlpha());
            }

            

Reported by PMD.

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

Line: 71

                          sep = writeClassName(out, Color.class, sep);
            
            out.writeFieldValue(sep, "r", color.getRed());
            out.writeFieldValue(',', "g", color.getGreen());
            out.writeFieldValue(',', "b", color.getBlue());
            if (color.getAlpha() > 0) {
                out.writeFieldValue(',', "alpha", color.getAlpha());
            }
        } else {

            

Reported by PMD.