REDUN.EQNULL
A redundant operation is one that does not have any effect, such as
- an assignment of a variable to itself
- use of an expression that will be evaluated to a constant such as a/a
- use of an expression that can be reduced to one operand such as a & a
Even if this is not an error on its own, it may indicate a larger error in the code. A REDUN.EQNULL warning is reported for a suspicious call to equals() with null passed as a parameter. Normally, equals(null) returns false (object is never equal to null).
Example 1
Copy
public int test() {
String s = "String";
if (s.equals(null)) {
return 1;
}
return 0;
}
REDUN.EQNULL is reported for line 11: Suspicious equals() called with 's' and null (never true).
External guidance
Security training
Application security training materials provided by Secure Code Warrior.