Class UnusedReturnValueMatcher
java.lang.Object
com.google.errorprone.matchers.UnusedReturnValueMatcher
- All Implemented Interfaces:
Matcher<ExpressionTree>, Serializable
@CheckReturnValue
public final class UnusedReturnValueMatcher
extends Object
implements Matcher<ExpressionTree>
Matches expressions that invoke or reference a non-void method or constructor and which do not
use their return value and are not in a context where non-use of the return value is allowed.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration of known reasons that an unused return value may be allowed because of the context in which the method is used. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanAllow return values to be ignored in tests that expect an exception to be thrown.static UnusedReturnValueMatcherget(boolean allowInExceptionThrowers) Gets an instance of this matcher.getAllowReasons(ExpressionTree tree, VisitorState state) Returns a stream of reasons the given expression is allowed to have an unused return value based on its context.booleanisAllowed(ExpressionTree tree, VisitorState state) Returnstrueif the given expression is allowed to have an unused return value based on its context.static booleanisReturnValueUnused(ExpressionTree tree, VisitorState state) Returnstrueif and only if the giventreeis an invocation of or reference to a constructor or non-voidmethod for which the return value is considered unused.booleanmatches(ExpressionTree tree, VisitorState state) static booleanmockitoInvocation(Tree tree, VisitorState state) Don't match the method that is invoked throughMockito.verify(t)ordoReturn(val).when(t).
-
Method Details
-
get
Gets an instance of this matcher. -
matches
- Specified by:
matchesin interfaceMatcher<ExpressionTree>
-
isReturnValueUnused
Returnstrueif and only if the giventreeis an invocation of or reference to a constructor or non-voidmethod for which the return value is considered unused. -
isAllowed
Returnstrueif the given expression is allowed to have an unused return value based on its context. -
getAllowReasons
public Stream<UnusedReturnValueMatcher.AllowReason> getAllowReasons(ExpressionTree tree, VisitorState state) Returns a stream of reasons the given expression is allowed to have an unused return value based on its context. -
expectedExceptionTest
Allow return values to be ignored in tests that expect an exception to be thrown. -
mockitoInvocation
Don't match the method that is invoked throughMockito.verify(t)ordoReturn(val).when(t).
-