fujaba/NetworkParser

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

Summary

Maintainability
F
1 wk
Test Coverage

File ReflectionLoader.java has 939 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package de.uniks.networkparser.ext.generic;

import java.io.DataInputStream;
/*
The MIT License
Severity: Major
Found in src/main/java/de/uniks/networkparser/ext/generic/ReflectionLoader.java - About 2 days to fix

    Method calling has a Cognitive Complexity of 81 (exceeds 5 allowed). Consider refactoring.
    Open

        public static Object calling(Object item, String methodName, boolean notify, Object notifyObject,
                Object... arguments) {
            if (methodName == null || item == null) {
                return null;
            }

    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 newInstanceSimple has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
    Open

        public static Object newInstanceSimple(Class<?> instance, String... ignoreCreateMethods) {
            if (instance == null) {
                return null;
            }
            if (ignoreCreateMethods != null) {

    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 calling has 125 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static Object calling(Object item, String methodName, boolean notify, Object notifyObject,
                Object... arguments) {
            if (methodName == null || item == null) {
                return null;
            }

      Method newInstance has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

          public static Object newInstance(boolean showError, Class<?> instance, Object... arguments) {
              if (instance == null) {
                  return null;
              }
              if (instance.isInterface()) {

      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 getField has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          public static Object getField(Object item, String... fieldNames) {
              if (item == null) {
                  return null;
              }
              Class<?> className = null;

      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

      ReflectionLoader has 28 methods (exceeds 20 allowed). Consider refactoring.
      Open

      public class ReflectionLoader {
          public static PrintStream logger = null;
          private static int errorCount;
          public static final Class<?> CHANGELISTENER;
          public static final Class<?> NODE;

        Method checkDirectory has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            private static void checkDirectory(File directory, String pckgname, SimpleList<Class<?>> classes)
                    throws ClassNotFoundException {
                File tmpDirectory;
                if (directory != null && directory.exists() && directory.isDirectory()) {
                    String[] files = directory.list();

        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 newInstanceSimple has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static Object newInstanceSimple(Class<?> instance, String... ignoreCreateMethods) {
                if (instance == null) {
                    return null;
                }
                if (ignoreCreateMethods != null) {

          Method newInstance has 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static Object newInstance(boolean showError, Class<?> instance, Object... arguments) {
                  if (instance == null) {
                      return null;
                  }
                  if (instance.isInterface()) {

            Method getField has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static Object getField(Object item, String... fieldNames) {
                    if (item == null) {
                        return null;
                    }
                    Class<?> className = null;

              Method callChainExt has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static Object callChainExt(Object item, Object... methodNames) {
                      if (methodNames == null) {
                          return null;
                      }
                      int i = 0;

              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 callChainExt has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static Object callChainExt(Object item, Object... methodNames) {
                      if (methodNames == null) {
                          return null;
                      }
                      int i = 0;

                Method setField has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static boolean setField(String fieldName, Object item, Object value) {
                        if (item == null) {
                            return false;
                        }
                        Class<?> className = null;

                  Method printAPI has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static CharacterBuffer printAPI(Object item) {
                          CharacterBuffer sb = new CharacterBuffer();
                          if (item == null) {
                              return sb;
                          }

                  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 closeThreads has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static final Set<Thread> closeThreads(Set<Thread> oldThreads) {
                          Set<Thread> newThreads = Thread.getAllStackTraces().keySet();
                          if (oldThreads != null && oldThreads.size() != newThreads.size()) {
                              for (Thread newThread : newThreads) {
                                  if (oldThreads.contains(newThread)) {

                  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 printAPI has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static CharacterBuffer printAPI(Object item) {
                          CharacterBuffer sb = new CharacterBuffer();
                          if (item == null) {
                              return sb;
                          }

                    Method newInstanceStr has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static Object newInstanceStr(String className, Object... arguments) {
                            if (className == null) {
                                return null;
                            }
                            try {
                    Severity: Minor
                    Found in src/main/java/de/uniks/networkparser/ext/generic/ReflectionLoader.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

                    Method setField has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static boolean setField(String fieldName, Object item, Object value) {
                            if (item == null) {
                                return false;
                            }
                            Class<?> className = null;
                    Severity: Minor
                    Found in src/main/java/de/uniks/networkparser/ext/generic/ReflectionLoader.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

                    Method checkValue has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private static boolean checkValue(Object[] arguments) {
                            if (arguments == null) {
                                return false;
                            }
                            for (int i = 0; i < arguments.length; i += 2) {
                    Severity: Minor
                    Found in src/main/java/de/uniks/networkparser/ext/generic/ReflectionLoader.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

                    Method getClassesForPackage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static SimpleList<Class<?>> getClassesForPackage(String pckgname) {
                            if (pckgname == null) {
                                return null;
                            }
                            SimpleList<Class<?>> classes = new SimpleList<Class<?>>();
                    Severity: Minor
                    Found in src/main/java/de/uniks/networkparser/ext/generic/ReflectionLoader.java - About 45 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

                    Method callStr has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static Object callStr(Object item, String methodName, Object... arguments) {
                            try {
                                if (arguments != null && arguments.length % 2 == 0) {
                                    for (int i = 0; i < arguments.length; i += 2) {
                                        if (arguments[i] instanceof String) {
                    Severity: Minor
                    Found in src/main/java/de/uniks/networkparser/ext/generic/ReflectionLoader.java - About 45 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

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

                        public static Object calling(Object item, String methodName, boolean notify, Object notifyObject,
                                Object... arguments) {
                    Severity: Minor
                    Found in src/main/java/de/uniks/networkparser/ext/generic/ReflectionLoader.java - About 35 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return new DataInputStream(new StringInputStream());
                      Severity: Major
                      Found in src/main/java/de/uniks/networkparser/ext/generic/ReflectionLoader.java - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

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

                          Avoid too many return statements within this method.
                          Open

                                          return method.invoke(item, methodArgumentsValues);
                          Severity: Major
                          Found in src/main/java/de/uniks/networkparser/ext/generic/ReflectionLoader.java - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

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

                                    Avoid too many return statements within this method.
                                    Open

                                                return ReflectionLoader.newInstance(instance);
                                    Severity: Major
                                    Found in src/main/java/de/uniks/networkparser/ext/generic/ReflectionLoader.java - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

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

                                        Avoid too many return statements within this method.
                                        Open

                                                    return constructor.newInstance(methodArgumentsValues);
                                        Severity: Major
                                        Found in src/main/java/de/uniks/networkparser/ext/generic/ReflectionLoader.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/generic/ReflectionLoader.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/generic/ReflectionLoader.java - About 30 mins to fix

                                              Method isAccessMethod has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                                  public static boolean isAccessMethod(Object item, String methodName) {
                                                      if (item == null || methodName == null) {
                                                          return false;
                                                      }
                                                      Method method = null;
                                              Severity: Minor
                                              Found in src/main/java/de/uniks/networkparser/ext/generic/ReflectionLoader.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 (con.getParameterTypes().length == 0) {
                                                                      emptyConstructor = con;
                                                                      break;
                                                                  }

                                              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 (arguments[i + 1].getClass().isAssignableFrom((Class<?>) arguments[i]) == 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 (methodName != null && methodName.length() > 0) {
                                                                          method = itemClass.getMethod(methodName, new Class[0]);
                                                                      }

                                              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