File SimpleController.java
has 1081 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.ext;
import java.io.BufferedReader;
/*
The MIT License
Method init
has a Cognitive Complexity of 108 (exceeds 5 allowed). Consider refactoring. Open
protected Process init() {
String outputFile = null;
String debugPort = null;
if (encodingCode != null && !encodingCode.equalsIgnoreCase(System.getProperty("file.encoding"))) {
System.setProperty("file.encoding", encodingCode);
- 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
SimpleController
has 66 methods (exceeds 20 allowed). Consider refactoring. Open
public class SimpleController implements ObjectCondition, UncaughtExceptionHandler, Runnable {
public static final String SEPARATOR = "------";
public static final String USER = "USER";
public static final String USERNAME = "USERNAME";
public static final String CLOSE = "close";
Method init
has 183 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected Process init() {
String outputFile = null;
String debugPort = null;
if (encodingCode != null && !encodingCode.equalsIgnoreCase(System.getProperty("file.encoding"))) {
System.setProperty("file.encoding", encodingCode);
Method executeProcess
has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring. Open
public static CharacterBuffer executeProcess(CharacterBuffer command, String... values) {
CharacterBuffer result = new CharacterBuffer();
if (values == null) {
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
Method withFXML
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
public SimpleController withFXML(String fxmlFile, Class<?>... fromClass) {
Class<?> path = null;
if (fromClass != null && fromClass.length > 0) {
path = fromClass[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 executeProcess
has 86 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static CharacterBuffer executeProcess(CharacterBuffer command, String... values) {
CharacterBuffer result = new CharacterBuffer();
if (values == null) {
return result;
}
Method visitPath
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public void visitPath(File file, String root, int deep, int maxDeep, String... excludes) {
if (file == null || root == null || deep > maxDeep) {
return;
}
boolean add = 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 showTrayIcon
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public Object showTrayIcon(String... labels) {
if (Os.checkSystemTray() == false) {
return null;
}
if (this.icon != null && this.icon.length() > 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 create
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public static SimpleController create(JavaBridge bridge, final ObjectCondition listener, boolean exitOnClose,
boolean wait) {
final SimpleController controller = new SimpleController(null);
final Class<?> launcherClass = ReflectionLoader.getClass("com.sun.javafx.application.LauncherImpl");
controller.withBridge(bridge);
- 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 withFXML
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
public SimpleController withFXML(String fxmlFile, Class<?>... fromClass) {
Class<?> path = null;
if (fromClass != null && fromClass.length > 0) {
path = fromClass[0];
}
Method getParameterMap
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
@SuppressWarnings("unchecked")
public SimpleKeyValueList<String, String> getParameterMap() {
SimpleKeyValueList<String, String> map = new SimpleKeyValueList<String, String>();
if (Os.isJUnitTest()) {
return map;
- 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 run
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
@Override
public void run() {
boolean showBridge = true;
if (this.runParams != null && this.runParams.length > 0) {
if (CREATING.equalsIgnoreCase(runAction)) {
- 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 showing
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
protected void showing(boolean wait) {
if (this.stage != null) {
init();
ReflectionLoader.call(this.stage, "setTitle", getTitle());
if (Os.isEclipse()) {
- 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 withIcon
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public SimpleController withIcon(String value, Class<?> relative) {
if (Os.isReflectionTest()) {
return this;
}
if (relative != 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 update
has a Cognitive Complexity of 13 (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 showing
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void showing(Object root, boolean wait, boolean newStage) {
Object oldStage = null;
if (newStage) {
oldStage = this.stage;
withStage(ReflectionLoader.newInstance(ReflectionLoader.STAGE));
Method showTrayIcon
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Object showTrayIcon(String... labels) {
if (Os.checkSystemTray() == false) {
return null;
}
if (this.icon != null && this.icon.length() > 0) {
Method visitPath
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void visitPath(File file, String root, int deep, int maxDeep, String... excludes) {
if (file == null || root == null || deep > maxDeep) {
return;
}
boolean add = false;
Method withIcon
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public SimpleController withIcon(String value, Class<?> relative) {
if (Os.isReflectionTest()) {
return this;
}
if (relative != null) {
Method showing
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private void showing(Object root, boolean wait, boolean newStage) {
Object oldStage = null;
if (newStage) {
oldStage = this.stage;
withStage(ReflectionLoader.newInstance(ReflectionLoader.STAGE));
- 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 withMap
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public SimpleController withMap(SendableEntityCreator controller, String key, Object... modelMapping) {
if (controller == null || key == null) {
return this;
}
if (mapping == 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 create
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static SimpleController create(JavaBridge bridge, final ObjectCondition listener, boolean exitOnClose,
boolean wait) {
final SimpleController controller = new SimpleController(null);
final Class<?> launcherClass = ReflectionLoader.getClass("com.sun.javafx.application.LauncherImpl");
controller.withBridge(bridge);
Method run
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void run() {
boolean showBridge = true;
if (this.runParams != null && this.runParams.length > 0) {
if (CREATING.equalsIgnoreCase(runAction)) {
Method withAgent
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public SimpleController withAgent(String agent, String backBoxTester, String... mainClass) {
this.javaAgent = agent;
CharacterBuffer testClasses = new CharacterBuffer();
if (mainClass != null) {
for (String test : mainClass) {
- 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 (controllers.contains(creator)) {
controller = creator.getSendableInstance(false);
} else {
controller = creator;
}
Method visitPath
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public void visitPath(File file, String root, int deep, int maxDeep, String... excludes) {
Avoid too many return
statements within this method. Open
return start;
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return null;
Method getUserName
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public String getUserName(String... defaultName) {
SimpleKeyValueList<String, String> parameterMap = getParameterMap();
for (int i = 0; i < parameterMap.size(); i++) {
String key = parameterMap.getKeyByIndex(i);
if (USER.equalsIgnoreCase(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
These nested if statements could be combined Open
if (modelMapping[0] != null) {
String property = null;
if (modelMapping.length > 1 && modelMapping[1] instanceof String) {
property = (String) modelMapping[1];
}
- 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 (match != null && match != this) {
match.update(evt);
}
- 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 (CLOSE.equals(evt.getId())) {
this.close();
}
- 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 (outputFile != null) {
if (outputFile.equalsIgnoreCase("inherit")) {
processBuilder.redirectErrorStream(true);
ReflectionLoader.call(processBuilder, "redirectOutput", ReflectionLoader.PROCESSBUILDERREDIRECT,
ReflectionLoader.getField(ReflectionLoader.PROCESSBUILDERREDIRECT, "INHERIT"));
- 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
}
}