Method main
has a Cognitive Complexity of 147 (exceeds 5 allowed). Consider refactoring. Open
public static void main(String[] args) {
NetworkParserLog logger = new NetworkParserLog().withListener(new StringPrintStream());
if (args != null && args.length > 0 && args[0] != null) {
if (GitRevision.MAINTAG.equalsIgnoreCase(args[0])) {
GitRevision revision = new GitRevision();
- 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 DiagramEditor.java
has 847 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.ext;
/*
The MIT License
Method main
has 184 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static void main(String[] args) {
NetworkParserLog logger = new NetworkParserLog().withListener(new StringPrintStream());
if (args != null && args.length > 0 && args[0] != null) {
if (GitRevision.MAINTAG.equalsIgnoreCase(args[0])) {
GitRevision revision = new GitRevision();
Method edobs
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
public static DiagramEditor edobs(boolean all, Object... items) {
if (items == null) {
return null;
}
if (editor == 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
DiagramEditor
has 40 methods (exceeds 20 allowed). Consider refactoring. Open
public class DiagramEditor extends JavaAdapter implements ObjectCondition, Converter {
private static final String FILE404 = "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n<html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL was not found on this server.</p></body></html>";
private static final String METHOD_GENERATE = "generating";
private SimpleController controller;
private Object logic;
Method update
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
@Override
public boolean update(Object value) {
if (value == 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 edobs
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static DiagramEditor edobs(boolean all, Object... items) {
if (items == null) {
return null;
}
if (editor == null) {
Method onDragDropped
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
protected boolean onDragDropped(Object event) {
List<File> files = getFiles(event);
if (files != null) {
for (File file : files) {
StringBuilder sb = new StringBuilder();
- 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 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public boolean update(Object value) {
if (value == null) {
return false;
}
Method executeWebServer
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public boolean executeWebServer(Message msg) {
String request = msg.getMessage().toString();
if (request.startsWith("GET")) {
CharacterBuffer path = new CharacterBuffer();
for (int i = 4; i < request.length(); 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 converting
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static boolean converting(final DiagramEditor editor, final Object entity, final String file,
final boolean wait, final boolean autoClose, int... dimension) {
final int width, height;
final DiagramEditor editorWindow;
if (editor == null) {
Method converting
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static boolean converting(final DiagramEditor editor, final Object entity, final String file,
final boolean wait, final boolean autoClose, int... dimension) {
final int width, height;
final DiagramEditor editorWindow;
if (editor == 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 onDragDropped
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected boolean onDragDropped(Object event) {
List<File> files = getFiles(event);
if (files != null) {
for (File file : files) {
StringBuilder sb = new StringBuilder();
Method creating
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected DiagramEditor creating(Object stage, Object url, int width, int height) {
if (stage == null) {
return this;
}
if (this.controller == null) {
Method load
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public boolean load(Object item) {
boolean result = super.load(item);
if (result) {
return result;
}
Method executeWebServer
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public boolean executeWebServer(Message msg) {
String request = msg.getMessage().toString();
if (request.startsWith("GET")) {
CharacterBuffer path = new CharacterBuffer();
for (int i = 4; i < request.length(); i++) {
Method onDragOver
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected boolean onDragOver(Object event) {
List<File> files = getFiles(event);
if (files != null) {
boolean error = true;
for (File file : files) {
- 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 export
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public void export(String type, Object value, String name, String context) {
if (this.controller == null) {
return;
}
String typeName = "files";
- 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 addGraphType
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static void addGraphType(Buffer resourceHandler, HTMLEntity entity) {
if(entity == null) {
return;
}
if(resourceHandler == 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 load
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public boolean load(Object item) {
boolean result = super.load(item);
if (result) {
return result;
}
- 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 (TYPE_EDITOR.equalsIgnoreCase(type)) {
/* Load Editor */
super.executeScript("window['editor'] = new ClassEditor(\"board\");", false);
}
Avoid deeply nested control flow statements. Open
if (validator.isValidate && subExit == 0 && validator.isExistFullJar() == false) {
logger.error(null, "main", "No FatJar found");
exit = -1;
}
Method converting
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public static boolean converting(final DiagramEditor editor, final Object entity, final String file,
final boolean wait, final boolean autoClose, int... dimension) {
Avoid deeply nested control flow statements. Open
if (subExit < 0) {
exit = subExit;
logger.error(null, "main", "FatJar Error");
}
Method creating
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected DiagramEditor creating(Object stage, Object url, int width, int height) {
if (stage == null) {
return this;
}
if (this.controller == 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 generating
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public boolean generating(JsonObject model) {
if (this.listener != null) {
SimpleEvent event = new SimpleEvent(model, METHOD_GENERATE, null, null);
event.with(model);
if (this.update(event)) {
- 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 false;
Avoid too many return
statements within this method. Open
return onDragDropped(value);
Avoid too many return
statements within this method. Open
return onError(value);
Avoid too many return
statements within this method. Open
return onDragExited(value);
Method screendump
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public void screendump(String nameExtension) {
Object snapshotParametersClass = ReflectionLoader.getClass("javafx.scene.SnapshotParameters");
Object writableImageClass = ReflectionLoader.getClass("javafx.scene.image.WritableImage");
Object image = ReflectionLoader.call(webView, "snapshot", snapshotParametersClass, null, writableImageClass,
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 save
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public boolean save(Object value) {
JsonObject model;
if (value instanceof JsonObject) {
model = (JsonObject) value;
} else {
- 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 using a branching statement as the last in a loop. Open
break;
- Read upRead up
- Exclude checks
AvoidBranchingStatementAsLastInLoop
Since: PMD 5.0
Priority: Medium High
Categories: Style
Remediation Points: 50000
Using a branching statement as the last part of a loop may be a bug, and/or is confusing. Ensure that the usage is not a bug, or consider using another approach.
Example:
// unusual use of branching statement in a loop
for (int i = 0; i < 10; i++) {
if (i*i <= 25) {
continue;
}
break;
}
// this makes more sense...
for (int i = 0; i < 10; i++) {
if (i*i > 25) {
break;
}
}
These nested if statements could be combined Open
if (value instanceof String) {
FileBuffer.writeFile(file, ((String) value).getBytes());
}
- 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 (parameterMap.contains(TYPE_EXPORTALL)) {
this.type = TYPE_EXPORTALL;
}
- 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 (evt.getCode() == 123) {
enableDebug();
}
- 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 ((Boolean) ReflectionLoader.call(db, "hasFiles")) {
List<File> files = (List<File>) ReflectionLoader.call(db, "getFiles");
return files;
}
- 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 (JavaViewAdapter.STATE.equalsIgnoreCase(newValue.getClass().getName())) {
if (newValue.toString().equals(JavaViewAdapter.FAILED)) {
logger.error(this, "update", evt);
}
if (newValue.toString().equals(JavaViewAdapter.SUCCEEDED)) {
- 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
}
}