The following issues were found

src/main/java/com/alibaba/fastjson/parser/JSONLexerBase.java
753 issues
Avoid using a branching statement as the last in a loop.
Error

Line: 364

                          }

            nextToken();
            break;
        }
    }

    public final void nextIdent() {
        while (isWhitespace(ch)) {

            

Reported by PMD.

Avoid using a branching statement as the last in a loop.
Error

Line: 856

                          hash = 31 * hash + chLocal;

            sp++;
            continue;
        }

        this.ch = charAt(bp);
        token = JSONToken.IDENTIFIER;


            

Reported by PMD.

Avoid using a branching statement as the last in a loop.
Error

Line: 1766

                          }

            matchStat = NOT_MATCH;
            return null;
        }

        if (chLocal == ',') {
            bp += offset;
            this.ch = this.charAt(bp);

            

Reported by PMD.

Avoid using a branching statement as the last in a loop.
Error

Line: 1892

                          }

            matchStat = NOT_MATCH;
            return;
        }

        if (chLocal == seperator) {
            bp += offset;
            this.ch = this.charAt(bp);

            

Reported by PMD.

Avoid using a branching statement as the last in a loop.
Error

Line: 2212

                                  chLocal = charAt(bp + offset++);
                    continue;
                }
                break;
            }
            matchStat = NOT_MATCH;
            return 0;
        } else {
            matchStat = NOT_MATCH;

            

Reported by PMD.

Avoid using a branching statement as the last in a loop.
Error

Line: 2474

                                  chLocal = charAt(bp + offset++);
                    continue;
                }
                break;
            }
            matchStat = NOT_MATCH;
            return 0;
        } else {
            matchStat = NOT_MATCH;

            

Reported by PMD.

Avoid using a branching statement as the last in a loop.
Error

Line: 2634

                                  chLocal = charAt(bp + offset++);
                    continue;
                }
                break;
            }
            matchStat = NOT_MATCH;
            return 0;
        } else {
            matchStat = NOT_MATCH;

            

Reported by PMD.

Avoid using a branching statement as the last in a loop.
Error

Line: 2814

                                  chLocal = charAt(bp + offset++);
                    continue;
                }
                break;
            }
            matchStat = NOT_MATCH;
            return 0;
        } else {
            matchStat = NOT_MATCH;

            

Reported by PMD.

Avoid using a branching statement as the last in a loop.
Error

Line: 2952

                                  chLocal = charAt(bp + offset++);
                    continue;
                }
                break;
            }
            matchStat = NOT_MATCH;
            return 0;
        } else {
            matchStat = NOT_MATCH;

            

Reported by PMD.

Avoid using a branching statement as the last in a loop.
Error

Line: 3079

                                  chLocal = charAt(bp + offset++);
                    continue;
                }
                break;
            }
            matchStat = NOT_MATCH;
            return null;
        } else {
            matchStat = NOT_MATCH;

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/util/TypeUtils.java
721 issues
Do not use the short type
Performance

Line: 917

                      return decimal.byteValueExact();
    }

    public static short shortValue(BigDecimal decimal) {
        if (decimal == null) {
            return 0;
        }

        int scale = decimal.scale();

            

Reported by PMD.

Do not use the short type
Performance

Line: 1937

              
                            Arrays.sort(paramNames_sorted);
                            paramNameMapping = new short[paramNames.length];
                            for(short p = 0; p < paramNames.length; p++){
                                int index = Arrays.binarySearch(paramNames_sorted, paramNames[p]);
                                paramNameMapping[index] = p;
                            }
                            paramNames = paramNames_sorted;
                        }

            

Reported by PMD.

Do not use the short type
Performance

