Style
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
public class Style implements Cloneable, SendableEntityCreatorNoIndex {
/** The Constant PROPERTY_NAME for Name of Style */
public static final String PROPERTY_NAME = "name";
private String name;
File Style.java
has 295 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser;
/*
NetworkParser
The MIT License
Method setValue
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public boolean setValue(Object entity, String attribute, Object value, String type) {
if (entity instanceof Style == false) {
return false;
}
Method getValue
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
@Override
public Object getValue(Object entity, String attrName) {
String attribute;
if (attrName == null || entity instanceof Style == 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 getValue
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public Object getValue(Object entity, String attrName) {
String attribute;
if (attrName == null || entity instanceof Style == false) {
return false;
Method setValue
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
@Override
public boolean setValue(Object entity, String attribute, Object value, String type) {
if (entity instanceof Style == 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 setBorder
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public void setBorder(GUIPosition position, String width, String color) {
GUILine border = this.borders.get(position);
if (width != null) {
if (border == null) {
this.borders.put(position, new GUILine().withColor(color).withWidth(width));
- 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 style.getForground();
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 style.getFontSize();
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return style.getBackground();
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return style.isUnderline();
Avoid too many return
statements within this method. Open
return style.getWidth();
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return style.getHeight();
Avoid too many return
statements within this method. Open
return style.getName();
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return style.getAlignment();
These nested if statements could be combined Open
if (border.isCustomLine() == false) {
this.borders.remove(position);
this.propertyChange(PROPERTY_BORDER, null, this.borders);
}
- 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
}
}