fujaba/NetworkParser

View on GitHub

Showing 4,645 of 4,645 total issues

These nested if statements could be combined
Open

                    if (received.indexOf(proxy) < 0 || proxy instanceof NodeProxyFileSystem) {
                        step++;
                        if (sendProxies.add(proxy) == false) {
                            /* Break while */
                            step = this.peerCount;

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

Do not hard code the IP address
Open

    public static final String LOCALHOST = "127.0.0.1";

AvoidUsingHardCodedIP

Since: PMD 4.1

Priority: Medium

Categories: Style

Remediation Points: 50000

Application with hard-coded IP addresses can become impossible to deploy in some cases. Externalizing IP adresses is preferable.

Example:

public class Foo {
 private String ip = '127.0.0.1'; // not recommended
}

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 (list.add(value)) {
                    value.setParentNode(this);
                }

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 (value instanceof Integer) {
                return dice.setValue((Integer) value);
            }

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 (chain) {
                        return false;
                    }

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[0] instanceof ChainCondition == false) {
                if (values[0] instanceof PropertyChangeListener || values[0] instanceof ObjectCondition) {
                    this.list = values[0];
                }
                return true;

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 (matchAssociationValues(oldAssociation, newAssociation)) {
                        metaMatchedAssociations.add(oldAssociation);
                        newMatchedAssociations.add(newAssociation);

                        if (oldAssociation.getClazz() == oldAssociation.getOtherClazz()

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

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 (((Number) upperValue).intValue() != 1) {
                        tgtAssoc.with(Association.MANY);
                    }

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 (this.students.remove(item)) {
                    item.withoutDone(this);
                }

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 (this.rooms.remove(item)) {
                    item.withUniversity(null);
                }

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 (assoc.getCardinality() != otherAssoc.getCardinality()) {
                    /* Self assoc with same RoleName but other Cardinality */
                    return false;
                }

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.length == 1) {
                this.children = values[0];
                ((GraphMember) values[0]).setParentNode(this);
                return this;
            }

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

Ensure you override both equals() and hashCode()
Open

  public boolean equals(Object obj) {

OverrideBothEqualsAndHashcode

Since: PMD 0.4

Priority: Medium

Categories: Style

Remediation Points: 50000

Override both public boolean Object.equals(Object other), and public int Object.hashCode(), or override neither. Even if you are inheriting a hashCode() from a parent class, consider implementing hashCode and explicitly delegating to your superclass.

Example:

public class Bar { // poor, missing a hashcode() method
 public boolean equals(Object o) {
 // do some comparison
 }
}

public class Baz { // poor, missing an equals() method
 public int hashCode() {
 // return some hash value
 }
}

public class Foo { // perfect, both methods provided
 public boolean equals(Object other) {
 // do some comparison
 }
 public int hashCode() {
 // return some hash value
 }
}

These nested if statements could be combined
Open

            if (v2 instanceof Comparable<?>) {
                return ((Comparable<Object>) v2).compareTo(v1);
            }

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 (sourceMethod.getClazz().getName().equals(otherMethod.getClazz().getName())) {
                return false;
            }

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 (this.label.remove(item)) {
                    item.withoutField(this);
                    firePropertyChange(PROPERTY_LABEL, item, null);
                }

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 (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)
 }
}
Severity
Category
Status
Source
Language