fujaba/NetworkParser

View on GitHub
src/main/java/de/uniks/networkparser/ext/story/Cucumber.java

Summary

Maintainability
F
4 days
Test Coverage

Method createFromFile has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
Open

    public static Cucumber createFromFile(String file) {
        CharacterBuffer readFile = FileBuffer.readFile(file);
        SimpleList<String> lines = readFile.splitStrings('\n');
        if (lines.size() < 1) {
            return null;
Severity: Minor
Found in src/main/java/de/uniks/networkparser/ext/story/Cucumber.java - About 7 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 Cucumber.java has 415 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package de.uniks.networkparser.ext.story;

import de.uniks.networkparser.SimpleEvent;
import de.uniks.networkparser.buffer.CharacterBuffer;
import de.uniks.networkparser.ext.ClassModel;
Severity: Minor
Found in src/main/java/de/uniks/networkparser/ext/story/Cucumber.java - About 5 hrs to fix

    Cucumber has 35 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class Cucumber implements ObjectCondition {
        public static final String TYPE_SCENARIO = "scenario";
        public static final String TYPE_TITLE = "title";
        public static final String TYPE_GIVEN = "given";
        public static final String TYPE_WHEN = "when";
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/ext/story/Cucumber.java - About 4 hrs to fix

      Method createFromFile has 74 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static Cucumber createFromFile(String file) {
              CharacterBuffer readFile = FileBuffer.readFile(file);
              SimpleList<String> lines = readFile.splitStrings('\n');
              if (lines.size() < 1) {
                  return null;
      Severity: Major
      Found in src/main/java/de/uniks/networkparser/ext/story/Cucumber.java - About 2 hrs to fix

        Method update has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            public boolean update(Object value) {
                if(value instanceof SimpleEvent == false) {
                    return false;
                }
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/ext/story/Cucumber.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 update has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @Override
            public boolean update(Object value) {
                if(value instanceof SimpleEvent == false) {
                    return false;
                }
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/ext/story/Cucumber.java - About 1 hr to fix

          Method getDictionary has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public String getDictionary(String id) {
                  if (id == null) {
                      return id;
                  }
                  if (this.parent != null) {
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/ext/story/Cucumber.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 analyse has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public boolean analyse() {
                  for (ObjectCondition rule : rules) {
                      if (rule.update(this) == false) {
                          return false;
                      }
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/ext/story/Cucumber.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 getDictionary has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public String getDictionary(String id) {
                  if (id == null) {
                      return id;
                  }
                  if (this.parent != null) {
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/ext/story/Cucumber.java - About 1 hr to fix

            Method analyse has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public boolean analyse() {
                    for (ObjectCondition rule : rules) {
                        if (rule.update(this) == false) {
                            return false;
                        }
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/story/Cucumber.java - About 1 hr to fix

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

                  public Cucumber withText(String type, String text) {
                      if(TYPE_TITLE.equalsIgnoreCase(type)) {
                          this.withTitle(text);
                          return this;
                      }
              Severity: Minor
              Found in src/main/java/de/uniks/networkparser/ext/story/Cucumber.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 too many return statements within this method.
              Open

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

                  Avoid too many return statements within this method.
                  Open

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

                      These nested if statements could be combined
                      Open

                                  if (id.endsWith("s")) {
                                      id = id.substring(0, id.length() - 1);
                                  }

                      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