fujaba/NetworkParser

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

Summary

Maintainability
F
4 days
Test Coverage

Method with has a Cognitive Complexity of 113 (exceeds 5 allowed). Consider refactoring.
Open

    protected GraphEntity with(Association... values) {
        if (values != null) {
            boolean add;
            AssociationSet allAssoc;
            for (Association assoc : values) {
Severity: Minor
Found in src/main/java/de/uniks/networkparser/graph/GraphEntity.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

Method getEdges has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    AssociationSet getEdges(AssociationTypes type, Condition<?>... filters) {
        if (this.children == null || type == null) {
            return AssociationSet.EMPTY_SET;
        }
        AssociationSet collection = new AssociationSet();
Severity: Minor
Found in src/main/java/de/uniks/networkparser/graph/GraphEntity.java - About 4 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 with has 93 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected GraphEntity with(Association... values) {
        if (values != null) {
            boolean add;
            AssociationSet allAssoc;
            for (Association assoc : values) {
Severity: Major
Found in src/main/java/de/uniks/networkparser/graph/GraphEntity.java - About 3 hrs to fix

    File GraphEntity.java has 266 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    package de.uniks.networkparser.graph;
    
    import de.uniks.networkparser.interfaces.Condition;
    
    public abstract class GraphEntity extends GraphMember {
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/graph/GraphEntity.java - About 2 hrs to fix

      Method getByObject has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          protected GraphMember getByObject(String clazz, boolean fullName) {
              if (clazz == null || children == null) {
                  return null;
              }
              String sub = clazz;
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/graph/GraphEntity.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 getChildByName has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public GraphMember getChildByName(String name, Class<?> subClass) {
              if (this.children == null) {
                  return null;
              }
              GraphSimpleSet children = this.getChildren();
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/graph/GraphEntity.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 getName has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public String getName(boolean shortName) {
              if (this.name == null) {
                  return null;
              }
              if (shortName == false) {
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/graph/GraphEntity.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 getByObject has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected GraphMember getByObject(String clazz, boolean fullName) {
              if (clazz == null || children == null) {
                  return null;
              }
              String sub = clazz;
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/graph/GraphEntity.java - About 1 hr to fix

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

            AssociationSet getEdges(AssociationTypes type, Condition<?>... filters) {
                if (this.children == null || type == null) {
                    return AssociationSet.EMPTY_SET;
                }
                AssociationSet collection = new AssociationSet();
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/graph/GraphEntity.java - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                  if (values != null) {
                      boolean add;
                      AssociationSet allAssoc;
                      for (Association assoc : values) {
                          /* Do Nothing */
          Severity: Major
          Found in src/main/java/de/uniks/networkparser/graph/GraphEntity.java - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                                    if (this.parentNode instanceof GraphModel) {
                                        ((GraphModel) this.parentNode).with(assoc);
                                    }
            Severity: Major
            Found in src/main/java/de/uniks/networkparser/graph/GraphEntity.java - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if (item != assoc) {
                                          add = false;
                                      }
              Severity: Major
              Found in src/main/java/de/uniks/networkparser/graph/GraphEntity.java - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if (itemOther.getClazz() == assocOther.getClazz() && item.getClazz() == assoc.getClazz()) {
                                            add = false;
                                            if (assocOther.name() != null && assoc.name() == null) {
                                                if (itemOther.getType() == AssociationTypes.EDGE
                                                        && item.getType() == AssociationTypes.ASSOCIATION) {
                Severity: Major
                Found in src/main/java/de/uniks/networkparser/graph/GraphEntity.java - About 45 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return name.substring(name.lastIndexOf(".") + 1);
                  Severity: Major
                  Found in src/main/java/de/uniks/networkparser/graph/GraphEntity.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/GraphEntity.java - About 30 mins to fix

                      These nested if statements could be combined
                      Open

                                              if (itemOther.getClazz() == assocOther.getClazz() && item.getClazz() == assoc.getClazz()) {
                                                  add = false;
                                                  if (assocOther.name() != null && assoc.name() == null) {
                                                      if (itemOther.getType() == AssociationTypes.EDGE
                                                              && item.getType() == AssociationTypes.ASSOCIATION) {

                      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 (subClass != null && subClass == item.getClass()) {
                                          return item;
                                      }

                      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 (this.parentNode instanceof GraphModel) {
                                                  ((GraphModel) this.parentNode).with(assoc);
                                              }

                      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