Conversation
693610a to
75974d3
Compare
b7db765 to
a1ca791
Compare
1ae9ccf to
01368c4
Compare
a1ca791 to
d3dd10e
Compare
afd810b to
098e30f
Compare
2b05970 to
a3902d4
Compare
| @@ -12,6 +12,15 @@ void npe(String a, String b) { | |||
| a.length(); | |||
10f3402 to
dd09a2c
Compare
58ca67a to
b92e6b0
Compare
b92e6b0 to
ff59179
Compare
4c33681 to
9ec6d26
Compare
6947d28 to
9409670
Compare
| public boolean equals(Object obj) { | ||
| return true; | ||
| return false; | ||
| } |
There was a problem hiding this comment.
Reporter: Findbugs
Rule: EQ_ALWAYS_TRUE
Severity: ERROR
File: se/bjurr/violations/lib/example/MyClass.java L35
Source: se.bjurr.violations.lib.example.MyClass
equals method always returns true <p> This class defines an equals method that always returns true. This is imaginative, but not very smart. Plus, it means that the equals method is not symmetric. </p>
| public boolean equals(Object obj) { | ||
| return true; | ||
| return false; | ||
| } |
There was a problem hiding this comment.
Reporter: Findbugs
Rule: HE_EQUALS_USE_HASHCODE
Severity: WARN
File: se/bjurr/violations/lib/example/MyClass.java L35
Source: se.bjurr.violations.lib.example.MyClass
Class defines equals() and uses Object.hashCode() <p> This class overrides <code>equals(Object)</code>, but does not override <code>hashCode()</code>, and inherits the implementation of <code>hashCode()</code> from <code>java.lang.Object</code> (which returns the identity hash code, an arbitrary value assigned to the object by the VM). Therefore, the class is very likely to violate the invariant that equal objects must have equal hashcodes.</p> <p>If you don't think instances of this class will ever be inserted into a HashMap/HashTable, the recommended <code>hashCode</code> implementation to use is:</p> <pre>public int hashCode() { assert false : "hashCode not designed"; return 42; // any arbitrary constant will do }</pre>
| @@ -30,6 +31,6 @@ void npe2(String a, String b) { | |||
There was a problem hiding this comment.
Reporter: Findbugs
Rule: NP_ALWAYS_NULL
Severity: ERROR
File: se/bjurr/violations/lib/example/MyClass.java L13
Source: se.bjurr.violations.lib.example.MyClass
Null pointer dereference <p> A null pointer is dereferenced here. This will lead to a <code>NullPointerException</code> when the code is executed.</p>
| @@ -30,6 +31,6 @@ void npe2(String a, String b) { | |||
There was a problem hiding this comment.
Reporter: Findbugs
Rule: NP_LOAD_OF_KNOWN_NULL_VALUE
Severity: INFO
File: se/bjurr/violations/lib/example/MyClass.java L13
Source: se.bjurr.violations.lib.example.MyClass
Load of known null value <p> The variable referenced at this point is known to be null due to an earlier check against null. Although this is valid, it might be a mistake (perhaps you intended to refer to a different variable, or perhaps the earlier check to see if the variable is null should have been a check to see if it was non-null). </p>
| void npe(String a, String b) { | ||
| if (a == null) { | ||
| System.out.println(); | ||
| System.out.println(); |
There was a problem hiding this comment.
Reporter: Checkstyle
Rule: com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck
Severity: INFO
File: src/main/java/se/bjurr/violations/lib/example/MyClass.java L9
Must have at least one statement.
| @Override | ||
| public boolean equals(Object obj) { | ||
| return true; | ||
| return false; |
There was a problem hiding this comment.
Reporter: PMD
Rule: OverrideBothEqualsAndHashcode
Severity: WARN
File: src/main/java/se/bjurr/violations/lib/example/MyClass.java L34
Ensure you override both equals() and hashCode() Basic https://pmd.github.io/pmd-5.6.1/pmd-java/rules/java/basic.html#OverrideBothEqualsAndHashcode
|
Found 17 violations: Reporter: Checkstyle Missing package-info.java file. Must have at least one statement. Must have at least one statement. Must have at least one statement. Must have at least one statement. Boolean expression complexity is 8 (max allowed is 1). Missing package-info.java file. equals method always returns true <p> This class defines an equals method that always returns true. This is imaginative, but not very smart. Plus, it means that the equals method is not symmetric. </p> Class defines equals() and uses Object.hashCode() <p> This class overrides <code>equals(Object)</code>, but does not override <code>hashCode()</code>, and inherits the implementation of <code>hashCode()</code> from <code>java.lang.Object</code> (which returns the identity hash code, an arbitrary value assigned to the object by the VM). Therefore, the class is very likely to violate the invariant that equal objects must have equal hashcodes.</p> <p>If you don't think instances of this class will ever be inserted into a HashMap/HashTable, the recommended <code>hashCode</code> implementation to use is:</p> <pre>public int hashCode() { assert false : "hashCode not designed"; return 42; // any arbitrary constant will do }</pre> Null pointer dereference <p> A null pointer is dereferenced here. This will lead to a <code>NullPointerException</code> when the code is executed.</p> Load of known null value <p> The variable referenced at this point is known to be null due to an earlier check against null. Although this is valid, it might be a mistake (perhaps you intended to refer to a different variable, or perhaps the earlier check to see if the variable is null should have been a check to see if it was non-null). </p> Possible null pointer dereference <p> There is a branch of statement that, <em>if executed,</em> guarantees that a null value will be dereferenced, which would generate a <code>NullPointerException</code> when the code is executed. Of course, the problem might be that the branch or statement is infeasible and that the null pointer exception can't ever be executed; deciding that is beyond the ability of FindBugs. </p> Field isn't final but should be <p> This static field public but not final, and could be changed by malicious code or by accident from another package. The field could be made final to avoid this vulnerability.</p> Field names should start with a lower case letter <p> Names of fields that are not final should be in mixed case with a lowercase first letter and the first letters of subsequent words capitalized. </p> Useless non-empty void method <p>Our analysis shows that this non-empty void method does not actually perform any useful work. Please check it: probably there's a mistake in its code or its body can be fully removed. </p> <p>We are trying to reduce the false positives as much as possible, but in some cases this warning might be wrong. Common false-positive cases include:</p> <p>- The method is intended to trigger loading of some class which may have a side effect.</p> <p>- The method is intended to implicitly throw some obscure exception.</p> Ensure you override both equals() and hashCode() Basic https://pmd.github.io/pmd-5.6.1/pmd-java/rules/java/basic.html#OverrideBothEqualsAndHashcode Ensure you override both equals() and hashCode() Basic https://pmd.github.io/pmd-5.6.1/pmd-java/rules/java/basic.html#OverrideBothEqualsAndHashcode |
Testing gradle plugin