parameter-assignment
What it does
Section titled “What it does”Reports an assignment to a parameter of a method. No fix.
Why it matters
Section titled “Why it matters”A reassigned parameter means two things in one method: the value the caller passed, and the later one. A reader who sees the name expects the argument, and a later edit that reads the parameter gets the wrong value.
To fix, put the new value in a local variable.
Example
Section titled “Example”class A { int f(int n, int m) { n = 1; n++; int k = m; k = 2; return k + n;...Configuration
Section titled “Configuration”java: lint: rules: parameter-assignment: warn # off (default), warn, errorSuppress one line with sudsy-disable-next-line parameter-assignment in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| checkstyle | ParameterAssignment |
full |