Class AbstractReturnValueIgnored

java.lang.Object
com.google.errorprone.bugpatterns.BugChecker
com.google.errorprone.bugpatterns.AbstractReturnValueIgnored
All Implemented Interfaces:
BugChecker.MemberReferenceTreeMatcher, BugChecker.MethodInvocationTreeMatcher, Suppressible, Serializable
Direct Known Subclasses:
CheckReturnValue, FutureReturnValueIgnored, IgnoredPureGetter, RectIntersectReturnValueIgnored, ReturnValueIgnored, RxReturnValueIgnored

public abstract class AbstractReturnValueIgnored
extends BugChecker
implements BugChecker.MethodInvocationTreeMatcher, BugChecker.MemberReferenceTreeMatcher
An abstract base class to match method invocations in which the return value is not used.
Author:
eaftan@google.com (Eddie Aftandilian)
See Also:
Serialized Form
  • Constructor Details

    • AbstractReturnValueIgnored

      public AbstractReturnValueIgnored()
  • Method Details

    • matchMethodInvocation

      public Description matchMethodInvocation​(com.sun.source.tree.MethodInvocationTree methodInvocationTree, VisitorState state)
      Specified by:
      matchMethodInvocation in interface BugChecker.MethodInvocationTreeMatcher
    • matchMemberReference

      public Description matchMemberReference​(com.sun.source.tree.MemberReferenceTree tree, VisitorState state)
      Specified by:
      matchMemberReference in interface BugChecker.MemberReferenceTreeMatcher
    • specializedMatcher

      protected abstract Matcher<? super com.sun.source.tree.ExpressionTree> specializedMatcher()
      Match whatever additional conditions concrete subclasses want to match (a list of known side-effect-free methods, has a @CheckReturnValue annotation, etc.).
    • allowInExceptionThrowers

      protected boolean allowInExceptionThrowers()
      Override this to return false to forbid discarding return values in testers that are testing whether an exception is thrown.
    • describeReturnValueIgnored

      protected Description describeReturnValueIgnored​(com.sun.source.tree.MethodInvocationTree methodInvocationTree, VisitorState state)
      Fixes the error by assigning the result of the call to the receiver reference, or deleting the method call. Subclasses may override if they prefer a different description.
    • describeReturnValueIgnored

      protected Description describeReturnValueIgnored​(com.sun.source.tree.MemberReferenceTree memberReferenceTree, VisitorState state)
      Uses the default description for results ignored via a method reference. Subclasses may override if they prefer a different description.