File ReflectionLoader.java
has 939 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.ext.generic;
import java.io.DataInputStream;
/*
The MIT License
Method calling
has a Cognitive Complexity of 81 (exceeds 5 allowed). Consider refactoring. Open
public static Object calling(Object item, String methodName, boolean notify, Object notifyObject,
Object... arguments) {
if (methodName == null || item == 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 newInstanceSimple
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring. Open
public static Object newInstanceSimple(Class<?> instance, String... ignoreCreateMethods) {
if (instance == null) {
return null;
}
if (ignoreCreateMethods != 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 calling
has 125 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static Object calling(Object item, String methodName, boolean notify, Object notifyObject,
Object... arguments) {
if (methodName == null || item == null) {
return null;
}
Method newInstance
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
public static Object newInstance(boolean showError, Class<?> instance, Object... arguments) {
if (instance == null) {
return null;
}
if (instance.isInterface()) {
- 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 getField
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public static Object getField(Object item, String... fieldNames) {
if (item == null) {
return null;
}
Class<?> className = 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
ReflectionLoader
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
public class ReflectionLoader {
public static PrintStream logger = null;
private static int errorCount;
public static final Class<?> CHANGELISTENER;
public static final Class<?> NODE;
Method checkDirectory
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
private static void checkDirectory(File directory, String pckgname, SimpleList<Class<?>> classes)
throws ClassNotFoundException {
File tmpDirectory;
if (directory != null && directory.exists() && directory.isDirectory()) {
String[] files = directory.list();
- 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 newInstanceSimple
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static Object newInstanceSimple(Class<?> instance, String... ignoreCreateMethods) {
if (instance == null) {
return null;
}
if (ignoreCreateMethods != null) {
Method newInstance
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static Object newInstance(boolean showError, Class<?> instance, Object... arguments) {
if (instance == null) {
return null;
}
if (instance.isInterface()) {
Method getField
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static Object getField(Object item, String... fieldNames) {
if (item == null) {
return null;
}
Class<?> className = null;
Method callChainExt
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static Object callChainExt(Object item, Object... methodNames) {
if (methodNames == null) {
return null;
}
int i = 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 callChainExt
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static Object callChainExt(Object item, Object... methodNames) {
if (methodNames == null) {
return null;
}
int i = 0;
Method setField
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static boolean setField(String fieldName, Object item, Object value) {
if (item == null) {
return false;
}
Class<?> className = null;
Method printAPI
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static CharacterBuffer printAPI(Object item) {
CharacterBuffer sb = new CharacterBuffer();
if (item == null) {
return sb;
}
- 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 closeThreads
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static final Set<Thread> closeThreads(Set<Thread> oldThreads) {
Set<Thread> newThreads = Thread.getAllStackTraces().keySet();
if (oldThreads != null && oldThreads.size() != newThreads.size()) {
for (Thread newThread : newThreads) {
if (oldThreads.contains(newThread)) {
- 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 printAPI
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static CharacterBuffer printAPI(Object item) {
CharacterBuffer sb = new CharacterBuffer();
if (item == null) {
return sb;
}
Method newInstanceStr
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static Object newInstanceStr(String className, Object... arguments) {
if (className == null) {
return null;
}
try {
- 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 setField
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static boolean setField(String fieldName, Object item, Object value) {
if (item == null) {
return false;
}
Class<?> className = 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 checkValue
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private static boolean checkValue(Object[] arguments) {
if (arguments == null) {
return false;
}
for (int i = 0; i < arguments.length; i += 2) {
- 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 getClassesForPackage
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static SimpleList<Class<?>> getClassesForPackage(String pckgname) {
if (pckgname == null) {
return null;
}
SimpleList<Class<?>> classes = new SimpleList<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 callStr
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static Object callStr(Object item, String methodName, Object... arguments) {
try {
if (arguments != null && arguments.length % 2 == 0) {
for (int i = 0; i < arguments.length; i += 2) {
if (arguments[i] instanceof String) {
- 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 calling
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static Object calling(Object item, String methodName, boolean notify, Object notifyObject,
Object... arguments) {
Avoid too many return
statements within this method. Open
return new DataInputStream(new StringInputStream());
Avoid too many return
statements within this method. Open
return newInstance;
Avoid too many return
statements within this method. Open
return method.invoke(item, methodArgumentsValues);
Avoid too many return
statements within this method. Open
return newInstance;
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 null;
Avoid too many return
statements within this method. Open
return ReflectionLoader.newInstance(instance);
Avoid too many return
statements within this method. Open
return result;
Avoid too many return
statements within this method. Open
return constructor.newInstance(methodArgumentsValues);
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return null;
Method isAccessMethod
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static boolean isAccessMethod(Object item, String methodName) {
if (item == null || methodName == null) {
return false;
}
Method method = 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
These nested if statements could be combined Open
if (con.getParameterTypes().length == 0) {
emptyConstructor = con;
break;
}
- Read upRead up
- Exclude checks
CollapsibleIfStatements
Since: PMD 3.1
Priority: Medium
Categories: Style
Remediation Points: 50000
Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.
Example:
void bar() {
if (x) { // original implementation
if (y) {
// do stuff
}
}
}
void bar() {
if (x && y) { // optimized implementation
// do stuff
}
}
These nested if statements could be combined Open
if (arguments[i + 1].getClass().isAssignableFrom((Class<?>) arguments[i]) == false) {
return false;
}
- Read upRead up
- Exclude checks
CollapsibleIfStatements
Since: PMD 3.1
Priority: Medium
Categories: Style
Remediation Points: 50000
Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.
Example:
void bar() {
if (x) { // original implementation
if (y) {
// do stuff
}
}
}
void bar() {
if (x && y) { // optimized implementation
// do stuff
}
}
These nested if statements could be combined Open
if (methodName != null && methodName.length() > 0) {
method = itemClass.getMethod(methodName, new Class[0]);
}
- Read upRead up
- Exclude checks
CollapsibleIfStatements
Since: PMD 3.1
Priority: Medium
Categories: Style
Remediation Points: 50000
Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.
Example:
void bar() {
if (x) { // original implementation
if (y) {
// do stuff
}
}
}
void bar() {
if (x && y) { // optimized implementation
// do stuff
}
}