Line: 1957

                                      }
                    }
                    if(p >= 0){
                        short index = paramNameMapping[p];
                        Annotation[] paramAnnotations = paramAnnotationArrays[index];
                        if(paramAnnotations != null){
                            for(Annotation paramAnnotation : paramAnnotations){
                                if(paramAnnotation instanceof JSONField){
                                    annotation = (JSONField) paramAnnotation;

            

Reported by PMD.

Return an empty array rather than null.
Error

Line: 3015

                      return creatorConstructor;
    }

    public static String[] getKoltinConstructorParameters(Class clazz){
        if(kotlin_kclass_constructor == null && !kotlin_class_klass_error){
            try{
                Class class_kotlin_kclass = Class.forName("kotlin.reflect.jvm.internal.KClassImpl");
                kotlin_kclass_constructor = class_kotlin_kclass.getConstructor(Class.class);
            } catch(Throwable e){

            

Reported by PMD.

Avoid reassigning parameters such as 'format'
Design

Line: 451

                      return castToDate(value, null);
    }

    public static Date castToDate(Object value, String format){
        if(value == null){
            return null;
        }

        if(value instanceof Date){ // 使用频率最高的,应优先处理

            

Reported by PMD.

Avoid reassigning parameters such as 'format'
Design

Line: 451

                      return castToDate(value, null);
    }

    public static Date castToDate(Object value, String format){
        if(value == null){
            return null;
        }

        if(value instanceof Date){ // 使用频率最高的,应优先处理

            

Reported by PMD.

Avoid reassigning parameters such as 'format'
Design

Line: 451

                      return castToDate(value, null);
    }

    public static Date castToDate(Object value, String format){
        if(value == null){
            return null;
        }

        if(value instanceof Date){ // 使用频率最高的,应优先处理

            

Reported by PMD.

Avoid reassigning parameters such as 'format'
Design

Line: 451

                      return castToDate(value, null);
    }

    public static Date castToDate(Object value, String format){
        if(value == null){
            return null;
        }

        if(value instanceof Date){ // 使用频率最高的,应优先处理

            

Reported by PMD.

Avoid reassigning parameters such as 'format'
Design

Line: 451

                      return castToDate(value, null);
    }

    public static Date castToDate(Object value, String format){
        if(value == null){
            return null;
        }

        if(value instanceof Date){ // 使用频率最高的,应优先处理

            

Reported by PMD.

Avoid reassigning parameters such as 'format'
Design

Line: 451

                      return castToDate(value, null);
    }

    public static Date castToDate(Object value, String format){
        if(value == null){
            return null;
        }

        if(value instanceof Date){ // 使用频率最高的,应优先处理

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/JSONPath.java
647 issues
Overridable method 'next' called during object construction
Error

Line: 907

              
        public JSONPathParser(String path){
            this.path = path;
            next();
        }

        void next() {
            ch = path.charAt(pos++);
        }

            

Reported by PMD.

Avoid using a branching statement as the last in a loop.
Error

Line: 102

                                      || segmentType == PropertySegment.class) {
                    continue;
                }
                return false;
            }
            return true;
        } catch (JSONPathException ex) {
            // skip
            return false;

            

Reported by PMD.

Avoid reassigning parameters such as 'features'
Design

Line: 772

                   * @param path
     * @return
     */
    public static Object extract(String json, String path, ParserConfig config, int features, Feature... optionFeatures) {
        features |= Feature.OrderedField.mask;
        DefaultJSONParser parser = new DefaultJSONParser(json, config, features);
        JSONPath jsonPath = compile(path);
        Object result = jsonPath.extract(parser);
        parser.lexer.close();

            

Reported by PMD.

Avoid reassigning parameters such as 'filter'
Design

Line: 1744

                          return segment;
        }

        Filter filterRest(Filter filter) {
            boolean and = ch == '&';
            if ((ch == '&' && getNextChar() == '&') || (ch == '|' && getNextChar() == '|')) {
                next();
                next();


            

Reported by PMD.

Avoid reassigning parameters such as 'indexText'
Design

Line: 2004

                          return result;
        }

        Segment buildArraySegement(String indexText) {
            final int indexTextLen = indexText.length();
            final char firstChar = indexText.charAt(0);
            final char lastChar = indexText.charAt(indexTextLen - 1);

            int commaIndex = indexText.indexOf(',');

            

Reported by PMD.

Avoid reassigning parameters such as 'a'
Design

Line: 2263

                      }
    }

    static int compare(Object a, Object b) {
        if (a.getClass() == b.getClass()) {
            return ((Comparable) a).compareTo(b);
        }

        Class typeA = a.getClass();

            

Reported by PMD.

Avoid reassigning parameters such as 'b'
Design

Line: 2263

                      }
    }

    static int compare(Object a, Object b) {
        if (a.getClass() == b.getClass()) {
            return ((Comparable) a).compareTo(b);
        }

        Class typeA = a.getClass();

            

Reported by PMD.

Avoid reassigning parameters such as 'a'
Design

Line: 2263

                      }
    }

    static int compare(Object a, Object b) {
        if (a.getClass() == b.getClass()) {
            return ((Comparable) a).compareTo(b);
        }

        Class typeA = a.getClass();

            

Reported by PMD.

Avoid reassigning parameters such as 'a'
Design

Line: 2263

                      }
    }

    static int compare(Object a, Object b) {
        if (a.getClass() == b.getClass()) {
            return ((Comparable) a).compareTo(b);
        }

        Class typeA = a.getClass();

            

Reported by PMD.

Avoid reassigning parameters such as 'b'
Design

Line: 2263

                      }
    }

    static int compare(Object a, Object b) {
        if (a.getClass() == b.getClass()) {
            return ((Comparable) a).compareTo(b);
        }

        Class typeA = a.getClass();

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/parser/JSONScanner.java
474 issues
Avoid using a branching statement as the last in a loop.
Error

Line: 1384

                              }

                matchStat = NOT_MATCH;
                return null;
            }
        } else if (text.startsWith("ull", index)) {
            index += 3;
            ch = charAt(index++);
            list = null;

            

Reported by PMD.

Avoid using a branching statement as the last in a loop.
Error

Line: 1677

                                      matchStat = NOT_MATCH;
                        return false;
                    }
                    break;
                }
                matchStat = END;
                break;
            } else if (isWhitespace(ch)) {
                ch = charAt(++bp);

            

Reported by PMD.

Avoid using a branching statement as the last in a loop.
Error

Line: 1776

                                  chLocal = charAt(offset++);
                    continue;
                }
                break;
            }
            matchStat = NOT_MATCH;
            return 0;
        } else {
            matchStat = NOT_MATCH;

            

Reported by PMD.

Avoid using a branching statement as the last in a loop.
Error

Line: 1922

                                  chLocal = charAt(offset++);
                    continue;
                }
                break;
            }
            matchStat = NOT_MATCH;
            return 0;
        } else {
            matchStat = NOT_MATCH;

            

Reported by PMD.

Avoid using a branching statement as the last in a loop.
Error

Line: 2016

                                  chLocal = charAt(offset++);
                    continue;
                }
                break;
            }
            matchStat = NOT_MATCH;
            return 0;
        } else {
            matchStat = NOT_MATCH;

            

Reported by PMD.

Avoid using a branching statement as the last in a loop.
Error

Line: 2288

                              next();
                continue;
            }
            break;
        }
        if (types.length != typeIndex) {
            String[] array = new String[typeIndex];
            System.arraycopy(types, 0, array, 0, typeIndex);
            types = array;

            

Reported by PMD.

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

Line: 35

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public final class JSONScanner extends JSONLexerBase {

    private final String text;
    private final int    len;

    public JSONScanner(String input){

            

Reported by PMD.

The class 'JSONScanner' has a Standard Cyclomatic Complexity of 12 (Highest = 73).
Design

Line: 35

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public final class JSONScanner extends JSONLexerBase {

    private final String text;
    private final int    len;

    public JSONScanner(String input){

            

Reported by PMD.

The class 'JSONScanner' has a NCSS line count of 2162 (Highest = 360).
Design

Line: 35

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public final class JSONScanner extends JSONLexerBase {

    private final String text;
    private final int    len;

    public JSONScanner(String input){

            

Reported by PMD.

The class 'JSONScanner' has a Modified Cyclomatic Complexity of 12 (Highest = 73).
Design

Line: 35

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public final class JSONScanner extends JSONLexerBase {

    private final String text;
    private final int    len;

    public JSONScanner(String input){

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/parser/deserializer/JavaBeanDeserializer.java
343 issues
Overridable method 'getFieldDeserializer' called during object construction
Error

Line: 93

                      fieldDeserializers = new FieldDeserializer[beanInfo.fields.length];
        for (int i = 0, size = beanInfo.fields.length; i < size; ++i) {
            FieldInfo fieldInfo = beanInfo.fields[i];
            FieldDeserializer fieldDeserializer = getFieldDeserializer(fieldInfo.name);
            fieldDeserializers[i] = fieldDeserializer;
        }
    }

    public FieldDeserializer getFieldDeserializer(String key) {

            

Reported by PMD.

Avoid reassigning parameters such as 'object'
Design

Line: 295

                  }

    @SuppressWarnings({ "unchecked" })
    public <T> T deserialzeArrayMapping(DefaultJSONParser parser, Type type, Object fieldName, Object object) {
        final JSONLexer lexer = parser.lexer; // xxx
        if (lexer.token() != JSONToken.LBRACKET) {
            throw new JSONException("error");
        }


            

Reported by PMD.

Avoid reassigning parameters such as 'object'
Design

Line: 395

                  protected <T> T deserialze(DefaultJSONParser parser, // 
                               Type type, // 
                               Object fieldName, // 
                               Object object, //
                               int features, //
                               int[] setFlags) {
        if (type == JSON.class || type == JSONObject.class) {
            return (T) parser.parse();
        }

            

Reported by PMD.

Avoid reassigning parameters such as 'object'
Design

Line: 395

                  protected <T> T deserialze(DefaultJSONParser parser, // 
                               Type type, // 
                               Object fieldName, // 
                               Object object, //
                               int features, //
                               int[] setFlags) {
        if (type == JSON.class || type == JSONObject.class) {
            return (T) parser.parse();
        }

            

Reported by PMD.

Avoid reassigning parameters such as 'object'
Design

Line: 395

                  protected <T> T deserialze(DefaultJSONParser parser, // 
                               Type type, // 
                               Object fieldName, // 
                               Object object, //
                               int features, //
                               int[] setFlags) {
        if (type == JSON.class || type == JSONObject.class) {
            return (T) parser.parse();
        }

            

Reported by PMD.

Avoid reassigning parameters such as 'object'
Design

Line: 395

                  protected <T> T deserialze(DefaultJSONParser parser, // 
                               Type type, // 
                               Object fieldName, // 
                               Object object, //
                               int features, //
                               int[] setFlags) {
        if (type == JSON.class || type == JSONObject.class) {
            return (T) parser.parse();
        }

            

Reported by PMD.

Avoid reassigning parameters such as 'object'
Design

Line: 395

                  protected <T> T deserialze(DefaultJSONParser parser, // 
                               Type type, // 
                               Object fieldName, // 
                               Object object, //
                               int features, //
                               int[] setFlags) {
        if (type == JSON.class || type == JSONObject.class) {
            return (T) parser.parse();
        }

            

Reported by PMD.

Avoid reassigning parameters such as 'object'
Design

Line: 395

                  protected <T> T deserialze(DefaultJSONParser parser, // 
                               Type type, // 
                               Object fieldName, // 
                               Object object, //
                               int features, //
                               int[] setFlags) {
        if (type == JSON.class || type == JSONObject.class) {
            return (T) parser.parse();
        }

            

Reported by PMD.

Avoid reassigning parameters such as 'object'
Design

Line: 395

                  protected <T> T deserialze(DefaultJSONParser parser, // 
                               Type type, // 
                               Object fieldName, // 
                               Object object, //
                               int features, //
                               int[] setFlags) {
        if (type == JSON.class || type == JSONObject.class) {
            return (T) parser.parse();
        }

            

Reported by PMD.

Avoid reassigning parameters such as 'object'
Design

Line: 395

                  protected <T> T deserialze(DefaultJSONParser parser, // 
                               Type type, // 
                               Object fieldName, // 
                               Object object, //
                               int features, //
                               int[] setFlags) {
        if (type == JSON.class || type == JSONObject.class) {
            return (T) parser.parse();
        }

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/parser/DefaultJSONParser.java
296 issues
Avoid using a branching statement as the last in a loop.
Error

Line: 763

                              if (lexer.isEnabled(Feature.AllowArbitraryCommas)) {
                    while (lexer.token() == JSONToken.COMMA) {
                        lexer.nextToken();
                        continue;
                    }
                }

                if (lexer.token() == JSONToken.RBRACKET) {
                    break;

            

Reported by PMD.

Avoid using a branching statement as the last in a loop.
Error

Line: 1201

                              if (lexer.isEnabled(Feature.AllowArbitraryCommas)) {
                    while (lexer.token() == JSONToken.COMMA) {
                        lexer.nextToken();
                        continue;
                    }
                }

                Object value;
                switch (lexer.token()) {

            

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 com.alibaba.fastjson.*;
import com.alibaba.fastjson.parser.deserializer.*;
import com.alibaba.fastjson.serializer.BeanContext;
import com.alibaba.fastjson.serializer.IntegerCodec;

            

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.parser;

import com.alibaba.fastjson.*;
import com.alibaba.fastjson.parser.deserializer.*;
import com.alibaba.fastjson.serializer.BeanContext;
import com.alibaba.fastjson.serializer.IntegerCodec;

            

Reported by PMD.

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

Line: 43

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public class DefaultJSONParser implements Closeable {

    public final Object                input;
    public final SymbolTable           symbolTable;
    protected ParserConfig             config;


            

Reported by PMD.

The class 'DefaultJSONParser' has a total cyclomatic complexity of 448 (highest 141).
Design

Line: 43

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public class DefaultJSONParser implements Closeable {

    public final Object                input;
    public final SymbolTable           symbolTable;
    protected ParserConfig             config;


            

Reported by PMD.

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

Line: 43

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public class DefaultJSONParser implements Closeable {

    public final Object                input;
    public final SymbolTable           symbolTable;
    protected ParserConfig             config;


            

Reported by PMD.

Too many fields
Design

Line: 43

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public class DefaultJSONParser implements Closeable {

    public final Object                input;
    public final SymbolTable           symbolTable;
    protected ParserConfig             config;


            

Reported by PMD.

Possible God Class (WMC=448, ATFD=355, TCC=24.319%)
Design

Line: 43

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public class DefaultJSONParser implements Closeable {

    public final Object                input;
    public final SymbolTable           symbolTable;
    protected ParserConfig             config;


            

Reported by PMD.

Avoid really long classes.
Design

Line: 43

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public class DefaultJSONParser implements Closeable {

    public final Object                input;
    public final SymbolTable           symbolTable;
    protected ParserConfig             config;


            

Reported by PMD.

src/main/java/com/alibaba/fastjson/util/JavaBeanInfo.java
263 issues
Avoid reassigning parameters such as 'propertyNamingStrategy'
Design

Line: 266

              
    public static JavaBeanInfo build(Class<?> clazz //
            , Type type //
            , PropertyNamingStrategy propertyNamingStrategy //
            , boolean fieldBased //
            , boolean compatibleWithJavaBean
            , boolean jacksonCompatible
    ) {
        JSONType jsonType = TypeUtils.getAnnotation(clazz,JSONType.class);

            

Reported by PMD.

Avoid reassigning parameters such as 'fieldBased'
Design

Line: 267

                  public static JavaBeanInfo build(Class<?> clazz //
            , Type type //
            , PropertyNamingStrategy propertyNamingStrategy //
            , boolean fieldBased //
            , boolean compatibleWithJavaBean
            , boolean jacksonCompatible
    ) {
        JSONType jsonType = TypeUtils.getAnnotation(clazz,JSONType.class);
        if (jsonType != null) {

            

Reported by PMD.

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

Line: 20

              import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.serializer.SerializerFeature;

public class JavaBeanInfo {

    public final Class<?> clazz;
    public final Class<?> builderClass;
    public final Constructor<?> defaultConstructor;
    public final Constructor<?> creatorConstructor;

            

Reported by PMD.

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

Line: 20

              import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.serializer.SerializerFeature;

public class JavaBeanInfo {

    public final Class<?> clazz;
    public final Class<?> builderClass;
    public final Constructor<?> defaultConstructor;
    public final Constructor<?> creatorConstructor;

            

Reported by PMD.

The class 'JavaBeanInfo' has a total cyclomatic complexity of 286 (highest 183).
Design

Line: 20

              import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.serializer.SerializerFeature;

public class JavaBeanInfo {

    public final Class<?> clazz;
    public final Class<?> builderClass;
    public final Constructor<?> defaultConstructor;
    public final Constructor<?> creatorConstructor;

            

Reported by PMD.

Avoid really long classes.
Design

Line: 20

              import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.serializer.SerializerFeature;

public class JavaBeanInfo {

    public final Class<?> clazz;
    public final Class<?> builderClass;
    public final Constructor<?> defaultConstructor;
    public final Constructor<?> creatorConstructor;

            

Reported by PMD.

Too many fields
Design

Line: 20

              import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.serializer.SerializerFeature;

public class JavaBeanInfo {

    public final Class<?> clazz;
    public final Class<?> builderClass;
    public final Constructor<?> defaultConstructor;
    public final Constructor<?> creatorConstructor;

            

Reported by PMD.

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

Line: 22

              
public class JavaBeanInfo {

    public final Class<?> clazz;
    public final Class<?> builderClass;
    public final Constructor<?> defaultConstructor;
    public final Constructor<?> creatorConstructor;
    public final Method factoryMethod;
    public final Method buildMethod;

            

Reported by PMD.

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

Line: 27

                  public final Constructor<?> defaultConstructor;
    public final Constructor<?> creatorConstructor;
    public final Method factoryMethod;
    public final Method buildMethod;

    public final int defaultConstructorParameterSize;

    public final FieldInfo[] fields;
    public final FieldInfo[] sortedFields;

            

Reported by PMD.

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

Line: 29

                  public final Method factoryMethod;
    public final Method buildMethod;

    public final int defaultConstructorParameterSize;

    public final FieldInfo[] fields;
    public final FieldInfo[] sortedFields;

    public final int parserFeatures;

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/serializer/ASMSerializerFactory.java
261 issues
The type has an NCSS line count of 1502
Design

Line: 26

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

public class ASMSerializerFactory implements Opcodes {

    protected final ASMClassLoader classLoader             = new ASMClassLoader();

    private final AtomicLong       seed                    = new AtomicLong();


            

Reported by PMD.

The class 'ASMSerializerFactory' has a total cyclomatic complexity of 224 (highest 35).
Design

Line: 26

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

public class ASMSerializerFactory implements Opcodes {

    protected final ASMClassLoader classLoader             = new ASMClassLoader();

    private final AtomicLong       seed                    = new AtomicLong();


            

Reported by PMD.

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

Line: 26

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

public class ASMSerializerFactory implements Opcodes {

    protected final ASMClassLoader classLoader             = new ASMClassLoader();

    private final AtomicLong       seed                    = new AtomicLong();


            

Reported by PMD.

Avoid really long classes.
Design

Line: 26

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

public class ASMSerializerFactory implements Opcodes {

    protected final ASMClassLoader classLoader             = new ASMClassLoader();

    private final AtomicLong       seed                    = new AtomicLong();


            

Reported by PMD.

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

Line: 26

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

public class ASMSerializerFactory implements Opcodes {

    protected final ASMClassLoader classLoader             = new ASMClassLoader();

    private final AtomicLong       seed                    = new AtomicLong();


            

Reported by PMD.

The class 'ASMSerializerFactory' has a NCSS line count of 1502 (Highest = 278).
Design

Line: 26

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

public class ASMSerializerFactory implements Opcodes {

    protected final ASMClassLoader classLoader             = new ASMClassLoader();

    private final AtomicLong       seed                    = new AtomicLong();


            

Reported by PMD.

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

Line: 26

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

public class ASMSerializerFactory implements Opcodes {

    protected final ASMClassLoader classLoader             = new ASMClassLoader();

    private final AtomicLong       seed                    = new AtomicLong();


            

Reported by PMD.

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

Line: 28

              
public class ASMSerializerFactory implements Opcodes {

    protected final ASMClassLoader classLoader             = new ASMClassLoader();

    private final AtomicLong       seed                    = new AtomicLong();

    static final String            JSONSerializer           = type(JSONSerializer.class);
    static final String            ObjectSerializer         = type(ObjectSerializer.class);

            

Reported by PMD.

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

Line: 30

              
    protected final ASMClassLoader classLoader             = new ASMClassLoader();

    private final AtomicLong       seed                    = new AtomicLong();

    static final String            JSONSerializer           = type(JSONSerializer.class);
    static final String            ObjectSerializer         = type(ObjectSerializer.class);
    static final String            ObjectSerializer_desc    = "L" + ObjectSerializer + ";";
    static final String            SerializeWriter          = type(SerializeWriter.class);

            

Reported by PMD.

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

Line: 53

                      static int                    original       = 7;
        static int                    processValue   = 8;

        private final FieldInfo[]       getters;
        private final String            className;
        private final SerializeBeanInfo beanInfo;
        private final boolean           writeDirect;

        private Map<String, Integer>    variants       = new HashMap<String, Integer>();

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/parser/deserializer/Jdk8DateCodec.java
228 issues
Avoid reassigning parameters such as 'formatter'
Design

Line: 259

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

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

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

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

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

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

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

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

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

                      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/issue_2200/Issue2224.java
226 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 13

              
public class Issue2224 extends TestCase {
    //support inherit with other parameterized type
    public void test_for_issue() {
        String json = "[{\"idNo\":\"123456\",\"name\":\"tom\"},{\"idNo\":\"123457\",\"name\":\"jack\"}]";
        PersonCollection personCollection = JSON.parseObject(json, PersonCollection.class);
        assertNotNull(personCollection);
        assertEquals(2, personCollection.size());
        assertEquals("tom", personCollection.get("123456").getName());

            

Reported by PMD.

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

Line: 13

              
public class Issue2224 extends TestCase {
    //support inherit with other parameterized type
    public void test_for_issue() {
        String json = "[{\"idNo\":\"123456\",\"name\":\"tom\"},{\"idNo\":\"123457\",\"name\":\"jack\"}]";
        PersonCollection personCollection = JSON.parseObject(json, PersonCollection.class);
        assertNotNull(personCollection);
        assertEquals(2, personCollection.size());
        assertEquals("tom", personCollection.get("123456").getName());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                  public void test_for_issue() {
        String json = "[{\"idNo\":\"123456\",\"name\":\"tom\"},{\"idNo\":\"123457\",\"name\":\"jack\"}]";
        PersonCollection personCollection = JSON.parseObject(json, PersonCollection.class);
        assertNotNull(personCollection);
        assertEquals(2, personCollection.size());
        assertEquals("tom", personCollection.get("123456").getName());
        assertEquals("jack", personCollection.get("123457").getName());
        String json2 = JSON.toJSONString(personCollection);
        assertNotNull(json2);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                      String json = "[{\"idNo\":\"123456\",\"name\":\"tom\"},{\"idNo\":\"123457\",\"name\":\"jack\"}]";
        PersonCollection personCollection = JSON.parseObject(json, PersonCollection.class);
        assertNotNull(personCollection);
        assertEquals(2, personCollection.size());
        assertEquals("tom", personCollection.get("123456").getName());
        assertEquals("jack", personCollection.get("123457").getName());
        String json2 = JSON.toJSONString(personCollection);
        assertNotNull(json2);
    }

            

Reported by PMD.

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

Line: 17

                      String json = "[{\"idNo\":\"123456\",\"name\":\"tom\"},{\"idNo\":\"123457\",\"name\":\"jack\"}]";
        PersonCollection personCollection = JSON.parseObject(json, PersonCollection.class);
        assertNotNull(personCollection);
        assertEquals(2, personCollection.size());
        assertEquals("tom", personCollection.get("123456").getName());
        assertEquals("jack", personCollection.get("123457").getName());
        String json2 = JSON.toJSONString(personCollection);
        assertNotNull(json2);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      PersonCollection personCollection = JSON.parseObject(json, PersonCollection.class);
        assertNotNull(personCollection);
        assertEquals(2, personCollection.size());
        assertEquals("tom", personCollection.get("123456").getName());
        assertEquals("jack", personCollection.get("123457").getName());
        String json2 = JSON.toJSONString(personCollection);
        assertNotNull(json2);
    }


            

Reported by PMD.

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

Line: 18

                      PersonCollection personCollection = JSON.parseObject(json, PersonCollection.class);
        assertNotNull(personCollection);
        assertEquals(2, personCollection.size());
        assertEquals("tom", personCollection.get("123456").getName());
        assertEquals("jack", personCollection.get("123457").getName());
        String json2 = JSON.toJSONString(personCollection);
        assertNotNull(json2);
    }


            

Reported by PMD.

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

Line: 18

                      PersonCollection personCollection = JSON.parseObject(json, PersonCollection.class);
        assertNotNull(personCollection);
        assertEquals(2, personCollection.size());
        assertEquals("tom", personCollection.get("123456").getName());
        assertEquals("jack", personCollection.get("123457").getName());
        String json2 = JSON.toJSONString(personCollection);
        assertNotNull(json2);
    }


            

Reported by PMD.

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

Line: 19

                      assertNotNull(personCollection);
        assertEquals(2, personCollection.size());
        assertEquals("tom", personCollection.get("123456").getName());
        assertEquals("jack", personCollection.get("123457").getName());
        String json2 = JSON.toJSONString(personCollection);
        assertNotNull(json2);
    }

    //support inherit with other parameterized type and item type is generic

            

Reported by PMD.

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

Line: 19

                      assertNotNull(personCollection);
        assertEquals(2, personCollection.size());
        assertEquals("tom", personCollection.get("123456").getName());
        assertEquals("jack", personCollection.get("123457").getName());
        String json2 = JSON.toJSONString(personCollection);
        assertNotNull(json2);
    }

    //support inherit with other parameterized type and item type is generic

            

Reported by PMD.