A private method ignores one of its parameters
What it finds
A parameter of a private method that the method never uses makes every caller compute a value for nothing. Since only the file can call a private method, the parameter can be removed together with the arguments for it.
A parameter counts as used when its name occurs anywhere else in the method. Left alone are methods with annotations, methods whose name appears in a method reference, whose parameters are fixed by the interface they implement, the methods serialization calls, and the parameter _.
From the rule's source, unused_parameter.rs.
import java.util.List; class Report { void print(List<String> lines) { lines.forEach(this::handle); format("x", 2); } private void handle(String line) {} private String format(String text, int width) {tx0 reports: the parameter width of the private method format is never used return text; } void open(int unusedButPublic) {}} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/java:ignored-private-parameter" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:ignored-private-parameter] reason="..."tx0 explain tx0/java:ignored-private-parameter shows the same in the terminal. Found a false positive? Report it.