Column
has 45 methods (exceeds 20 allowed). Consider refactoring. Open
public class Column implements SendableEntityCreatorNoIndex, CellHandler {
public static final int AUTOWIDTH = -1;
public static final String PROPERTY_ID = "id";
Method setValue
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
@Override
public boolean setValue(Object entity, String attribute, Object value, String type) {
if (entity instanceof Column == false || attribute == 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
File Column.java
has 356 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.gui;
/*
NetworkParser
The MIT License
Method setValue
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public boolean setValue(Object entity, String attribute, Object value, String type) {
if (entity instanceof Column == false || attribute == null) {
return false;
}
Method getValue
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
@Override
public Object getValue(Object entity, String attribute) {
if (entity instanceof Column == false || attribute == null) {
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 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public Object getValue(Object entity, String attribute) {
if (entity instanceof Column == false || attribute == null) {
return null;
}
Method getValue
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public Object getValue(Object entity, SendableEntityCreator creator) {
String attrName = getAttrName();
if (attrName != null) {
if (attrName.startsWith("\"")) {
return attrName.substring(1, attrName.length() - 1);
- 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 (oldStyle.getValue(oldStyle, prop) == null) {
oldStyle.setValue(oldStyle, prop, style.getValue(style, prop), SendableEntityCreator.NEW);
}
Avoid too many return
statements within this method. Open
return that.getActiveStyle();
Avoid too many return
statements within this method. Open
return that.isResizable();
Avoid too many return
statements within this method. Open
return that.getAltAttribute();
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 that.isMovable();
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return that.getFieldTyp();
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return that.getStyle();
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 that.getDefaultText();
Avoid too many return
statements within this method. Open
return that.isVisible();
Avoid too many return
statements within this method. Open
return that.isEditable();
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 true;
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return null;
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 that.getLabel();
Avoid too many return
statements within this method. Open
return that.getBrowserId();
These nested if statements could be combined Open
if (entity != null) {
return entity.getClass().getSimpleName();
}
- 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
}
}