fujaba/NetworkParser

View on GitHub
src/main/java/de/uniks/networkparser/xml/ArtifactList.java

Summary

Maintainability
D
1 day
Test Coverage

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

    @Override
    public boolean add(ArtifactFile value) {
        if (value == null) {
            return false;
        }
Severity: Minor
Found in src/main/java/de/uniks/networkparser/xml/ArtifactList.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

Method add has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @Override
    public boolean add(ArtifactFile value) {
        if (value == null) {
            return false;
        }
Severity: Major
Found in src/main/java/de/uniks/networkparser/xml/ArtifactList.java - About 2 hrs to fix

    Method addItem has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        private boolean addItem(ArtifactFile pom) {
            if (pom == null) {
                return false;
            }
            super.add(pom);
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/xml/ArtifactList.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 addItem has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private boolean addItem(ArtifactFile pom) {
            if (pom == null) {
                return false;
            }
            super.add(pom);
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/xml/ArtifactList.java - About 1 hr to fix

      Avoid using a branching statement as the last in a loop.
      Open

                          break;

      AvoidBranchingStatementAsLastInLoop

      Since: PMD 5.0

      Priority: Medium High

      Categories: Style

      Remediation Points: 50000

      Using a branching statement as the last part of a loop may be a bug, and/or is confusing. Ensure that the usage is not a bug, or consider using another approach.

      Example:

      // unusual use of branching statement in a loop
      for (int i = 0; i < 10; i++) {
       if (i*i <= 25) {
       continue;
       }
       break;
      }
      
      // this makes more sense...
      for (int i = 0; i < 10; i++) {
       if (i*i > 25) {
       break;
       }
      }

      These nested if statements could be combined
      Open

                  if (pom.calculatePomNumber(first().getPomNumber())) {
                      /* Must be recalculate */
                      for (ArtifactFile child : this) {
                          child.calculatePomNumber(pom.getPomNumber());
                      }

      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