fujaba/NetworkParser

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

Summary

Maintainability
D
2 days
Test Coverage

Method invoke has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if (method == 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

SimpleSLF4JProvider has 33 methods (exceeds 20 allowed). Consider refactoring.
Open

public class SimpleSLF4JProvider implements InvocationHandler {
    /*
     * public class SimpleSLF4JProvider implements SLF4JServiceProvider,
     * InvocationHandler { to avoid constant folding by the compiler, this field
     * must *not* be final

    Method invoke has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @Override
        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
            if (method == null) {
                return null;
            }

      Avoid too many return statements within this method.
      Open

                  return isWarnEnabled();

        Avoid too many return statements within this method.
        Open

                        return isTraceEnabled(args[0]);

          Avoid too many return statements within this method.
          Open

                          return isErrorEnabled(args[0]);

            Avoid too many return statements within this method.
            Open

                        return getDetachedMarker((String) args[0]);

              Avoid too many return statements within this method.
              Open

                          return isErrorEnabled();

                Avoid too many return statements within this method.
                Open

                            return isTraceEnabled();

                  Avoid too many return statements within this method.
                  Open

                              return getLogger((String) args[0]);

                    Avoid too many return statements within this method.
                    Open

                                    return isDebugEnabled(args[0]);

                      Avoid too many return statements within this method.
                      Open

                                  return getName();

                        Avoid too many return statements within this method.
                        Open

                                        return isWarnEnabled(args[0]);

                          Avoid too many return statements within this method.
                          Open

                                  return null;

                            Avoid too many return statements within this method.
                            Open

                                        return isDebugEnabled();

                              Avoid too many return statements within this method.
                              Open

                                              return isInfoEnabled(args[0]);

                                Avoid too many return statements within this method.
                                Open

                                            return isInfoEnabled();

                                  These nested if statements could be combined
                                  Open

                                              if (args != null && args.length > 0 && args[0] instanceof String) {
                                                  this.debug((String) args[0], convertConvert(args));
                                              } /* not allowed debug(Marker marker, ?) */

                                  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 (args != null && args.length > 0 && args[0] instanceof String) {
                                                  this.info((String) args[0], convertConvert(args));
                                              } /* not allowed debug(Marker marker, ?) */

                                  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 (args != null && args.length > 0 && args[0] instanceof String) {
                                                  this.warn((String) args[0], convertConvert(args));
                                              } /* not allowed debug(Marker marker, ?) */

                                  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 (args != null && args.length > 0 && args[0] instanceof String) {
                                                  this.error((String) args[0], convertConvert(args));
                                              } /* not allowed debug(Marker marker, ?) */

                                  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 (args != null && args.length > 0 && args[0] instanceof String) {
                                                  this.trace((String) args[0], convertConvert(args));
                                              } /* not allowed trace(Marker marker, ?) */

                                  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