PB.ASI
Avoid assignments within an "if" condition
Description
This rule flags any assignment in "if" conditional statements.
Example
package PB;
public class ASI {
public int foo(boolean b) {
int ret = 0;
if ((b = true) { // Violation
ret = 3;
}
return ret;
}
}
Repair
Replace the "=" with "==" or move the variable assignment outside of the "if".
Reference
http://g.oswego.edu/dl/html/javaCodingStd.html
|