-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strict unused variable enforces lambda parameters #1355
Conversation
Generate changelog in
|
boolean isPrivateMethod = methodSymbol.getModifiers().contains(Modifier.PRIVATE); | ||
int index = methodSymbol.params.indexOf(varSymbol); | ||
Preconditions.checkState(index != -1, "symbol must be a parameter to the owning method"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be nice to log the symbol and the method if we're gonna throw? :)
"import java.util.function.BiFunction;", | ||
"class Test {", | ||
" private static BiFunction<String, String, Integer> doStuff() {", | ||
" BiFunction<String, String, Integer> first = (String value1, String value2) -> 1;", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd maybe use one of them to check that it only renames the other one
👍 |
…baseline into fo/unused-lambda-params
👍 |
Released 3.15.0 |
This just broke some code by dropping the contents before a lambda with a single (used) parameter |
This reverts commit 620c65b.
Before this PR
StrictUnusedVariable
would not ensure that all lambda parameters were unusedAfter this PR
==COMMIT_MSG==
StrictUnusedVariable
checks for unused lambda parameters==COMMIT_MSG==
Possible downsides?
Some code bases may have had existing conventions for denoting unused lambda parameters. However the fix that comes along with the rule should prevent upgrades from being blocked