Extend NullArgumentForNonNullParameter
to match calls to some Immutable*
methods and to ArgumentCaptor.forClass
.
#3680
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Extend
NullArgumentForNonNullParameter
to match calls to someImmutable*
methods and toArgumentCaptor.forClass
.Immutable*
methods of course already throwNullPointerException
. And while they're already annotated for nullness, they've been ignored by this checker because there are technical challenges with identifying the nullness of type-variable types loaded from.class
files.ArgumentCaptor.forClass
soon will throwNullPointerException
. See Improve vararg handling mockito/mockito#2807 (comment).To match
ArgumentCaptor.forClass
, we have to start checking test-only code. But for now, we check such code only for calls toArgumentCaptor.forClass
.(I suppose that we still don't handle the varargs parameters of the various
Immutable*
methods, since this entire check skips varargs, in part because varargs are confusing in general (b/232103314) and in part because we can't see annotations on a varargs-element type that is loaded from a.class
file. We could make an exception for these methods if we really wanted, but I doubt it's worth it.)