Method createFromFile
has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring. Open
public static Cucumber createFromFile(String file) {
CharacterBuffer readFile = FileBuffer.readFile(file);
SimpleList<String> lines = readFile.splitStrings('\n');
if (lines.size() < 1) {
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
File Cucumber.java
has 415 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.ext.story;
import de.uniks.networkparser.SimpleEvent;
import de.uniks.networkparser.buffer.CharacterBuffer;
import de.uniks.networkparser.ext.ClassModel;
Cucumber
has 35 methods (exceeds 20 allowed). Consider refactoring. Open
public class Cucumber implements ObjectCondition {
public static final String TYPE_SCENARIO = "scenario";
public static final String TYPE_TITLE = "title";
public static final String TYPE_GIVEN = "given";
public static final String TYPE_WHEN = "when";
Method createFromFile
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static Cucumber createFromFile(String file) {
CharacterBuffer readFile = FileBuffer.readFile(file);
SimpleList<String> lines = readFile.splitStrings('\n');
if (lines.size() < 1) {
return null;
Method update
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
@Override
public boolean update(Object value) {
if(value instanceof SimpleEvent == false) {
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 update
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public boolean update(Object value) {
if(value instanceof SimpleEvent == false) {
return false;
}
Method getDictionary
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public String getDictionary(String id) {
if (id == null) {
return id;
}
if (this.parent != 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 analyse
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public boolean analyse() {
for (ObjectCondition rule : rules) {
if (rule.update(this) == false) {
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 getDictionary
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public String getDictionary(String id) {
if (id == null) {
return id;
}
if (this.parent != null) {
Method analyse
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public boolean analyse() {
for (ObjectCondition rule : rules) {
if (rule.update(this) == false) {
return false;
}
Method withText
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public Cucumber withText(String type, String text) {
if(TYPE_TITLE.equalsIgnoreCase(type)) {
this.withTitle(text);
return this;
}
- 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 TYPE_DEFINITION;
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return this;
Avoid too many return
statements within this method. Open
return true;
These nested if statements could be combined Open
if (id.endsWith("s")) {
id = id.substring(0, id.length() - 1);
}
- 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
}
}