Method createFromFile
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
public StoryBook createFromFile(String fileName) {
CharacterBuffer readFile = FileBuffer.readFile(fileName);
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 StoryBook.java
has 308 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.ext.story;
import de.uniks.networkparser.SendableItem;
import de.uniks.networkparser.buffer.CharacterBuffer;
import de.uniks.networkparser.ext.ClassModel;
Method writeToFile
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public boolean writeToFile(String... directory) {
String subDir = "";
if(directory != null) {
if(directory.length>0) {
subDir =directory[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 writeToFile
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
public boolean writeToFile(String... directory) {
String subDir = "";
if(directory != null) {
if(directory.length>0) {
subDir =directory[0];
StoryBook
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
public class StoryBook extends SendableItem implements SendableEntityCreator {
public static final String PROPERTY_STORIES = "stories";
public static final String PROPERTY_PART = "part";
public static final String[] properties = new String[] { PROPERTY_PART, PROPERTY_STORIES };
Method createFromFile
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public StoryBook createFromFile(String fileName) {
CharacterBuffer readFile = FileBuffer.readFile(fileName);
SimpleList<String> lines = readFile.splitStrings('\n');
if (lines.size() < 1) {
return null;
Method getClassModel
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public ClassModel getClassModel(String packageName) {
ClassModel classModel = new ClassModel(packageName);
for(StoryElement element :this.children) {
if(element instanceof Story) {
Story subStory = (Story) element;
- 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 withPart
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public StoryBook withPart(Line... value) {
if (value == null) {
return this;
}
for (Line item : value) {
- 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 deeply nested control flow statements. Open
if(type != null) {
cucumber.withText(type, sub.toString());
}
Method withStory
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public StoryBook withStory(Story... value) {
if (value == null) {
return this;
}
for (Story item : value) {
- 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 withTask
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public StoryBook withTask(Task... value) {
if (value == null) {
return this;
}
for (Task item : value) {
- 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 withoutPart
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public StoryBook withoutPart(Line... values) {
if (values != null) {
for (Line item : values) {
if (this.part != null && item != null) {
this.part.remove(item);
- 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 withoutTask
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public StoryBook withoutTask(Task... values) {
if (values != null) {
for (Task item : values) {
if (item != null) {
this.children.remove((Object) item);
- 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 modifying an outer loop incrementer in an inner loop for update expression Open
for(i++;i<lines.size();i++) {
line = lines.get(i).trim();
if(line.length()<1) {
continue;
}
- Read upRead up
- Exclude checks
JumbledIncrementer
Since: PMD 1.0
Priority: Medium
Categories: Style
Remediation Points: 50000
Avoid jumbled loop incrementers - its usually a mistake, and is confusing even if intentional.
Example:
public class JumbledIncrementerRule1 {
public void foo() {
for (int i = 0; i < 10; i++) { // only references 'i'
for (int k = 0; k < 20; i++) { // references both 'i' and 'k'
System.out.println('Hello');
}
}
}
}