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();
- Read upRead up
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));
- Read upRead up
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;
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) {
- Read upRead up
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();
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));
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;
- Read upRead up
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) {
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);
- Read upRead up
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;
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();
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) {
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) {
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);
Avoid deeply nested control flow statements. Open
if (statement.isAutoStatement()) {
statement.withEnable(false);
} else if (primaryKey != null) {
values.addId(primaryKey);
values.addDeletedId(primaryKey);
Avoid deeply nested control flow statements. Open
if (properties[i].indexOf('.') >= 0 || properties[i] == SendableEntityCreator.DYNAMIC) {
continue;
}
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);
Method addTableCreate
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private void addTableCreate(String tableName, Object item, SendableEntityCreator creator,
SQLStatementList statements, MapEntity map) {
These nested if statements could be combined Open
if (this.connection == null || this.connection != connection) {
result = result & disconnect(connection);
}
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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) {
}
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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
}
}