Method getElementsBy
has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring. Open
public EntityList getElementsBy(String key, String value) {
if (value == null) {
return null;
}
EntityList children = getNewList(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 XMLEntity.java
has 393 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.xml;
/*
NetworkParser
The MIT License
XMLEntity
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
public class XMLEntity extends SimpleKeyValueList<String, Object> implements Entity, EntityList {
/** Constant of TAG. */
public static final String PROPERTY_TAG = "tag";
/** Constant of VALUE. */
public static final String PROPERTY_VALUE = "value";
Method getElementsBy
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
public EntityList getElementsBy(String key, String value) {
if (value == null) {
return null;
}
EntityList children = getNewList(false);
Method getValue
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public String getValue() {
if (this.valueItem == null && this.sizeChildren() > 0) {
/* Complex children */
boolean show = false;
for (int i = 0; i < this.children.size(); i++) {
- 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 toStringChildren
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
protected void toStringChildren(CharacterBuffer sb, EntityStringConverter converter) {
/* parse Children */
if (sb == null) {
return;
}
- 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 getElementBy
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public Entity getElementBy(String key, String value) {
if (value == null) {
return null;
}
if (value.equalsIgnoreCase(getString(key))) {
- 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 getElementBy
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Entity getElementBy(String key, String value) {
if (value == null) {
return null;
}
if (value.equalsIgnoreCase(getString(key))) {
Method toStringChildren
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected void toStringChildren(CharacterBuffer sb, EntityStringConverter converter) {
/* parse Children */
if (sb == null) {
return;
}
Method add
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
@Override
public boolean add(Object... values) {
if (values == null || values.length < 1) {
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 withValue
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public XMLEntity withValue(Tokener tokener, Object values) {
if (tokener != null) {
Buffer buffer = null;
if (values instanceof Buffer) {
buffer = (Buffer) values;
- 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 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public String getValue() {
if (this.valueItem == null && this.sizeChildren() > 0) {
/* Complex children */
boolean show = false;
for (int i = 0; i < this.children.size(); i++) {
Avoid too many return
statements within this method. Open
return item;
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 item;
Avoid too many return
statements within this method. Open
return children;
These nested if statements could be combined Open
if (value.equalsIgnoreCase(this.getValue())) {
return this;
}
- 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
}
}
These nested if statements could be combined Open
if (value.equalsIgnoreCase(this.getTag())) {
return this;
}
- 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
}
}
These nested if statements could be combined Open
if (((XMLEntity) item).getTag() == null) {
show = true;
break;
}
- 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
}
}