fujaba/NetworkParser

View on GitHub
src/main/java/de/uniks/networkparser/ext/sql/SQLStatement.java

Summary

Maintainability
F
3 days
Test Coverage

Method toString has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    public String toString() {
        /* CONNECTION */
        if (command == SQLCommand.CONNECTION) {
            String driver = "";
Severity: Minor
Found in src/main/java/de/uniks/networkparser/ext/sql/SQLStatement.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 toString has 105 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @Override
    public String toString() {
        /* CONNECTION */
        if (command == SQLCommand.CONNECTION) {
            String driver = "";
Severity: Major
Found in src/main/java/de/uniks/networkparser/ext/sql/SQLStatement.java - About 4 hrs to fix

    File SQLStatement.java has 312 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    package de.uniks.networkparser.ext.sql;
    
    /*
    NetworkParser
    The MIT License
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/ext/sql/SQLStatement.java - About 3 hrs to fix

      Method addCondition has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          private void addCondition(StringBuilder sb) {
              if (conditions != null) {
                  boolean first = true;
      
                  sb.append(" WHERE ");
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/ext/sql/SQLStatement.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

      SQLStatement has 21 methods (exceeds 20 allowed). Consider refactoring.
      Open

      public class SQLStatement {
          public static final String ID = "_ID";
          public static final String VALUE = "VALUE";
          public static final String PROP = "PROP";
      
      
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/ext/sql/SQLStatement.java - About 2 hrs to fix

        Method getPrimaryId has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public String getPrimaryId() {
                SimpleIteratorSet<String, Object> i;
                if (command == SQLCommand.SELECT) {
                    i = new SimpleIteratorSet<String, Object>(conditions);
                } else {
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/ext/sql/SQLStatement.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 addCondition has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private void addCondition(StringBuilder sb) {
                if (conditions != null) {
                    boolean first = true;
        
                    sb.append(" WHERE ");
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/ext/sql/SQLStatement.java - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                                  for (; i.hasNext();) {
                                      item = i.next();
                                      values.append(", '").append(i.next().getValue()).append(QUOTE);
                                  }
          Severity: Major
          Found in src/main/java/de/uniks/networkparser/ext/sql/SQLStatement.java - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if (newFirst == false) {
                                        sb.append(", ");
                                    } else {
                                        newFirst = false;
                                    }
            Severity: Major
            Found in src/main/java/de/uniks/networkparser/ext/sql/SQLStatement.java - About 45 mins to fix

              Method convertValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  private void convertValue(StringBuilder sb, Object value) {
                      if (value == null) {
                          return;
                      }
                      if (value instanceof SimpleSet<?>) {
              Severity: Minor
              Found in src/main/java/de/uniks/networkparser/ext/sql/SQLStatement.java - About 35 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 sb.toString();
              Severity: Major
              Found in src/main/java/de/uniks/networkparser/ext/sql/SQLStatement.java - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return sb.toString();
                Severity: Major
                Found in src/main/java/de/uniks/networkparser/ext/sql/SQLStatement.java - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return sb.toString();
                  Severity: Major
                  Found in src/main/java/de/uniks/networkparser/ext/sql/SQLStatement.java - About 30 mins to fix

                    These nested if statements could be combined
                    Open

                                    if (values instanceof SimpleKeyValueList<?, ?>) {
                                        SimpleIteratorSet<String, Object> i = new SimpleIteratorSet<String, Object>(values);
                                        Entry<String, Object> item = i.next();
                                        StringBuilder values = new StringBuilder();
                                        values.append(QUOTE).append(item.getValue()).append(QUOTE);

                    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 (values instanceof SimpleKeyValueList<?, ?>) {
                                    sb.append("SET ");
                                    SimpleIteratorSet<String, Object> i = new SimpleIteratorSet<String, Object>(values);
                                    Entry<String, Object> item = null;
                                    for (; i.hasNext();) {

                    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
                     }
                    }

                    This for loop could be simplified to a while loop
                    Open

                                    for (; i.hasNext();) {
                                        item = i.next();
                                        if (first == false) {
                                            sb.append(", ");
                                        } else {

                    ForLoopShouldBeWhileLoop

                    Since: PMD 1.02

                    Priority: Medium

                    Categories: Style

                    Remediation Points: 50000

                    Some for loops can be simplified to while loops, this makes them more concise.

                    Example:

                    public class Foo {
                     void bar() {
                     for (;true;) true; // No Init or Update part, may as well be: while (true)
                     }
                    }

                    This for loop could be simplified to a while loop
                    Open

                                            for (; i.hasNext();) {
                                                item = i.next();
                                                values.append(", '").append(i.next().getValue()).append(QUOTE);
                                            }

                    ForLoopShouldBeWhileLoop

                    Since: PMD 1.02

                    Priority: Medium

                    Categories: Style

                    Remediation Points: 50000

                    Some for loops can be simplified to while loops, this makes them more concise.

                    Example:

                    public class Foo {
                     void bar() {
                     for (;true;) true; // No Init or Update part, may as well be: while (true)
                     }
                    }

                    This for loop could be simplified to a while loop
                    Open

                                    for (; i.hasNext();) {
                                        item = i.next();
                                        if (first == false) {
                                            sb.append(", ");
                                        }

                    ForLoopShouldBeWhileLoop

                    Since: PMD 1.02

                    Priority: Medium

                    Categories: Style

                    Remediation Points: 50000

                    Some for loops can be simplified to while loops, this makes them more concise.

                    Example:

                    public class Foo {
                     void bar() {
                     for (;true;) true; // No Init or Update part, may as well be: while (true)
                     }
                    }

                    This for loop could be simplified to a while loop
                    Open

                            for (; i.hasNext();) {
                                item = i.next();
                                if (ID.equals(item.getKey())) {
                                    return (String) item.getValue();
                                }

                    ForLoopShouldBeWhileLoop

                    Since: PMD 1.02

                    Priority: Medium

                    Categories: Style

                    Remediation Points: 50000

                    Some for loops can be simplified to while loops, this makes them more concise.

                    Example:

                    public class Foo {
                     void bar() {
                     for (;true;) true; // No Init or Update part, may as well be: while (true)
                     }
                    }

                    This for loop could be simplified to a while loop
                    Open

                                            for (; i.hasNext();) {
                                                item = i.next();
                                                keys.append(", ").append(item.getKey());
                                                values.append(", '");
                                                convertValue(values, item.getValue());

                    ForLoopShouldBeWhileLoop

                    Since: PMD 1.02

                    Priority: Medium

                    Categories: Style

                    Remediation Points: 50000

                    Some for loops can be simplified to while loops, this makes them more concise.

                    Example:

                    public class Foo {
                     void bar() {
                     for (;true;) true; // No Init or Update part, may as well be: while (true)
                     }
                    }

                    This for loop could be simplified to a while loop
                    Open

                                for (; i.hasNext();) {
                                    item = i.next();
                                    if (ID.equals(item.getKey())) {
                                        return (String) item.getValue();
                                    }

                    ForLoopShouldBeWhileLoop

                    Since: PMD 1.02

                    Priority: Medium

                    Categories: Style

                    Remediation Points: 50000

                    Some for loops can be simplified to while loops, this makes them more concise.

                    Example:

                    public class Foo {
                     void bar() {
                     for (;true;) true; // No Init or Update part, may as well be: while (true)
                     }
                    }

                    This for loop could be simplified to a while loop
                    Open

                                    for (; i.hasNext();) {
                                        item = i.next();
                                        if (first == false) {
                                            sb.append(", ");
                                        }

                    ForLoopShouldBeWhileLoop

                    Since: PMD 1.02

                    Priority: Medium

                    Categories: Style

                    Remediation Points: 50000

                    Some for loops can be simplified to while loops, this makes them more concise.

                    Example:

                    public class Foo {
                     void bar() {
                     for (;true;) true; // No Init or Update part, may as well be: while (true)
                     }
                    }

                    There are no issues that match your filters.

                    Category
                    Status