params
is assigned to itself32
33 public void setApiRequestData(URL url, Map<String, String> params) {
34 url = url;
35 params = params;36 }
37
38 /**
url
is assigned to itself31 }
32
33 public void setApiRequestData(URL url, Map<String, String> params) {
34 url = url;35 params = params;
36 }
37
Description
A local variable is assigned to itself.
This is essentially a noop but it may be indicative of a different problem. It may be that the variable shadows another in a parent scope, or that the variable may shadow a field of the object itself. Such code can cause confusion and subtle logic errors that are hard to catch.
Bad Practice
public void foo() {
int x = 3;
int y = someInt;
// ...
x = x; // Useless self assignment.
}
Recommended
Always check that the correct variable is being assigned to (or from)
public void foo() {
int x = 3;
int y = someInt;
// ...
y = x; // Here, we assign x to y.
}
Check if you meant to assign a field or another local variable with a similar name instead.