You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DistinctVarargsChecker flags incorrectly on Mockito stubbings #6240
but this new check is considering the argument matchers to be duplicated. I think it is getting confused on the last any() call which has a type CopyOption and is the first argument to a varargs array of CopyOption....
If I specify the type explicitly, I get the same issue, i.e.
My workaround for now is to disable this check. I'm assuming this is not a valid case being flagged here, having read the docs for the check... if this is intentional would it be possible to document this use case on the check page on GitHub pages?
Thanks. I don't think we'd considered Mockito because most of the methods we flag are static and we have static mocking disabled internally. We have existing logic for detecting Mockito usage in other checks, so it if applied easily here, we might be able to get this fixed. I'll try to find time to have a look.
#6247 addresses the common case. I'm not sure when we'd get to the more thorough fix (which would handle matchers from classes other than the typical built-in Mockit ones), but if you (or anyone else) would benefit from it, let us know.
Oh, I guess I should look at the error text and see how it could be improved, too... someday... :\
It's complaining about passing any(Path.class) twice. Files.copy(foo, foo, ...) would likely be a bug, since it would be a no-op. But Files.copy(any(Path.class), any(Path.class), ...) is a different story because it's not a "real" call with "real" arguments.
(Also, it would also be weird to pass any CopyOption multiple times. That fits better with the "DistinctVarargsChecker" name of the check, but we then generalized the check beyond varargs without updating the name.)
Activity
Suppress errorprone DistinctVarargsChecker in AetherMavenArtifactPath…
cpovirk commentedon Oct 26, 2026
Thanks. I don't think we'd considered Mockito because most of the methods we flag are static and we have static mocking disabled internally. We have existing logic for detecting Mockito usage in other checks, so it if applied easily here, we might be able to get this fixed. I'll try to find time to have a look.
Allow passing `any()`, etc. multiple times in DistinctVarargsChecker.
cpovirk commentedon Oct 27, 2026
#6247 addresses the common case. I'm not sure when we'd get to the more thorough fix (which would handle matchers from classes other than the typical built-in Mockit ones), but if you (or anyone else) would benefit from it, let us know.
ascopes commentedon Oct 27, 2026
Thanks, what is the cause of the error exactly in this case? What does it consider to be duplicated?
cpovirk commentedon Oct 27, 2026
Oh, I guess I should look at the error text and see how it could be improved, too... someday... :\
It's complaining about passing
any(Path.class)twice.Files.copy(foo, foo, ...)would likely be a bug, since it would be a no-op. ButFiles.copy(any(Path.class), any(Path.class), ...)is a different story because it's not a "real" call with "real" arguments.cpovirk commentedon Oct 27, 2026
(Also, it would also be weird to pass any
CopyOptionmultiple times. That fits better with the "DistinctVarargsChecker" name of the check, but we then generalized the check beyond varargs without updating the name.)(@kluever FYI)