REDUN.EQ

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.EQ warning is reported for a suspicious call to equals() with the same object on both sides. Normally, equals() returns true to the same objects.

Example 1

9      public int test() {
10         String s = "String";
11         if (s.equals(s)) {
12             return 1;
13         }
14         return 0;
15     }

REDUN.EQ is reported for line 11: Suspicious equals() called with 's' on both sides.

Security training

Application security training materials provided by Secure Code Warrior.