fujaba/NetworkParser

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

Summary

Maintainability
F
4 days
Test Coverage

Method fixClassModel has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

    public boolean fixClassModel() {
        Clazz[] classes = getClazzes().toArray(new Clazz[getClazzes().size()]);
        SimpleSet<Clazz> visited = new SimpleSet<Clazz>();
        String packageName = null;
        for (Clazz item : classes) {
Severity: Minor
Found in src/main/java/de/uniks/networkparser/graph/GraphModel.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

Method fixClassModel has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

    private boolean fixClassModel(Clazz item, SimpleSet<Clazz> visited) {
        /* Run over Interfaces, SuperClazzes, KidClazzes, Associations */
        AssociationSet assocs = item.getAssociations();
        for (Association role : assocs) {
            if (item.repairAssociation(role, this.renameAttributes) == false) {
Severity: Minor
Found in src/main/java/de/uniks/networkparser/graph/GraphModel.java - About 6 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

File GraphModel.java has 309 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package de.uniks.networkparser.graph;

import java.util.Iterator;

import de.uniks.networkparser.EntityUtil;
Severity: Minor
Found in src/main/java/de/uniks/networkparser/graph/GraphModel.java - About 3 hrs to fix

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

        @Override
        public Object getValue(String attribute) {
            if (PROPERTY_CLAZZ.equalsIgnoreCase(attribute)) {
                return getClazzes();
            }
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/graph/GraphModel.java - About 2 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 fixClassModel has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private boolean fixClassModel(Clazz item, SimpleSet<Clazz> visited) {
            /* Run over Interfaces, SuperClazzes, KidClazzes, Associations */
            AssociationSet assocs = item.getAssociations();
            for (Association role : assocs) {
                if (item.repairAssociation(role, this.renameAttributes) == false) {
    Severity: Major
    Found in src/main/java/de/uniks/networkparser/graph/GraphModel.java - About 2 hrs to fix

      Method fixClassModel has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public boolean fixClassModel() {
              Clazz[] classes = getClazzes().toArray(new Clazz[getClazzes().size()]);
              SimpleSet<Clazz> visited = new SimpleSet<Clazz>();
              String packageName = null;
              for (Clazz item : classes) {
      Severity: Major
      Found in src/main/java/de/uniks/networkparser/graph/GraphModel.java - About 2 hrs to fix

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

            protected boolean clearAddOnClazzes() {
                if (this.children == null) {
                    return true;
                }
                if (this.children instanceof GraphSimpleSet == false) {
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/graph/GraphModel.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 createClazz has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            public Clazz createClazz(String name) {
                if (name == null || children == null
                        || (children instanceof Clazz && name.equals(((Clazz) children).getName()))) {
                    Clazz clazz = createInstance(name);
                    clazz.setClassModel(this);
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/graph/GraphModel.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 getClazzes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            public ClazzSet getClazzes(Condition<?>... filters) {
                ClazzSet collection = new ClazzSet();
                if (children == null) {
                    return collection;
                }
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/graph/GraphModel.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 clearAddOnClazzes has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected boolean clearAddOnClazzes() {
                if (this.children == null) {
                    return true;
                }
                if (this.children instanceof GraphSimpleSet == false) {
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/graph/GraphModel.java - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                                  if (no < 'a' || no > 'z') {
                                      if (name.equals(name.toUpperCase())) {
                                          attribute.setName(name.toLowerCase());
                                      } else {
                                          attribute.setName(EntityUtil.downFirstChar(name));
          Severity: Major
          Found in src/main/java/de/uniks/networkparser/graph/GraphModel.java - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if (name == null || name.length() < 1) {
                                        item.remove(attribute);
                                        continue;
                                    }
            Severity: Major
            Found in src/main/java/de/uniks/networkparser/graph/GraphModel.java - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if (value != null) {
                                          String type = EntityUtil.shortClassName(value.getClass().getName());
                                          if (attributes.size() > no) {
                                              Attribute attribute = attributes.get(no);
                                              if (attribute.getType().getName(true).equals(type)) {
              Severity: Major
              Found in src/main/java/de/uniks/networkparser/graph/GraphModel.java - About 45 mins to fix

                Avoid too many return statements within this method.
                Open

                        return super.getValue(attribute);
                Severity: Major
                Found in src/main/java/de/uniks/networkparser/graph/GraphModel.java - About 30 mins to fix

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

                      private void fixDataType(DataType dataType) {
                          if (dataType == null) {
                              return;
                          }
                          Clazz clazz = dataType.getClazz();
                  Severity: Minor
                  Found in src/main/java/de/uniks/networkparser/graph/GraphModel.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 (check(child, filters)) {
                                          collection.add((Clazz) child);
                                      }

                  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