fujaba/NetworkParser

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

Summary

Maintainability
F
1 wk
Test Coverage

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
Severity: Major
Found in src/main/java/de/uniks/networkparser/ext/SimpleController.java - About 2 days to fix

    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);
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/ext/SimpleController.java - About 2 days 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

    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";
    Severity: Major
    Found in src/main/java/de/uniks/networkparser/ext/SimpleController.java - About 1 day to fix

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

        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;
                }
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/ext/SimpleController.java - About 6 hrs 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 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];
                }
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/ext/SimpleController.java - About 5 hrs 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 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;
                }
        Severity: Major
        Found in src/main/java/de/uniks/networkparser/ext/SimpleController.java - About 3 hrs to fix

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

            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;
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/SimpleController.java - About 2 hrs 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 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)) {
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/SimpleController.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 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()) {
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/SimpleController.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 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) {
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/SimpleController.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 update has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                @Override
                public boolean update(Object value) {
                    if (value == null) {
                        return false;
                    }
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/SimpleController.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 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));
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/SimpleController.java - About 1 hr to fix

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

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

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

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

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

                        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) {
                        Severity: Minor
                        Found in src/main/java/de/uniks/networkparser/ext/SimpleController.java - About 55 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 deeply nested control flow statements.
                        Open

                                                if (controllers.contains(creator)) {
                                                    controller = creator.getSendableInstance(false);
                                                } else {
                                                    controller = creator;
                                                }
                        Severity: Major
                        Found in src/main/java/de/uniks/networkparser/ext/SimpleController.java - About 45 mins to fix

                          Method visitPath has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              public void visitPath(File file, String root, int deep, int maxDeep, String... excludes) {
                          Severity: Minor
                          Found in src/main/java/de/uniks/networkparser/ext/SimpleController.java - About 35 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                                return start;
                            Severity: Major
                            Found in src/main/java/de/uniks/networkparser/ext/SimpleController.java - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                              return null;
                              Severity: Major
                              Found in src/main/java/de/uniks/networkparser/ext/SimpleController.java - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                        return null;
                                Severity: Major
                                Found in src/main/java/de/uniks/networkparser/ext/SimpleController.java - About 30 mins to fix

                                  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)) {
                                  Severity: Minor
                                  Found in src/main/java/de/uniks/networkparser/ext/SimpleController.java - About 25 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

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

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

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

                                  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"));

                                  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