fujaba/NetworkParser

View on GitHub
src/main/java/de/uniks/networkparser/graph/GraphUtil.java

Summary

Maintainability
F
4 days
Test Coverage

File GraphUtil.java has 600 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package de.uniks.networkparser.graph;

import de.uniks.networkparser.EntityUtil;
import de.uniks.networkparser.buffer.CharacterBuffer;
import de.uniks.networkparser.interfaces.ObjectCondition;
Severity: Major
Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.java - About 1 day to fix

    GraphUtil has 55 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class GraphUtil {
        private static SimpleList<String> noneDictionary = new SimpleList<String>().with("aircraft", "carp", "deer",
                "salmon", "sheep", "trout");
        private static SimpleList<String> oesDictionary = new SimpleList<String>().with("hero", "potato", "torpedo");
    
    
    Severity: Major
    Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.java - About 7 hrs to fix

      Method containsClazzAssociation has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          public static final boolean containsClazzAssociation(SimpleList<GraphMember> visited, Association assoc,
                  Association other) {
              boolean foundAssoc = false;
              for (GraphMember checkItem : visited) {
                  if (checkItem instanceof Association == false || checkItem.getName() == null) {
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.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 getPlural has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public static String getPlural(String singular) {
              /* Zischlaut */
              if (singular == null || singular.length() < 1) {
                  return null;
              }
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.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 containsClazzAssociation has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static final boolean containsClazzAssociation(SimpleList<GraphMember> visited, Association assoc,
                  Association other) {
              boolean foundAssoc = false;
              for (GraphMember checkItem : visited) {
                  if (checkItem instanceof Association == false || checkItem.getName() == null) {
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.java - About 1 hr to fix

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

            public static final Modifier getVisible(GraphMember member) {
                if (member == null) {
                    return Modifier.PACKAGE;
                }
                Modifier modifier = member.getModifier();
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.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 compareName has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public static double compareName(String source, String other) {
                if (source == null || other == null) {
                    return 0;
                }
                int counter = 0;
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.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 getParentClazz has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public static final Clazz getParentClazz(GraphMember member) {
                if (member == null) {
                    return null;
                }
                if (member instanceof Clazz) {
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.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 (assocB.getClazz() == other.getClazz()) {
                                    /* May be n-m */
                                    assocA.with(Association.MANY);
                                    assocB.with(Association.MANY);
                                } else {
        Severity: Major
        Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.java - About 45 mins to fix

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

              public static final GraphModel getGraphModel(GraphMember member) {
                  if (member instanceof GraphModel) {
                      return (GraphModel) member;
                  }
                  Object parent = member.getParent();
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.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

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

              public static final SimpleSet<Annotation> getAnnotations(GraphMember item) {
                  if (item == null) {
                      return null;
                  }
                  SimpleSet<Annotation> collection = new SimpleSet<Annotation>();
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.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

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

              public static boolean setChildren(GraphMember graphMember, Object children) {
                  if (graphMember != null ) {
                      if(children instanceof GraphSimpleSet) {
                          GraphSimpleSet set = (GraphSimpleSet) children;
                          if(graphMember.children != set) {
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.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

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

              public static double compareType(String sourceType, String otherType) {
                  if (sourceType == null || otherType == null) {
                      return 1;
                  }
                  if (EntityUtil.isNumericType(sourceType) && EntityUtil.isNumericType(otherType)) {
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.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 value;
          Severity: Major
          Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.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/graph/GraphUtil.java - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return Clazz.TYPE_CLASS;
              Severity: Major
              Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.java - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return singular.subSequence(0, singular.length() - 1) + "ves";
                Severity: Major
                Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.java - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return singular + "s";
                  Severity: Major
                  Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.java - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return singular + "s";
                    Severity: Major
                    Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.java - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return Clazz.TYPE_PATTERNOBJECT;
                      Severity: Major
                      Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.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/graph/GraphUtil.java - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return Clazz.TYPE_SET;
                          Severity: Major
                          Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.java - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                            return singular + "es";
                            Severity: Major
                            Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.java - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                      return -1;
                              Severity: Major
                              Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.java - About 30 mins to fix

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

                                    public static final boolean removeYou(GraphMember value) {
                                        if (value == null) {
                                            return true;
                                        }
                                        value.setParentNode(null);
                                Severity: Minor
                                Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.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

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

                                    public static final GraphSimpleSet getGraphDiff(GraphSimpleSet owner, GraphMember item) {
                                        if (item == null) {
                                            return owner;
                                        }
                                        if (owner == null) {
                                Severity: Minor
                                Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.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

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

                                    public static final boolean isUndirectional(Association assoc) {
                                        if (assoc == null) {
                                            return false;
                                        }
                                        if ((assoc.getType() == AssociationTypes.ASSOCIATION || assoc.getType() == AssociationTypes.UNDIRECTIONAL)
                                Severity: Minor
                                Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.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

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

                                    public static final String createType(String value) {
                                        if (value == null) {
                                            return Clazz.TYPE_CLASS;
                                        }
                                        String trim = value.trim().toLowerCase();
                                Severity: Minor
                                Found in src/main/java/de/uniks/networkparser/graph/GraphUtil.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 (assocB.getName().equals(other.getName())) {
                                                    /* Found Link ?? */
                                                    foundAssoc = true;
                                                    if (assocA.getClazz() == assoc.getClazz()) {
                                                        if (assocB.getClazz() == other.getClazz()) {

                                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 (child.equals(Modifier.PACKAGE) || child.equals(Modifier.PRIVATE) || child.equals(Modifier.PUBLIC)
                                                        || child.equals(Modifier.PROTECTED)) {
                                                    return modifier;
                                                }

                                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