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 = "";
- 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 toString
has 105 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public String toString() {
/* CONNECTION */
if (command == SQLCommand.CONNECTION) {
String driver = "";
File SQLStatement.java
has 312 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.ext.sql;
/*
NetworkParser
The MIT License
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 ");
- 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
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";
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 {
- 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 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 ");
Avoid deeply nested control flow statements. Open
for (; i.hasNext();) {
item = i.next();
values.append(", '").append(i.next().getValue()).append(QUOTE);
}
Avoid deeply nested control flow statements. Open
if (newFirst == false) {
sb.append(", ");
} else {
newFirst = false;
}
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<?>) {
- 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
Avoid too many return
statements within this method. Open
return sb.toString();
Avoid too many return
statements within this method. Open
return sb.toString();
Avoid too many return
statements within this method. Open
return sb.toString();
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);
- 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 (values instanceof SimpleKeyValueList<?, ?>) {
sb.append("SET ");
SimpleIteratorSet<String, Object> i = new SimpleIteratorSet<String, Object>(values);
Entry<String, Object> item = null;
for (; i.hasNext();) {
- 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
}
}
This for loop could be simplified to a while loop Open
for (; i.hasNext();) {
item = i.next();
if (first == false) {
sb.append(", ");
} else {
- Read upRead up
- Exclude checks
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);
}
- Read upRead up
- Exclude checks
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(", ");
}
- Read upRead up
- Exclude checks
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();
}
- Read upRead up
- Exclude checks
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());
- Read upRead up
- Exclude checks
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();
}
- Read upRead up
- Exclude checks
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(", ");
}
- Read upRead up
- Exclude checks
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)
}
}