Method update
has a Cognitive Complexity of 99 (exceeds 5 allowed). Consider refactoring. Open
@Override
public boolean update(Object evt) {
if (isAtomar()) {
if (evt instanceof PropertyChangeEvent) {
return condition.update(evt);
- 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 UpdateCondition.java
has 421 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser;
import java.beans.PropertyChangeEvent;
import de.uniks.networkparser.interfaces.Entity;
Method mergeChanges
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
public Object mergeChanges() {
if (this.changes == null) {
return null;
}
Entity mergeChange = 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 changeItem
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public boolean changeItem(Object source, Object target, String property) {
if (map == null) {
return false;
}
SendableEntityCreator creator = map.getCreatorClass(source);
- 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 changeAttribute
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
private boolean changeAttribute(Object target, Object newValue, String property, SendableEntityCreator creator,
Object defaultItem) {
if (creator == null) {
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 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public boolean update(Object evt) {
if (isAtomar()) {
if (evt instanceof PropertyChangeEvent) {
return condition.update(evt);
UpdateCondition
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
public class UpdateCondition implements ObjectCondition {
private Object owner;
private ObjectCondition condition; /* FOR ATOM OR TRANSACTION */
/** FOR ACCUMULATE */
Method changeItem
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
public boolean changeItem(Object source, Object target, String property) {
if (map == null) {
return false;
}
SendableEntityCreator creator = map.getCreatorClass(source);
Method changeAttribute
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
private boolean changeAttribute(Object target, Object newValue, String property, SendableEntityCreator creator,
Object defaultItem) {
if (creator == null) {
return false;
}
Method mergeChanges
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Object mergeChanges() {
if (this.changes == null) {
return null;
}
Entity mergeChange = null;
Method changeAttribute
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public boolean changeAttribute(UpdateListener listener, Object source, SendableEntityCreator creator,
String property, Object oldValue, Object newValue) {
Avoid deeply nested control flow statements. Open
if (mergeUpdate != null) {
mergeUpdate.put(valueKey, valueValue);
}
Method addChange
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private void addChange(UpdateListener listener, Object source, SendableEntityCreator creator, String property,
Object oldValue, Object newValue) {
Avoid deeply nested control flow statements. Open
if (source.getClass() == endClass) {
if (this.condition != null) {
return this.condition.update(this.changes);
}
this.changes = null;
Method changeAttribute
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private boolean changeAttribute(Object target, Object newValue, String property, SendableEntityCreator creator,
Object defaultItem) {
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return this.condition.update(this.changes);
Avoid too many return
statements within this method. Open
return map.getKey(event.getModelValue()) == null && map.getKey(event.getNewValue()) == null;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return this.condition.update(this.changes);
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return this.condition.update(eventTransaction);
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
These nested if statements could be combined Open
if (source.getClass() == owner) {
this.changes = new SimpleSet<SimpleEvent>();
return true;
}
- 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
}
}