fujaba/NetworkParser

View on GitHub
src/main/java/de/uniks/networkparser/ext/ErrorHandler.java

Summary

Maintainability
D
1 day
Test Coverage

File ErrorHandler.java has 331 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package de.uniks.networkparser.ext;

/*
The MIT License

Severity: Minor
Found in src/main/java/de/uniks/networkparser/ext/ErrorHandler.java - About 3 hrs to fix

    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();
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/ext/ErrorHandler.java - About 2 hrs to fix

      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) {
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/ext/ErrorHandler.java - About 2 hrs to fix

        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) {
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/ext/ErrorHandler.java - About 1 hr to fix

        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) {
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/ext/ErrorHandler.java - About 1 hr to fix

        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) {
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/ext/ErrorHandler.java - About 1 hr to fix

          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) {
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/ext/ErrorHandler.java - About 1 hr to fix

            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;
                    }
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/ErrorHandler.java - About 1 hr to fix

              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) {
              Severity: Minor
              Found in src/main/java/de/uniks/networkparser/ext/ErrorHandler.java - About 35 mins to fix

              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;
              Severity: Major
              Found in src/main/java/de/uniks/networkparser/ext/ErrorHandler.java - About 30 mins to fix

                These nested if statements could be combined
                Open

                                if (file.createNewFile() == false) {
                                    return false;
                                }

                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;
                            }

                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
                 }
                }

                There are no issues that match your filters.

                Category
                Status