Method toString
has a Cognitive Complexity of 95 (exceeds 5 allowed). Consider refactoring. Open
@Override
public String toString() {
SourceCode code = getCode();
if (this.size() < 1) {
if (code != 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 toString
has 101 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public String toString() {
SourceCode code = getCode();
if (this.size() < 1) {
if (code != null) {
File TemplateResultFile.java
has 304 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.parser;
import de.uniks.networkparser.EntityUtil;
/*
The MIT License
TemplateResultFile
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
public class TemplateResultFile extends SortedSet<TemplateResultFragment>
implements SendableEntityCreator, LocalisationInterface {
public static final String PROPERTY_PARENT = "parent";
public static final String PROPERTY_CHILD = "child";
public static final String PROPERTY_MEMBER = "member";
Method getValue
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
@Override
public Object getValue(Object entity, String attribute) {
if (entity instanceof TemplateResultFile == false) {
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 getValue
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public Object getValue(Object entity, String attribute) {
if (entity instanceof TemplateResultFile == false) {
return null;
}
Avoid deeply nested control flow statements. Open
if (symbolEntry == null) {
int pos = code.getEndOfBody();
sb.replace(pos, pos, fragment.getValue().toString());
}
Avoid too many return
statements within this method. Open
return headers;
Avoid too many return
statements within this method. Open
return member;
Avoid too many return
statements within this method. Open
return null;
FIXME found Open
/* FIXME FOR NON COMPARATOR */
- Exclude checks
TODO found Open
/* TODO DONT ADD CORRECTLY ADD */
- Exclude checks
These nested if statements could be combined Open
if (entry.getName().equals(fragment.getMember().getName())) {
part = fragment;
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 (code != null) {
String codeString = code.toString();
if (codeString != null && codeString.length() > 0) {
return code.toString();
}
- 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
}
}