fujaba/NetworkParser

View on GitHub
src/main/java/de/uniks/networkparser/ext/petaf/ModelHistory.java

Summary

Maintainability
F
4 days
Test Coverage

Method addHistory has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
Open

    public boolean addHistory(ModelChange value) {
        boolean success = true;
        ModelChange historyChange = history.ceiling(value, true);

        while (success && historyChange != null) {
Severity: Minor
Found in src/main/java/de/uniks/networkparser/ext/petaf/ModelHistory.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 ModelHistory.java has 460 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package de.uniks.networkparser.ext.petaf;

/*
The MIT License

Severity: Minor
Found in src/main/java/de/uniks/networkparser/ext/petaf/ModelHistory.java - About 7 hrs to fix

    ModelHistory has 37 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class ModelHistory implements ObjectCondition {
        public static final String PROPERTY_HISTORY = "history";
        public static final String PROPERTY_LASTMODELCHANGE = "lastmodelchange";
        public static final String PROPERTY_CHANGES = "changes";
    
    
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/ext/petaf/ModelHistory.java - About 4 hrs to fix

      Method refactoringHistory has 82 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public boolean refactoringHistory() {
              SortedSet<NodeProxy> nodes = getSpace().getNodeProxies();
              SimpleList<String> keys = new SimpleList<String>();
              for (NodeProxy proxy : nodes) {
                  String key = proxy.getHistory();
      Severity: Major
      Found in src/main/java/de/uniks/networkparser/ext/petaf/ModelHistory.java - About 3 hrs to fix

        Method refactoringHistory has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            public boolean refactoringHistory() {
                SortedSet<NodeProxy> nodes = getSpace().getNodeProxies();
                SimpleList<String> keys = new SimpleList<String>();
                for (NodeProxy proxy : nodes) {
                    String key = proxy.getHistory();
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/ext/petaf/ModelHistory.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 addHistory has 69 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public boolean addHistory(ModelChange value) {
                boolean success = true;
                ModelChange historyChange = history.ceiling(value, true);
        
                while (success && historyChange != null) {
        Severity: Major
        Found in src/main/java/de/uniks/networkparser/ext/petaf/ModelHistory.java - About 2 hrs to fix

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

              public ModelHistory back(Object target, String property) {
                  while (true) {
                      back();
          
                      if (currentStep <= 0) {
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/ext/petaf/ModelHistory.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 back has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public ModelHistory back() {
                  if (currentStep <= 0) {
                      /* already at start */
                      return this;
                  }
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/ext/petaf/ModelHistory.java - About 1 hr to fix

            Method back has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public ModelHistory back(Object target) {
                    while (true) {
                        back();
                        if (currentStep <= 0) {
                            return this;
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/petaf/ModelHistory.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

            Method back has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public ModelHistory back() {
                    if (currentStep <= 0) {
                        /* already at start */
                        return this;
                    }
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/petaf/ModelHistory.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 (createrClass.getValue(target, fieldName) instanceof Collection<?>) {
                                        /* same kid object? */
                                        Entity historyKid = getObject(historyPropsObject, fieldName);
                                        if (historyKid == null) {
                                            success = false; /* should not happen */
            Severity: Major
            Found in src/main/java/de/uniks/networkparser/ext/petaf/ModelHistory.java - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if (target == null) {
                                          return false; /* this should not happen */
                                      }
              Severity: Major
              Found in src/main/java/de/uniks/networkparser/ext/petaf/ModelHistory.java - About 45 mins to fix

                TODO found
                Open

                    /* TODO OLD METHOD WITH NUMERIC-CHANGES */

                These nested if statements could be combined
                Open

                                if (space != null) {
                                    space.error(this, "addHistory", "ERROR");
                                }

                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