-
Notifications
You must be signed in to change notification settings - Fork 744
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
DistinctVarargsChecker produces a lot of false positives #4544
Comments
It looks like this has been the behavior since |
Thanks for the report. I think there are a few places where checks make assumptions that methods are idempotent in situations like this. Another example is IdentityBinaryExpression where it discourages Was the example you encountered literally |
The examples I encountered weren't exactly that, but were effectively the same thing. This was primarily in test code where we were generating IDs and entities to for tests. Set.of(createUserId(), createUserId()) I don't have any great ideas for a heuristic, I can see how you might want this check if the method being invoked here was something like an accessor. |
I think the other consideration (possibly the main one?) is that we'd have a spectacular quantity of false negatives if we only flagged provably-identical results. We have some logic in |
DistinctVarargsChecker
only compares arguments using their textual representation, which is an unreliable way to determine if two arguments are equivalent.For example,
DistinctVarargsChecker
emits a warnings for this code:The text was updated successfully, but these errors were encountered: