Method coerce
has a Cognitive Complexity of 125 (exceeds 5 allowed). Consider refactoring. Open
public static Object coerce(Class<?> cls, Object val)
throws ClassCastException {
if (cls.isInstance(val))
return val;
- 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 Classes.java
has 1005 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* Classes.java
Purpose: Utilities to handle Class
Description:
Method coerce
has 163 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static Object coerce(Class<?> cls, Object val)
throws ClassCastException {
if (cls.isInstance(val))
return val;
Classes
has 45 methods (exceeds 20 allowed). Consider refactoring. Open
public class Classes {
private static final Logger log = LoggerFactory.getLogger(Classes.class);
private static final Object NOT_FOUND = new Object();
Method myGetCloseMethod
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
private static final
Method myGetCloseMethod(final Class<?> cls, final String name,
final Class<?>[] argTypes, final boolean bySubclass)
throws NoSuchMethodException {
// assert argTypes != null: "Caller shall handle 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 matched
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
private static boolean matched(Class[] types, Object[] args, boolean loosely) {
if (types.length == args.length) {
final Object[] argcvt = loosely ? new Object[args.length]: args;
boolean cvted = false;
for (int k = args.length;;) {
- 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 myGetCloseMethods
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
private static final Method[]
myGetCloseMethods(final Class<?> cls, final String name,
final Class<?>[] argTypes, final boolean bySubclass) {
// assert argTypes != null: "Caller shall handle null";
final List<Method> mtds = new LinkedList<Method>();
- 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 myGetAcsObj
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
private static final AccessibleObject
myGetAcsObj(Class<?> cls, String name, Class<?>[] argTypes, int flags)
throws NoSuchMethodException {
//try public set/get
final String decoratedName =
- 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 looselyCast
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
private static Object looselyCast(Class type, Object arg) {
if (type == Integer.class || type == int.class) {
if (arg instanceof Number)
return ((Number) arg).intValue();
} else if (type == Long.class || type == long.class) {
- 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 coerce
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public static Object coerce(Class<?> cls, Object val, boolean nullable)
throws ClassCastException {
if (nullable || val != null)
return coerce(cls, val);
- 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 parseMethod
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public static final MethodInfo parseMethod(String signature)
throws IllegalSyntaxException {
int len = signature.length();
int j = Strings.skipWhitespaces(signature, 0);
int k = Strings.anyOf(signature, "( \t\n\r", j);
- 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 parseMethod
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static final MethodInfo parseMethod(String signature)
throws IllegalSyntaxException {
int len = signature.length();
int j = Strings.skipWhitespaces(signature, 0);
int k = Strings.anyOf(signature, "( \t\n\r", j);
Method myGetAcsObj
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static final AccessibleObject
myGetAcsObj(Class<?> cls, String name, Class<?>[] argTypes, int flags)
throws NoSuchMethodException {
//try public set/get
final String decoratedName =
Method toInternalForm
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public static final String toInternalForm(String clsName) {
final int k = clsName.indexOf('[');
if (k <= 0) { //not an array, or already in internal form
return clsName; //just return
}
- 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 getSuperClasses
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static final Class<?>[] getSuperClasses(Class<?> cls, Class<?>[] clsToCheck) {
if (clsToCheck!=null) {
int[] hits = new int[clsToCheck.length];
int no = 0;
for (int j=0; j<clsToCheck.length; ++j)
- 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 myGetCloseMethod
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static final
Method myGetCloseMethod(final Class<?> cls, final String name,
final Class<?>[] argTypes, final boolean bySubclass)
throws NoSuchMethodException {
// assert argTypes != null: "Caller shall handle null";
Method equals
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof AOInfo))
return false;
- 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 myGetCloseMethods
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static final Method[]
myGetCloseMethods(final Class<?> cls, final String name,
final Class<?>[] argTypes, final boolean bySubclass) {
// assert argTypes != null: "Caller shall handle null";
final List<Method> mtds = new LinkedList<Method>();
Method coerce
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static Object coerce(Class<?> cls, Object val, boolean nullable)
throws ClassCastException {
if (nullable || val != null)
return coerce(cls, val);
Method toInternalForm
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static final String toInternalForm(String clsName) {
final int k = clsName.indexOf('[');
if (k <= 0) { //not an array, or already in internal form
return clsName; //just return
}
Method toAttributeName
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static final String toAttributeName(String methodName) {
int len = methodName.length();
if (len < 2)
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 toAttributeName
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static final String toAttributeName(String methodName) {
int len = methodName.length();
if (len < 2)
return null;
Method matched
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static boolean matched(Class[] types, Object[] args, boolean loosely) {
if (types.length == args.length) {
final Object[] argcvt = loosely ? new Object[args.length]: args;
boolean cvted = false;
for (int k = args.length;;) {
Method getAnyMethod
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static final Method
getAnyMethod(Class<?> cls, String name, Class<?>[] argTypes)
throws NoSuchMethodException {
try {
return cls.getDeclaredMethod(name, argTypes);
- 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 getMethodInPublic
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static final Method
getMethodInPublic(Class<?> cls, String name, Class<?>[] argTypes)
throws NoSuchMethodException {
final Method m = cls.getMethod(name, argTypes);
if (Modifier.isPublic(m.getDeclaringClass().getModifiers()))
- 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 getTopmostInterface
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static Class<?> getTopmostInterface(Class<?> cls, Class<?> subIF) {
if (cls.isInterface())
return subIF.isAssignableFrom(cls) ? cls: null;
while (cls != 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 isAttribute
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static final boolean isAttribute(String methodName) {
int len = methodName.length();
if (len < 2)
return false;
- 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 match
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private static
Method match(Class<?> cls, String name, Object[] args, boolean loosely) {
final Method[] ms = cls.getMethods();
for (int j = 0; j < ms.length; ++j) {
if (!ms[j].getName().equals(name)
- 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 getClassOfSignature
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static final
Class getClassOfSignature(ClassResolver resolver, String clsnm)
throws ClassNotFoundException {
try {
return resolver != 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
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return new Byte((String)val);
Avoid too many return
statements within this method. Open
return new Float(((Number)val).floatValue());
Avoid too many return
statements within this method. Open
return ((Number) arg).longValue();
Avoid too many return
statements within this method. Open
return j==len || Character.isUpperCase(methodName.charAt(j));
Avoid too many return
statements within this method. Open
return new BigDecimal((String)val);
Avoid too many return
statements within this method. Open
return val;
Avoid too many return
statements within this method. Open
return null; //not castable
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return cls.getField(name);
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return new Character((char)((Number)val).shortValue());
Avoid too many return
statements within this method. Open
return new Float(((Date)val).getTime());
Avoid too many return
statements within this method. Open
return Byte.class == cls ? null: Objects.ZERO_BYTE;
Avoid too many return
statements within this method. Open
return Short.class == cls ? null: Objects.ZERO_SHORT;
Avoid too many return
statements within this method. Open
return BigIntegers.toBigInteger((Integer)val);
Avoid too many return
statements within this method. Open
return new Float((String)val);
Avoid too many return
statements within this method. Open
return Long.valueOf((String) val);
Avoid too many return
statements within this method. Open
return new String(buf);
Avoid too many return
statements within this method. Open
return new Byte(((Number)val).byteValue());
Avoid too many return
statements within this method. Open
return Long.class == cls ? null: Objects.ZERO_LONG;
Avoid too many return
statements within this method. Open
return ((Number) arg).intValue();
Avoid too many return
statements within this method. Open
return getAnyMethod(cls, name, argTypes);
Avoid too many return
statements within this method. Open
return getAnyMethod(cls, isMethodName, argTypes);
Avoid too many return
statements within this method. Open
return Float.class == cls ? null: Objects.ZERO_FLOAT;
Avoid too many return
statements within this method. Open
return val;
Avoid too many return
statements within this method. Open
return ((Number) val).shortValue();
Avoid too many return
statements within this method. Open
return new BigInteger((String)val);
Avoid too many return
statements within this method. Open
return getAnyField(cls, name);
Avoid too many return
statements within this method. Open
return val;
Avoid too many return
statements within this method. Open
return Double.class == cls ? null: Objects.ZERO_DOUBLE;
Avoid too many return
statements within this method. Open
return s.length() > 0 ? new Character(s.charAt(0)): Objects.NULL_CHARACTER;
Avoid too many return
statements within this method. Open
return BigIntegers.toBigInteger((Byte)val);
Avoid too many return
statements within this method. Open
return new Date(((Number)val).longValue());
Avoid too many return
statements within this method. Open
return Character.class == cls ? null: Objects.NULL_CHARACTER;
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return BigIntegers.toBigInteger((Short)val);
Avoid too many return
statements within this method. Open
return ((Date) val).getTime();
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return val;
Avoid too many return
statements within this method. Open
return ((Number) val).intValue();
Avoid too many return
statements within this method. Open
return new BigDecimal((BigInteger)val);
Avoid too many return
statements within this method. Open
return ((Date) val).getTime();
Avoid too many return
statements within this method. Open
return ((BigInteger) val).signum() != 0;
Avoid too many return
statements within this method. Open
return val;
Avoid too many return
statements within this method. Open
return Objects.ZERO_INTEGER;
Avoid too many return
statements within this method. Open
return Objects.ZERO_BIG_INTEGER;
Avoid too many return
statements within this method. Open
return ((Number) val).intValue() != 0;
Avoid too many return
statements within this method. Open
return new BigDecimal((String)val);
Avoid too many return
statements within this method. Open
return Objects.ZERO_BYTE;
Avoid too many return
statements within this method. Open
return ((Number) val).doubleValue();
Avoid too many return
statements within this method. Open
return ((BigDecimal) val).signum() != 0;
Avoid too many return
statements within this method. Open
return Integer.valueOf((String) val);
Avoid too many return
statements within this method. Open
return BigDecimals.toBigDecimal(((Number)val).intValue());
Avoid too many return
statements within this method. Open
return Boolean.valueOf((String)val);
Avoid too many return
statements within this method. Open
return val;
Avoid too many return
statements within this method. Open
return Boolean.TRUE; //non-null is true
Avoid too many return
statements within this method. Open
return new BigDecimal(((Date)val).getTime());
Avoid too many return
statements within this method. Open
return Objects.ZERO_DOUBLE;
Avoid too many return
statements within this method. Open
return val;
Avoid too many return
statements within this method. Open
return new BigDecimal(Double.toString((Double)val));
Avoid too many return
statements within this method. Open
return Objects.ZERO_LONG;
Avoid too many return
statements within this method. Open
return Boolean.FALSE;
Avoid too many return
statements within this method. Open
return Objects.ZERO_SHORT;
Avoid too many return
statements within this method. Open
return val;
Avoid too many return
statements within this method. Open
return BigIntegers.toBigInteger(((Date)val).getTime());
Avoid too many return
statements within this method. Open
return BigIntegers.toBigInteger(((Number)val).longValue());
Avoid too many return
statements within this method. Open
return Double.valueOf((String)val);
Avoid too many return
statements within this method. Open
return Short.valueOf((String) val);
Avoid too many return
statements within this method. Open
return Integer.class == cls ? null: Objects.ZERO_INTEGER;
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return ((Number) val).longValue();
Avoid too many return
statements within this method. Open
return Objects.ZERO_BIG_DECIMAL;
Avoid too many return
statements within this method. Open
return new BigDecimal(Float.toString((Float)val));
Avoid too many return
statements within this method. Open
return Objects.toString(val);
Avoid too many return
statements within this method. Open
return Boolean.class == cls ? null: Boolean.FALSE;
Method correctFieldName
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public final static String correctFieldName(String name) {
int j = name.indexOf('-');
if (j < 0)
return name; //nothing to change
- 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 newInstance
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static final
Object newInstance(Class<?> cls, Object[] args)
throws NoSuchMethodException, InstantiationException,
InvocationTargetException, IllegalAccessException {
if (args == null || args.length == 0)
- 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 getAnyField
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static final Field getAnyField(Class<?> cls, String name)
throws NoSuchFieldException {
for (;;) {
try {
return cls.getDeclaredField(name);
- 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 isNumeric
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static final boolean isNumeric(Class<?> cls, boolean extend) {
if (cls.isPrimitive())
return extend ||
(!cls.equals(char.class) && !cls.equals(boolean.class));
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
} else if (Double.class == cls || double.class == cls) {
if (val == null) {
return Double.class == cls ? null: Objects.ZERO_DOUBLE;
} else if (val instanceof Double) { //double.class
return val;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 94.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
} else if (Long.class == cls || long.class == cls) {
if (val == null) {
return Long.class == cls ? null: Objects.ZERO_LONG;
} else if (val instanceof Long) { //long.class
return val;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 94.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
} else if (Integer.class == cls || int.class == cls) {
if (val == null) {
return Integer.class == cls ? null: Objects.ZERO_INTEGER;
} else if (val instanceof Integer) { //int.class
return val;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 76.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
} else if (Short.class == cls || short.class == cls) {
if (val == null) {
return Short.class == cls ? null: Objects.ZERO_SHORT;
} else if (val instanceof Short) { //short.class
return val;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 76.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
protected MethodInfo(String r, String m, String[] argTs, String[] argNs, String tEx) {
returnType = r;
method = m;
argTypes = argTs;
argNames = argNs;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 50.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
for (int j = 0; j< clses.length; ++j)
try {
return getMethodInPublic(clses[j], name, argTypes);
} catch (NoSuchMethodException ex) { //ignore it
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 42.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
for (int j = 0; j< clses.length; ++j)
try {
return getAnyMethod(clses[j], name, argTypes);
} catch (NoSuchMethodException e2) { //ignore it
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 42.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (argType == null
|| (!bySubclass && mType.isAssignableFrom(argType))
|| (bySubclass && argType.isAssignableFrom(mType)))
continue; //match one argument
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 40.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (argType == null
|| (!bySubclass && mType.isAssignableFrom(argType))
|| (bySubclass && argType.isAssignableFrom(mType)))
continue; //match
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 40.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76