fujaba/NetworkParser

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

Summary

Maintainability
F
1 wk
Test Coverage

Method validateStatements has a Cognitive Complexity of 113 (exceeds 5 allowed). Consider refactoring.
Open

    public boolean validateStatements(SQLStatementList result, SimpleList<SQLTable> results) {
        SimpleKeyValueList<String, SelectSearcher> foundKeys = new SimpleKeyValueList<String, SelectSearcher>();

        for (SQLStatement statement : result) {
            String table = statement.getTable();
Severity: Minor
Found in src/main/java/de/uniks/networkparser/ext/sql/SQLTokener.java - About 2 days 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 addTableCreate has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
Open

    private void addTableCreate(String tableName, Object item, SendableEntityCreator creator,
            SQLStatementList statements, MapEntity map) {
        if (map.contains(tableName) == false) {
            if (map.isTokenerFlag(FLAG_DROP)) {
                statements.add(new SQLStatement(SQLCommand.DROPTABLE, tableName));
Severity: Minor
Found in src/main/java/de/uniks/networkparser/ext/sql/SQLTokener.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 SQLTokener.java has 494 lines of code (exceeds 250 allowed). Consider refactoring.
Open


package de.uniks.networkparser.ext.sql;

import java.sql.Connection;
import java.sql.DriverManager;
Severity: Minor
Found in src/main/java/de/uniks/networkparser/ext/sql/SQLTokener.java - About 7 hrs to fix

    Method executeStatements has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

        public boolean executeStatements(SQLStatementList statements, SimpleList<SQLTable> results, boolean dynamicTable) {
            boolean result = true;
            Connection connection = null;
            for (SQLStatement statement : statements) {
                if (statement.isEnable() == false) {
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/ext/sql/SQLTokener.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

    Method validateStatements has 134 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public boolean validateStatements(SQLStatementList result, SimpleList<SQLTable> results) {
            SimpleKeyValueList<String, SelectSearcher> foundKeys = new SimpleKeyValueList<String, SelectSearcher>();
    
            for (SQLStatement statement : result) {
                String table = statement.getTable();
    Severity: Major
    Found in src/main/java/de/uniks/networkparser/ext/sql/SQLTokener.java - About 5 hrs to fix

      Method addTableCreate has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private void addTableCreate(String tableName, Object item, SendableEntityCreator creator,
                  SQLStatementList statements, MapEntity map) {
              if (map.contains(tableName) == false) {
                  if (map.isTokenerFlag(FLAG_DROP)) {
                      statements.add(new SQLStatement(SQLCommand.DROPTABLE, tableName));
      Severity: Major
      Found in src/main/java/de/uniks/networkparser/ext/sql/SQLTokener.java - About 2 hrs to fix

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

            private void parseModelPrivotisierung(MapEntity map, String tableName, String id, SendableEntityCreator creator,
                    Object item, SQLStatementList statements) {
                String[] properties = creator.getProperties();
                Object prototype = creator.getSendableInstance(true);
                SQLStatement insertStatement;
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/ext/sql/SQLTokener.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 executeStatements has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public boolean executeStatements(SQLStatementList statements, SimpleList<SQLTable> results, boolean dynamicTable) {
                boolean result = true;
                Connection connection = null;
                for (SQLStatement statement : statements) {
                    if (statement.isEnable() == false) {
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/ext/sql/SQLTokener.java - About 2 hrs to fix

          Method parseModelFlat has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              private void parseModelFlat(MapEntity map, String tableName, String id, SendableEntityCreator creator, Object item,
                      SQLStatementList statements) {
                  SQLStatement insertStatement = new SQLStatement(SQLCommand.INSERT, tableName);
                  insertStatement.with(SQLStatement.ID, id);
          
          
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/ext/sql/SQLTokener.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 parseModelPrivotisierung has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private void parseModelPrivotisierung(MapEntity map, String tableName, String id, SendableEntityCreator creator,
                      Object item, SQLStatementList statements) {
                  String[] properties = creator.getProperties();
                  Object prototype = creator.getSendableInstance(true);
                  SQLStatement insertStatement;
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/ext/sql/SQLTokener.java - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                                    if (value instanceof Collection<?>) {
                                        Collection<?> collection = (Collection<?>) value;
                                        if (collection.size() > 0) {
                                            Object child = collection.iterator().next();
                                            String simpleName = child.getClass().getName();
            Severity: Major
            Found in src/main/java/de/uniks/networkparser/ext/sql/SQLTokener.java - About 45 mins to fix

              Method parseModelPrivotisierung has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  private void parseModelPrivotisierung(MapEntity map, String tableName, String id, SendableEntityCreator creator,
                          Object item, SQLStatementList statements) {
              Severity: Minor
              Found in src/main/java/de/uniks/networkparser/ext/sql/SQLTokener.java - About 45 mins to fix

                Method parseModelFlat has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    private void parseModelFlat(MapEntity map, String tableName, String id, SendableEntityCreator creator, Object item,
                            SQLStatementList statements) {
                Severity: Minor
                Found in src/main/java/de/uniks/networkparser/ext/sql/SQLTokener.java - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if (statement.isAutoStatement()) {
                                              statement.withCommand(SQLCommand.INSERT);
                                              statement.withoutCondition(SQLStatement.ID);
                                              statement.with(SQLStatement.ID, primaryKey);
                                              values.addId(primaryKey);
                  Severity: Major
                  Found in src/main/java/de/uniks/networkparser/ext/sql/SQLTokener.java - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if (statement.isAutoStatement()) {
                                                statement.withEnable(false);
                                            } else if (primaryKey != null) {
                                                values.addId(primaryKey);
                                                values.addDeletedId(primaryKey);
                    Severity: Major
                    Found in src/main/java/de/uniks/networkparser/ext/sql/SQLTokener.java - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if (properties[i].indexOf('.') >= 0 || properties[i] == SendableEntityCreator.DYNAMIC) {
                                                  continue;
                                              }
                      Severity: Major
                      Found in src/main/java/de/uniks/networkparser/ext/sql/SQLTokener.java - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if (statement.getCommand().equals(SQLCommand.INSERT)) {
                                                    statement.withCommand(SQLCommand.UPDATE);
                                                    statement.withCondition(SQLStatement.ID, primaryId);
                                                    statement.without(SQLStatement.ID);
                                                    selectSearcher.mayBeStatements.remove(i);
                        Severity: Major
                        Found in src/main/java/de/uniks/networkparser/ext/sql/SQLTokener.java - About 45 mins to fix

                          Method addTableCreate has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              private void addTableCreate(String tableName, Object item, SendableEntityCreator creator,
                                      SQLStatementList statements, MapEntity map) {
                          Severity: Minor
                          Found in src/main/java/de/uniks/networkparser/ext/sql/SQLTokener.java - About 35 mins to fix

                            These nested if statements could be combined
                            Open

                                        if (this.connection == null || this.connection != connection) {
                                            result = result & disconnect(connection);
                                        }

                            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 (statement.isAutoStatement()) {
                                                        statement.withCommand(SQLCommand.INSERT);
                                                        statement.withoutCondition(SQLStatement.ID);
                                                        statement.with(SQLStatement.ID, primaryKey);
                                                        values.addId(primaryKey);

                            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 (statement.getCommand() == SQLCommand.INSERT
                                                                || statement.getCommand() == SQLCommand.UPDATE) {
                            
                                                        }

                            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 (primaryKey != null) {
                                                        statement.withCommand(SQLCommand.INSERT);
                                                        statement.withoutCondition(SQLStatement.ID);
                                                        statement.with(SQLStatement.ID, primaryKey);
                                                        values.addId(primaryKey);

                            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