Method getValueForField
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
private Object getValueForField(Field field, Object value)
throws JSONException {
try {
if (value != null) {
if (value == JSONObject.NULL) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File ObjectMapper.java
has 274 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
Method convertArrayToList
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
private List<Object> convertArrayToList(Field field, JSONArray array)
throws IllegalAccessException, JSONException {
if (List.class.isAssignableFrom(field.getType())) {
ParameterizedType parameterizedType = (ParameterizedType) field.getGenericType();
Type[] types = parameterizedType.getActualTypeArguments();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method getValueForField
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private Object getValueForField(Field field, Object value)
throws JSONException {
try {
if (value != null) {
if (value == JSONObject.NULL) {
Method _convertToJSONObject
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private JSONObject _convertToJSONObject(Object fromValue)
throws JSONException, InvocationTargetException, IllegalAccessException {
JSONObject jsonObject = new JSONObject();
if(fromValue instanceof Map) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method convertValue
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public <T> T convertValue(Object fromValue, Class<T> toValueType)
throws IllegalArgumentException {
if (fromValue == null) {
return null;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method convertArrayToList
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private List<Object> convertArrayToList(Field field, JSONArray array)
throws IllegalAccessException, JSONException {
if (List.class.isAssignableFrom(field.getType())) {
ParameterizedType parameterizedType = (ParameterizedType) field.getGenericType();
Type[] types = parameterizedType.getActualTypeArguments();
Method getJsonValue
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private Object getJsonValue(Object value, Class<?> clazz, Field field)
throws InvocationTargetException, IllegalAccessException {
if (value == null) {
// Now technically we /could/ return JsonNode.NULL here but Chrome's webkit inspector croaks
// if you pass a null "id"
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method convertValue
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public <T> T convertValue(Object fromValue, Class<T> toValueType)
throws IllegalArgumentException {
if (fromValue == null) {
return null;
}
Method getEnumByMethod
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private Enum getEnumByMethod(String value, Class<? extends Enum> clazz, Method method) {
Enum[] enumValues = clazz.getEnumConstants();
// Start at the front to ensure first always wins
for (int i = 0; i < enumValues.length; ++i) {
Enum enumValue = enumValues[i];
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this method. Open
return "-Infinity";
Avoid too many return
statements within this method. Open
return convertArrayToList(field, (JSONArray) value);
Avoid too many return
statements within this method. Open
return value;
Avoid too many return
statements within this method. Open
return numberValue.longValue();
Avoid too many return
statements within this method. Open
return value;
Avoid too many return
statements within this method. Open
return numberValue.intValue();
Avoid too many return
statements within this method. Open
return "Infinity";
Avoid too many return
statements within this method. Open
return numberValue.floatValue();
Avoid too many return
statements within this method. Open
return numberValue.doubleValue();
Avoid too many return
statements within this method. Open
return "NaN";
Avoid too many return
statements within this method. Open
return getEnumValue((String) value, field.getType().asSubclass(Enum.class));
Avoid too many return
statements within this method. Open
return convertValue(value, field.getType());