File HTMLEntity.java
has 603 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.xml;
import java.net.URL;
import java.util.Iterator;
import java.util.List;
HTMLEntity
has 49 methods (exceeds 20 allowed). Consider refactoring. Open
public class HTMLEntity implements BaseItem {
public static final String PROPERTY_HEADER = "head";
public static final String PROPERTY_BODY = "body";
public static final String IMAGEFORMAT = " .bmp .jpg .jpeg .png .gif .svg ";
public static final String SCRIPT = "script";
Method add
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
@Override
public boolean add(Object... values) {
if (values == 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 withoutHeader
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
public HTMLEntity withoutHeader(String string) {
if (header != null && string != null) {
String ext = null;
int pos = string.lastIndexOf(".");
if (pos > 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 add
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public boolean add(Object... values) {
if (values == null) {
return false;
}
Method withGraph
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public HTMLEntity withGraph(String graph, String path, String editor) {
XMLEntity script = new XMLEntity().withType(SCRIPT).withKeyValue("type", "text/javascript");
StringBuilder sb = new StringBuilder();
sb.append("var json=");
sb.append(graph);
- 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 getElementsBy
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public XMLEntity getElementsBy(String key, String value) {
XMLEntity item = new XMLEntity();
EntityList headerList = this.header.getElementsBy(key, value);
EntityList bodyList = this.body.getElementsBy(key, value);
int z;
- 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 getHeader
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public XMLEntity getHeader(String url) {
if (url == null) {
return null;
}
for (int i = 0; i < this.header.sizeChildren(); 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 withGraph
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public HTMLEntity withGraph(String graph, String path, String editor) {
XMLEntity script = new XMLEntity().withType(SCRIPT).withKeyValue("type", "text/javascript");
StringBuilder sb = new StringBuilder();
sb.append("var json=");
sb.append(graph);
Method withGraph
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public HTMLEntity withGraph(GraphModel value) {
URL resource = GraphList.class.getResource("");
if (resource == null || value == null) {
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 withoutHeader
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public HTMLEntity withoutHeader(String string) {
if (header != null && string != null) {
String ext = null;
int pos = string.lastIndexOf(".");
if (pos > 0) {
Method createBodyTag
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public XMLEntity createBodyTag(String tag, String... values) {
if (tag == null) {
return null;
}
String[] tags = tag.split("\\.");
- 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 createScript
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public XMLEntity createScript(String value, XMLEntity parentNode) {
XMLEntity node = new XMLEntity().withType(SCRIPT).withKeyValue("language", "Javascript");
if (value == null) {
return node;
}
- 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 withScript
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public HTMLEntity withScript(XMLEntity parentNode, CharSequence... values) {
if (values != null) {
CharacterBuffer content = new CharacterBuffer();
if (values.length > 0) {
content.with(values[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 createTag
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public XMLEntity createTag(String tag, XMLEntity... parentNode) {
XMLEntity parentElement = null;
if (parentNode != null && parentNode.length > 0) {
parentElement = parentNode[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 withValue
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public HTMLEntity withValue(String value) {
XMLEntity htmlPage = new XMLEntity().withValue(value);
/* All Children possible head and body */
for (int i = 0; i < htmlPage.sizeChildren(); i++) {
BaseItem item = htmlPage.getChild(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 getChild
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
XMLEntity getChild(String ref) {
XMLEntity child = null;
if (ref == 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 addStyle
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public HTMLEntity addStyle(String name, String style) {
XMLEntity styleElement = null;
for (int i = 0; i < header.size(); i++) {
BaseItem child = header.getChild(i);
if (child instanceof XMLEntity == 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
These nested if statements could be combined Open
if(GraphUtil.isGenerate(item)) {
return withGraph(value, null);
}
- 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
}
}