Class CheckReturnValue
java.lang.Object
com.google.errorprone.bugpatterns.BugChecker
com.google.errorprone.bugpatterns.AbstractReturnValueIgnored
com.google.errorprone.bugpatterns.CheckReturnValue
- All Implemented Interfaces:
BugChecker.ClassTreeMatcher, BugChecker.MemberReferenceTreeMatcher, BugChecker.MethodInvocationTreeMatcher, BugChecker.MethodTreeMatcher, BugChecker.NewClassTreeMatcher, BugChecker.ReturnTreeMatcher, ResultUsePolicyAnalyzer<ExpressionTree, VisitorState>, Suppressible, Serializable
public class CheckReturnValue
extends AbstractReturnValueIgnored
implements BugChecker.MethodTreeMatcher, BugChecker.ClassTreeMatcher
- Author:
- eaftan@google.com (Eddie Aftandilian)
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class BugChecker
BugChecker.AnnotatedTypeTreeMatcher, BugChecker.AnnotationTreeMatcher, BugChecker.ArrayAccessTreeMatcher, BugChecker.ArrayTypeTreeMatcher, BugChecker.AssertTreeMatcher, BugChecker.AssignmentTreeMatcher, BugChecker.BinaryTreeMatcher, BugChecker.BindingPatternTreeMatcher, BugChecker.BlockTreeMatcher, BugChecker.BreakTreeMatcher, BugChecker.CaseTreeMatcher, BugChecker.CatchTreeMatcher, BugChecker.ClassTreeMatcher, BugChecker.CompilationUnitTreeMatcher, BugChecker.CompoundAssignmentTreeMatcher, BugChecker.ConditionalExpressionTreeMatcher, BugChecker.ContinueTreeMatcher, BugChecker.DoWhileLoopTreeMatcher, BugChecker.EmptyStatementTreeMatcher, BugChecker.EnhancedForLoopTreeMatcher, BugChecker.ExportsTreeMatcher, BugChecker.ExpressionStatementTreeMatcher, BugChecker.ForLoopTreeMatcher, BugChecker.IdentifierTreeMatcher, BugChecker.IfTreeMatcher, BugChecker.ImportTreeMatcher, BugChecker.InstanceOfTreeMatcher, BugChecker.IntersectionTypeTreeMatcher, BugChecker.LabeledStatementTreeMatcher, BugChecker.LambdaExpressionTreeMatcher, BugChecker.LiteralTreeMatcher, BugChecker.MemberReferenceTreeMatcher, BugChecker.MemberSelectTreeMatcher, BugChecker.MethodInvocationTreeMatcher, BugChecker.MethodTreeMatcher, BugChecker.ModifiersTreeMatcher, BugChecker.ModuleTreeMatcher, BugChecker.NewArrayTreeMatcher, BugChecker.NewClassTreeMatcher, BugChecker.OpensTreeMatcher, BugChecker.PackageTreeMatcher, BugChecker.ParameterizedTypeTreeMatcher, BugChecker.ParenthesizedTreeMatcher, BugChecker.PrimitiveTypeTreeMatcher, BugChecker.ProvidesTreeMatcher, BugChecker.RequiresTreeMatcher, BugChecker.ReturnTreeMatcher, BugChecker.SuppressibleTreePathScanner<R,P>, BugChecker.SwitchExpressionTreeMatcher, BugChecker.SwitchTreeMatcher, BugChecker.SynchronizedTreeMatcher, BugChecker.ThrowTreeMatcher, BugChecker.TryTreeMatcher, BugChecker.TypeCastTreeMatcher, BugChecker.TypeParameterTreeMatcher, BugChecker.UnaryTreeMatcher, BugChecker.UnionTypeTreeMatcher, BugChecker.UsesTreeMatcher, BugChecker.VariableTreeMatcher, BugChecker.WhileLoopTreeMatcher, BugChecker.WildcardTreeMatcher, BugChecker.YieldTreeMatcher -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionprotected DescriptiondescribeReturnValueIgnored(MemberReferenceTree tree, VisitorState state) Uses the default description for results ignored via a method reference.protected DescriptiondescribeReturnValueIgnored(MethodInvocationTree tree, VisitorState state) Fixes the error by assigning the result of the call to the receiver reference, or deleting the method call.protected DescriptiondescribeReturnValueIgnored(NewClassTree tree, VisitorState state) Uses the default description for results ignored via a constructor call.com.google.common.collect.ImmutableMap<String, ?> getMatchMetadata(ExpressionTree tree, VisitorState state) Returns a map of optional metadata about why this check matched the given expression.getMethodPolicy(ExpressionTree expression, VisitorState state) Returns theResultUsePolicyfor the method used in the givenexpression.booleanisCovered(ExpressionTree tree, VisitorState state) Returns whether this checker makes any determination about whether the given expression's return value should be used or not.matchClass(ClassTree tree, VisitorState state) Validate that at most one ofCheckReturnValueandCanIgnoreReturnValueare applied to a class (or interface or enum).matchMethod(MethodTree tree, VisitorState state) Validate@CheckReturnValueandCanIgnoreReturnValueusage on methods.Return a matcher for method invocations in which the method being called should be considered must-be-used.Methods inherited from class AbstractReturnValueIgnored
allowInExceptionThrowers, getMessage, lostType, lostTypeMessage, matchMemberReference, matchMethodInvocation, matchNewClass, matchReturnMethods inherited from class BugChecker
allNames, buildDescription, buildDescription, buildDescription, canonicalName, customSuppressionAnnotations, defaultSeverity, describeMatch, describeMatch, describeMatch, describeMatch, describeMatch, describeMatch, disableable, equals, hashCode, isSuppressed, isSuppressed, isSuppressed, isSuppressed, linkUrl, message, supportsSuppressWarnings, suppressedByAnyOf, suppressedRegionsMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ResultUsePolicyAnalyzer
allNames, canonicalNameMethods inherited from interface Suppressible
allNames, canonicalName, customSuppressionAnnotations, supportsSuppressWarnings, suppressedByAnyOf
-
Field Details
-
CHECK_ALL_CONSTRUCTORS
- See Also:
-
CHECK_ALL_METHODS
- See Also:
-
-
Method Details
-
specializedMatcher
Return a matcher for method invocations in which the method being called should be considered must-be-used.- Specified by:
specializedMatcherin classAbstractReturnValueIgnored
-
getMethodPolicy
Description copied from interface:ResultUsePolicyAnalyzerReturns theResultUsePolicyfor the method used in the givenexpression.- Specified by:
getMethodPolicyin interfaceResultUsePolicyAnalyzer<ExpressionTree, VisitorState>- Overrides:
getMethodPolicyin classAbstractReturnValueIgnored
-
isCovered
Description copied from interface:ResultUsePolicyAnalyzerReturns whether this checker makes any determination about whether the given expression's return value should be used or not. Most checkers either determine that an expression is CRV or make no determination.- Specified by:
isCoveredin interfaceResultUsePolicyAnalyzer<ExpressionTree, VisitorState>- Overrides:
isCoveredin classAbstractReturnValueIgnored
-
getMatchMetadata
public com.google.common.collect.ImmutableMap<String,?> getMatchMetadata(ExpressionTree tree, VisitorState state) Description copied from interface:ResultUsePolicyAnalyzerReturns a map of optional metadata about why this check matched the given expression.- Specified by:
getMatchMetadatain interfaceResultUsePolicyAnalyzer<ExpressionTree, VisitorState>
-
matchMethod
Validate@CheckReturnValueandCanIgnoreReturnValueusage on methods.The annotations should not both be applied to the same method.
The annotations should not be applied to void-returning methods. Doing so makes no sense, because there is no return value to check.
- Specified by:
matchMethodin interfaceBugChecker.MethodTreeMatcher
-
matchClass
Validate that at most one ofCheckReturnValueandCanIgnoreReturnValueare applied to a class (or interface or enum).- Specified by:
matchClassin interfaceBugChecker.ClassTreeMatcher
-
describeReturnValueIgnored
Description copied from class:AbstractReturnValueIgnoredFixes 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.- Overrides:
describeReturnValueIgnoredin classAbstractReturnValueIgnored
-
describeReturnValueIgnored
Description copied from class:AbstractReturnValueIgnoredUses the default description for results ignored via a constructor call. Subclasses may override if they prefer a different description.- Overrides:
describeReturnValueIgnoredin classAbstractReturnValueIgnored
-
describeReturnValueIgnored
Description copied from class:AbstractReturnValueIgnoredUses the default description for results ignored via a method reference. Subclasses may override if they prefer a different description.- Overrides:
describeReturnValueIgnoredin classAbstractReturnValueIgnored
-