Class ComparisonOutOfRange
- java.lang.Object
-
- com.google.errorprone.bugpatterns.BugChecker
-
- com.google.errorprone.bugpatterns.ComparisonOutOfRange
-
- All Implemented Interfaces:
BugChecker.BinaryTreeMatcher
,Suppressible
,Serializable
public class ComparisonOutOfRange extends BugChecker implements BugChecker.BinaryTreeMatcher
- Author:
- [email protected] (Bill Pugh), [email protected] (Eddie Aftandilian)
TODO(eaftan): Support other types of comparisons? Are there likely to be errors in those?
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.errorprone.bugpatterns.BugChecker
BugChecker.AnnotatedTypeTreeMatcher, BugChecker.AnnotationTreeMatcher, BugChecker.ArrayAccessTreeMatcher, BugChecker.ArrayTypeTreeMatcher, BugChecker.AssertTreeMatcher, BugChecker.AssignmentTreeMatcher, BugChecker.BinaryTreeMatcher, 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.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.NewArrayTreeMatcher, BugChecker.NewClassTreeMatcher, BugChecker.ParameterizedTypeTreeMatcher, BugChecker.ParenthesizedTreeMatcher, BugChecker.PrimitiveTypeTreeMatcher, BugChecker.ReturnTreeMatcher, BugChecker.SuppressibleTreePathScanner<A extends Object,B extends Object>, BugChecker.SwitchTreeMatcher, BugChecker.SynchronizedTreeMatcher, BugChecker.ThrowTreeMatcher, BugChecker.TryTreeMatcher, BugChecker.TypeCastTreeMatcher, BugChecker.TypeParameterTreeMatcher, BugChecker.UnaryTreeMatcher, BugChecker.UnionTypeTreeMatcher, BugChecker.VariableTreeMatcher, BugChecker.WhileLoopTreeMatcher, BugChecker.WildcardTreeMatcher
-
-
Constructor Summary
Constructors Constructor Description ComparisonOutOfRange()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Description
describe(com.sun.source.tree.BinaryTree tree, VisitorState state)
Suggested fixes are as follows.Description
matchBinary(com.sun.source.tree.BinaryTree tree, VisitorState state)
-
Methods inherited from class com.google.errorprone.bugpatterns.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, suppressedRegions
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.errorprone.matchers.Suppressible
allNames, canonicalName, customSuppressionAnnotations, supportsSuppressWarnings, suppressedByAnyOf
-
-
-
-
Method Detail
-
matchBinary
public Description matchBinary(com.sun.source.tree.BinaryTree tree, VisitorState state)
- Specified by:
matchBinary
in interfaceBugChecker.BinaryTreeMatcher
-
describe
public Description describe(com.sun.source.tree.BinaryTree tree, VisitorState state)
Suggested fixes are as follows. For the byte case, convert the literal to its byte representation. For example, "255" becomes "-1. For the character case, replace the comparison with "true"/"false" since it's not clear what was intended and that is semantically equivalent.TODO(eaftan): Suggested fixes don't handle side-effecting expressions, such as (d = reader.read()) == -1. Maybe add special case handling for assignments.
-
-