Example
Avoiding self comparisons can be as simple as finding code in which x == x are compared as shown in the example. It can be expanded to understand simple getters and the
this
keyword as well.
public
class
ClassA {
int
x;
public void
methodA() {
if
(x==x){
// ...
}
if
(this.x==x){
// ...
}
if
(getX()==x){
// ...
}
}
}
Solution
Remove 'x==x, this.x==x, getX()==x' and reconsider the logic of the code