Why is this an issue?
There is no reason to re-assign a variable to itself. Either this statement is redundant and should be removed, or the re-assignment is a mistake
and some other value or variable was intended for the assignment instead.
Noncompliant code example
public void setName(String name) {
name = name;
}
Compliant solution
public void setName(String name) {
this.name = name;
}
Resources
- CERT, MSC12-C. - Detect and remove code that has no effect or is never executed