Method addHistory
has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring. Open
public boolean addHistory(ModelChange value) {
boolean success = true;
ModelChange historyChange = history.ceiling(value, true);
while (success && historyChange != 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 ModelHistory.java
has 460 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.ext.petaf;
/*
The MIT License
ModelHistory
has 37 methods (exceeds 20 allowed). Consider refactoring. Open
public class ModelHistory implements ObjectCondition {
public static final String PROPERTY_HISTORY = "history";
public static final String PROPERTY_LASTMODELCHANGE = "lastmodelchange";
public static final String PROPERTY_CHANGES = "changes";
Method refactoringHistory
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
public boolean refactoringHistory() {
SortedSet<NodeProxy> nodes = getSpace().getNodeProxies();
SimpleList<String> keys = new SimpleList<String>();
for (NodeProxy proxy : nodes) {
String key = proxy.getHistory();
Method refactoringHistory
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public boolean refactoringHistory() {
SortedSet<NodeProxy> nodes = getSpace().getNodeProxies();
SimpleList<String> keys = new SimpleList<String>();
for (NodeProxy proxy : nodes) {
String key = proxy.getHistory();
- 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 addHistory
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
public boolean addHistory(ModelChange value) {
boolean success = true;
ModelChange historyChange = history.ceiling(value, true);
while (success && historyChange != null) {
Method back
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public ModelHistory back(Object target, String property) {
while (true) {
back();
if (currentStep <= 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 back
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public ModelHistory back() {
if (currentStep <= 0) {
/* already at start */
return this;
}
Method back
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public ModelHistory back(Object target) {
while (true) {
back();
if (currentStep <= 0) {
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
Method back
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public ModelHistory back() {
if (currentStep <= 0) {
/* already at start */
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 deeply nested control flow statements. Open
if (createrClass.getValue(target, fieldName) instanceof Collection<?>) {
/* same kid object? */
Entity historyKid = getObject(historyPropsObject, fieldName);
if (historyKid == null) {
success = false; /* should not happen */
Avoid deeply nested control flow statements. Open
if (target == null) {
return false; /* this should not happen */
}
TODO found Open
/* TODO OLD METHOD WITH NUMERIC-CHANGES */
- Exclude checks
These nested if statements could be combined Open
if (space != null) {
space.error(this, "addHistory", "ERROR");
}
- 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
}
}