fujaba/NetworkParser

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

Summary

Maintainability
F
3 days
Test Coverage

Method create has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
Open

    public static GenericCreator create(IdMap map, Class<?> instance) {
        if (map == null || instance == null) {
            return null;
        }
        SendableEntityCreator creator = map.getCreator(instance.getName(), true, true, null);
Severity: Minor
Found in src/main/java/de/uniks/networkparser/ext/generic/GenericCreator.java - About 1 day 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

File GenericCreator.java has 277 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package de.uniks.networkparser.ext.generic;

/*
NetworkParser
The MIT License
Severity: Minor
Found in src/main/java/de/uniks/networkparser/ext/generic/GenericCreator.java - About 2 hrs to fix

    Method create has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static GenericCreator create(IdMap map, Class<?> instance) {
            if (map == null || instance == null) {
                return null;
            }
            SendableEntityCreator creator = map.getCreator(instance.getName(), true, true, null);
    Severity: Major
    Found in src/main/java/de/uniks/networkparser/ext/generic/GenericCreator.java - About 2 hrs to fix

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

          private boolean setNewValue(Object entity, String methodName, Object value) {
              if (this.clazz == null || value == null) {
                  return false;
              }
              try {

        Method getValue has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @Override
            public Object getValue(Object entity, String attribute) {
                if (entity == null || this.clazz == null) {
                    return null;
                }

          Method setValue has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              @Override
              public boolean setValue(Object entity, String attribute, Object value, String type) {
                  if (entity == null || this.clazz == null) {
                      return false;
                  }

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

                @Override
                public boolean setValue(Object entity, String attribute, Object value, String type) {
                    if (entity == null || this.clazz == null) {
                        return false;
                    }
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/generic/GenericCreator.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 setNewValue has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                private boolean setNewValue(Object entity, String methodName, Object value) {
                    if (this.clazz == null || value == null) {
                        return false;
                    }
                    try {
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/generic/GenericCreator.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 getValidMethod has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                String getValidMethod(String methodName) {
                    String name = null;
                    if (methodName != null && badProperties.contains(methodName) == false) {
                        if (methodName.startsWith("get")) {
                            name = methodName.substring(3);
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/generic/GenericCreator.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

            Avoid deeply nested control flow statements.
            Open

                                    if (childClass != null) {
                                        child = ReflectionLoader.getClass("" + childClass);
                                    }
            Severity: Major
            Found in src/main/java/de/uniks/networkparser/ext/generic/GenericCreator.java - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                          if (genericSuperclass.getActualTypeArguments().length > 0) {
                                              Type type = genericSuperclass.getActualTypeArguments()[0];
                                              String typeClass = "" + ReflectionLoader.call(type, "getTypeName");
                                              if (typeClass.length() > 0) {
                                                  child = Class.forName(typeClass);
              Severity: Major
              Found in src/main/java/de/uniks/networkparser/ext/generic/GenericCreator.java - About 45 mins to fix

                Method withItem has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public GenericCreator withItem(Object value) {
                        this.item = value;
                
                        /* Init all Values */
                        if (this.item == null) {
                Severity: Minor
                Found in src/main/java/de/uniks/networkparser/ext/generic/GenericCreator.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 false;
                Severity: Major
                Found in src/main/java/de/uniks/networkparser/ext/generic/GenericCreator.java - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

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

                    Avoid too many return statements within this method.
                    Open

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

                      Avoid too many return statements within this method.
                      Open

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

                        Avoid too many return statements within this method.
                        Open

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

                            Avoid too many return statements within this method.
                            Open

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

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

                                  @Override
                                  public Object getValue(Object entity, String attribute) {
                                      if (entity == null || this.clazz == null) {
                                          return null;
                                      }
                              Severity: Minor
                              Found in src/main/java/de/uniks/networkparser/ext/generic/GenericCreator.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 (setNewValue(entity, "addTo" + this.getMethodName(attribute), value)) {
                                              return true;
                                          }

                              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