File ErrorHandler.java
has 331 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.ext;
/*
The MIT License
ErrorHandler
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
public class ErrorHandler implements Thread.UncaughtExceptionHandler {
public static final String TYPE = "ERROR";
private String path;
private Object stage;
private DateTimeEntity startDate = new DateTimeEntity();
Method saveErrorFile
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public boolean saveErrorFile(String prefix, String fileName, String filePath, Throwable e) {
boolean success;
try {
File file = getFileName(filePath, prefix, fileName);
if (file == null) {
Method writeOutput
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public boolean writeOutput(String output, boolean error) {
String fullFileName = "";
if (this.path != null) {
fullFileName = this.path;
if (fullFileName.length() > 0 && fullFileName.endsWith("/") == 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 getFileName
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public File getFileName(String filepath, String prefix, String fileName) throws IOException {
if (filepath == null) {
return null;
}
if (fileName == 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 getFileName
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public File getFileName(String filepath, String prefix, String fileName) throws IOException {
if (filepath == null) {
return null;
}
if (fileName == null) {
Method writeOutput
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public boolean writeOutput(String output, boolean error) {
String fullFileName = "";
if (this.path != null) {
fullFileName = this.path;
if (fullFileName.length() > 0 && fullFileName.endsWith("/") == false) {
Method saveScreenShoot
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Exception saveScreenShoot(String prefix, String fileName, String filePath, Object currentStage) {
/* Save Screenshot */
if (currentStage == null) {
currentStage = stage;
}
Method printSubTrace
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static void printSubTrace(PrintStream ps, String prefix, int index, Throwable e) {
if (prefix == null) {
return;
}
if (prefix.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
Avoid too many return
statements within this method. Open
return file;
These nested if statements could be combined Open
if (file.createNewFile() == false) {
return false;
}
- 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 (file.createNewFile() == false) {
return 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
}
}