Class BugChecker
java.lang.Object
com.google.errorprone.bugpatterns.BugChecker
- All Implemented Interfaces:
Suppressible, Serializable
- Direct Known Subclasses:
AbstractAsKeyOfSetOrMap, AbstractBanUnsafeAPIChecker, AbstractMockChecker, AbstractMustBeClosedChecker, AbstractPatternSyntaxChecker, AbstractReferenceEquality, AbstractReturnValueIgnored, AbstractToString, AbstractUseSwitch, AddNullMarkedToPackageInfo, AddressSelection, AlmostJavadoc, AlreadyChecked, AlwaysThrows, AmbiguousMethodReference, AndroidInjectionBeforeSuper, AnnotateFormatMethod, AnnotationPosition, ApiDiffChecker, ArgumentSelectionDefectChecker, ArrayEquals, ArrayFillIncompatibleType, ArrayHashCode, ArrayRecordComponent, ArraysAsListPrimitiveArray, AssertEqualsArgumentOrderChecker, AssertFalse, AssertionFailureIgnored, AssertThrowsMultipleStatements, AssignmentExpression, AssistedInjectAndInjectOnConstructors, AssistedInjectAndInjectOnSameConstructor, AssistedInjectScoping, AssistedParameters, ASTHelpersSuggestions, AsyncCallableReturnsNull, AsyncFunctionReturnsNull, AttemptedNegativeZero, AutoFactoryAtInject, AutoValueBoxedValues, AutoValueBuilderDefaultsInConstructor, AutoValueConstructorOrderChecker, AutoValueFinalMethods, AutoValueImmutableFields, AutoValueSubclassLeaked, AvoidObjectArrays, BadAnnotationImplementation, BadComparable, BadImport, BadInstanceof, BadShiftAmount, BigDecimalEquals, BigDecimalLiteralDouble, BinderIdentityRestoredDangerously, BindingToUnqualifiedCommonType, BooleanLiteral, BooleanParameter, BoxedPrimitiveConstructor, BugPatternNaming, BuilderReturnThis, BundleDeserializationCast, ByteBufferBackingArray, CacheLoaderNull, CanIgnoreReturnValueSuggester, CannotMockFinalClass, CannotMockMethod, CanonicalDuration, CatchAndPrintStackTrace, CatchFail, CatchingUnchecked, ChainedAssertionLosesContext, ChainingConstructorIgnoresParameter, CharacterGetNumericValue, CheckedExceptionNotThrown, CheckNotNullMultipleTimes, ClassCanBeStatic, ClassInitializationDeadlock, ClassName, ClassNamedLikeTypeParameter, ClassNewInstance, CloseableProvides, ClosingStandardOutputStreams, CollectionIncompatibleType, CollectionToArraySafeParameter, CollectionUndefinedEquality, CollectorShouldNotUseState, ComparableAndComparator, ComparableType, CompareToZero, ComparingThisWithNull, ComparisonContractViolated, ComparisonOutOfRange, CompatibleWithMisuse, CompileTimeConstantChecker, ComplexBooleanConstant, ComputeIfAbsentAmbiguousReference, ConditionalExpressionNumericPromotion, ConstantField, ConstantOverflow, ConstantPatternCompile, DangerousLiteralNullChecker, DateChecker, DateFormatConstant, DeadException, DeadThread, DeduplicateConstants, DeeplyNested, DefaultCharset, DefaultLocale, DefaultPackage, DepAnn, DeprecatedVariable, DereferenceWithNullBranch, DifferentNameButSame, DirectInvocationOnMock, DiscardedPostfixExpression, DistinctVarargsChecker, DoNotCallChecker, DoNotCallSuggester, DoNotClaimAnnotations, DoubleBraceInitialization, DoubleCheckedLocking, DuplicateBranches, DuplicateMapKeys, DurationFrom, DurationGetTemporalUnit, DurationTemporalUnit, DurationToLongTimeUnit, EffectivelyPrivate, EmptyBlockTag, EmptyCatch, EmptyIfStatement, EmptySetMultibindingContributions, EmptyTopLevelDeclaration, EnumOrdinal, EqualsBrokenForNull, EqualsGetClass, EqualsHashCode, EqualsIncompatibleType, EqualsMissingNullable, EqualsNaN, EqualsNull, EqualsReference, EqualsUnsafeCast, EqualsUsingHashCode, EqualsWrongThing, ErroneousBitwiseExpression, ErroneousThreadPoolConstructorChecker, EscapedEntity, ExpectedExceptionChecker, ExpensiveLenientFormatString, ExplicitArrayForVarargs, ExtendingJUnitAssert, ExtendsAutoValue, ExtendsObject, FallThrough, FieldCanBeFinal, FieldCanBeLocal, FieldCanBeStatic, FieldMissingNullable, Finalize, Finally, FloatCast, FloatingPointAssertionWithinEpsilon, FloatingPointLiteralPrecision, FloggerArgumentToString, FloggerFormatString, FloggerLogString, FloggerLogVarargs, FloggerLogWithCause, FloggerMessageFormat, FloggerPerWithoutRateLimit, FloggerRedundantIsEnabled, FloggerRequiredModifiers, FloggerSplitLogStatement, FloggerStringConcatenation, FloggerWithCause, FloggerWithoutCause, ForEachIterable, FormatString, FormatStringAnnotationChecker, FormatStringShouldUsePlaceholders, ForOverrideChecker, FragmentInjection, FragmentNotInstantiable, FromTemporalAccessor, FunctionalInterfaceClash, FunctionalInterfaceMethodChanged, FuturesGetCheckedIllegalExceptionType, FutureTransformAsync, FuzzyEqualsShouldNotBeUsedInEqualsMethod, GetClassOnAnnotation, GetClassOnClass, GetClassOnEnum, GuardedByChecker, GuiceNestedCombine, HardCodedSdCardPath, HashtableContains, HidingField, ICCProfileGetInstance, IdentifierName, IdentityBinaryExpression, IdentityHashMapBoxing, IdentityHashMapUsage, ImmutableAnnotationChecker, ImmutableChecker, ImmutableEnumChecker, ImmutableMemberCollection, ImmutableRefactoring, ImmutableSetForContains, ImplementAssertionWithChaining, ImpossibleNullComparison, Incomparable, IncompatibleArgumentType, IncompatibleModifiersChecker, InconsistentCapitalization, InconsistentHashCode, InconsistentOverloads, IncorrectMainMethod, IncrementInForLoopAndHeader, IndexOfChar, InexactVarargsConditional, InfiniteRecursion, InheritDoc, InitializeInline, InjectedConstructorAnnotations, InjectOnBugCheckers, InjectOnConstructorOfAbstractClass, InjectOnFinalField, InjectOnMemberAndConstructor, InlineFormatString, Inliner, InlineTrivialConstant, InputStreamSlowMultibyteRead, InsecureCipherMode, InstanceOfAndCastMatchWrongType, InstantTemporalUnit, InterfaceWithOnlyStatics, InterruptedExceptionSwallowed, Interruption, IntFloatConversion, IntLiteralCast, IntLongMath, InvalidBlockTag, InvalidInlineTag, InvalidJavaTimeConstant, InvalidLink, InvalidParam, InvalidSnippet, InvalidTargetingOnScopingAnnotation, InvalidThrows, InvalidThrowsLink, InvalidTimeZoneID, InvalidZoneId, IsInstanceIncompatibleType, IsInstanceOfClass, IsLoggableTagLength, IterableAndIterator, IterablePathParameter, JavaDurationGetSecondsGetNano, JavaDurationGetSecondsToToSeconds, JavaDurationWithNanos, JavaDurationWithSeconds, JavaInstantGetSecondsGetNano, JavaLangClash, JavaLocalDateTimeGetNano, JavaLocalTimeGetNano, JavaPeriodGetDays, JavaTimeDefaultTimeZone, JavaUtilDateChecker, JavaxInjectOnAbstractMethod, JavaxInjectOnFinalField, JdkObsolete, JodaConstructors, JodaDateTimeConstants, JodaDurationWithMillis, JodaInstantWithMillis, JodaNewPeriod, JodaPlusMinusLong, JodaTimeConverterManager, JodaToSelf, JodaWithDurationAddedLong, JUnit3FloatingPointComparisonWithoutDelta, JUnit3TestNotRun, JUnit4ClassAnnotationNonStatic, JUnit4ClassUsedInJUnit3, JUnit4EmptyMethods, JUnit4SetUpNotRun, JUnit4TearDownNotRun, JUnit4TestNotRun, JUnit4TestsNotRunWithinEnclosed, JUnitAmbiguousTestClass, JUnitAssertSameCheck, JUnitIncompatibleType, JUnitParameterMethodNotFound, LabelledBreakTarget, LambdaFunctionalInterface, LenientFormatStringValidation, LiteByteStringUtf8, LiteEnumValueOf, LocalDateTemporalAmount, LockNotBeforeTry, LockOnBoxedPrimitive, LockOnNonEnclosingClassLiteral, LogicalAssignment, LongDoubleConversion, LongFloatConversion, LongLiteralLowerCaseSuffix, LoopConditionChecker, LoopOverCharArray, LossyPrimitiveCompare, MalformedInlineTag, MathAbsoluteNegative, MathRoundIntLong, MemoizeConstantVisitorStateLookups, MethodCanBeStatic, MisformattedTestData, MislabeledAndroidString, MisleadingEmptyVarargs, MisleadingEscapedSpace, MisplacedScopeAnnotations, MissingBraces, MissingCasesInEnumSwitch, MissingDefault, MissingFail, MissingImplementsComparable, MissingOverride, MissingRefasterAnnotation, MissingRuntimeRetention, MissingSummary, MissingSuperCall, MissingTestCall, MisusedDateFormat, MixedArrayDimensions, MixedDescriptors, MixedMutabilityReturnType, MockIllegalThrows, MockitoDoSetup, MockitoUsage, MockNotUsedInProduction, ModifiedButNotUsed, ModifyCollectionInEnhancedForLoop, ModifyingCollectionWithItself, ModifySourceCollectionInStream, MoreThanOneInjectableConstructor, MoreThanOneQualifier, MoreThanOneScopeAnnotationOnClass, MultimapKeys, MultipleNullnessAnnotations, MultipleParallelOrSequentialCalls, MultipleTopLevelClasses, MultipleUnaryOperatorsInMethodCall, MultiVariableDeclaration, MutableGuiceModule, MutablePublicArray, NamedLikeContextualKeyword, NarrowCalculation, NarrowingCompoundAssignment, NCopiesOfChar, NegativeBoolean, NegativeCharLiteral, NestedInstanceOfConditions, NewFileSystem, NoAllocationChecker, NoCanIgnoreReturnValueOnClasses, NonApiType, NonAtomicVolatileUpdate, NonCanonicalStaticImport, NonCanonicalStaticMemberImport, NonCanonicalType, NonFinalCompileTimeConstant, NonFinalStaticField, NonOverridingEquals, NonRuntimeAnnotation, NotJavadoc, NullableConstructor, NullableOnContainingClass, NullableOptional, NullablePrimitive, NullablePrimitiveArray, NullableTypeParameter, NullableVoid, NullableWildcard, NullArgumentForNonNullParameter, NullNeedsCastForVarargs, NullOptional, NullTernary, ObjectEqualsForPrimitives, ObjectsHashCodePrimitive, OperatorPrecedence, OptionalMapToOptional, OptionalMapUnusedValue, OptionalNotPresent, OptionalOfRedundantMethod, OrphanedFormatString, OutlineNone, OverlappingQualifierAndScopeAnnotation, Overrides, OverridesGuiceInjectableMethod, OverridesJavaxInjectableMethod, OverrideThrowableToString, OverridingMethodInconsistentArgumentNamesChecker, PackageInfo, PackageLocation, ParameterComment, ParameterMissingNullable, ParameterName, ParametersButNotParameterized, ParcelableCreator, PatternMatchingInstanceof, PeriodFrom, PeriodGetTemporalUnit, PeriodTimeMath, PreconditionsCheckNotNullRepeated, PreconditionsInvalidPlaceholder, PreferInstanceofOverGetKind, PreferJavaTimeOverload, PreferredInterfaceType, PrimitiveArrayPassedToVarargsMethod, PrimitiveAtomicReference, PrivateConstructorForNoninstantiableModule, PrivateConstructorForUtilityClass, PrivateSecurityContractProtoAccess, ProtectedMembersInFinalClass, ProtocolBufferOrdinal, ProtoDurationGetSecondsGetNano, ProtoStringFieldReferenceEquality, ProtoTimestampGetSecondsGetNano, ProtoTruthMixedDescriptors, ProvidesMethodOutsideOfModule, ProvidesNull, PublicApiNamedStreamShouldReturnStream, QualifierOrScopeOnInjectMethod, QualifierWithTypeUse, RandomCast, RandomModInteger, ReachabilityFenceUsage, RedundantControlFlow, RedundantNullCheck, RedundantOverride, RedundantSetterCall, RedundantThrows, RefersToDaggerCodegen, RemoveUnusedImports, RequiredModifiersChecker, RestrictedApiChecker, RethrowReflectiveOperationExceptionAsLinkageError, ReturnAtTheEndOfVoidFunction, ReturnFromVoid, ReturnMissingNullable, ReturnsNullCollection, RobolectricShadowDirectlyOn, RuleNotRun, SameNameButDifferent, ScopeAnnotationOnInterfaceOrAbstractClass, ScopeOnModule, SelfAlwaysReturnsThis, SelfAssertion, SelfAssignment, SelfComparison, SelfEquals, SelfSet, SetUnrecognized, ShortCircuitBoolean, ShouldHaveEvenArgs, SizeGreaterThanOrEqualsZero, StatementSwitchToExpressionSwitch, StaticAssignmentInConstructor, StaticAssignmentOfThrowable, StaticGuardedByInstance, StaticMockMember, StaticOrDefaultInterfaceMethod, StaticQualifiedUsingExpression, StreamToIterable, StringBuilderInitWithChar, StringCaseLocaleUsage, StringCharset, StringConcatToTextBlock, StringFormatWithLiteral, StringJoin, StringSplitter, StronglyTypeByteString, StronglyTypeTime, SubstringOfZero, Suggester, SunApi, SuperCallToObjectMethod, SuppressWarningsDeprecated, SuppressWarningsWithoutExplanation, SwigMemoryLeak, SwitchDefault, SynchronizeOnNonFinalField, SystemConsoleNull, SystemExitOutsideMain, SystemOut, TemporalAccessorGetChronoField, TestExceptionChecker, TestParametersNotInitialized, TheoryButNoTheories, ThreadBuilderNameWithPlaceholder, ThreadJoinLoop, ThreadLocalUsage, ThreadPriorityCheck, ThreadSafeChecker, ThreeLetterTimeZoneID, ThrowIfUncheckedKnownChecked, ThrowIfUncheckedKnownUnchecked, ThrowNull, ThrowSpecificExceptions, ThrowsUncheckedException, TimeInStaticInitializer, TimeUnitConversionChecker, TimeUnitMismatch, TooManyParameters, ToStringReturnsNull, TraditionalSwitchExpression, TransientMisuse, TruthAssertExpected, TruthConstantAsserts, TruthContainsExactlyElementsInUsage, TruthGetOrDefault, TruthIncompatibleType, TryFailRefactoring, TryFailThrowable, TryWithResourcesVariable, TypeEqualsChecker, TypeNameShadowing, TypeParameterNaming, TypeParameterQualifier, TypeParameterShadowing, TypeParameterUnusedInFormals, UndefinedEquals, UnescapedEntity, UngroupedOverloads, UnicodeDirectionalityCharacters, UnicodeEscape, UnicodeInCode, UnnecessarilyFullyQualified, UnnecessarilyUsedValue, UnnecessarilyVisible, UnnecessaryAnonymousClass, UnnecessaryAssignment, UnnecessaryAsync, UnnecessaryBoxedAssignment, UnnecessaryBoxedVariable, UnnecessaryBreakInSwitch, UnnecessaryCheckNotNull, UnnecessaryCopy, UnnecessaryDefaultInEnumSwitch, UnnecessaryFinal, UnnecessaryLambda, UnnecessaryLongToIntConversion, UnnecessaryMethodInvocationMatcher, UnnecessaryMethodReference, UnnecessaryOptionalGet, UnnecessaryParentheses, UnnecessaryQualifier, UnnecessarySetDefault, UnnecessaryStaticImport, UnnecessaryStringBuilder, UnnecessaryTestMethodPrefix, UnnecessaryTypeArgument, UnrecognisedJavadocTag, UnsafeFinalization, UnsafeLocaleUsage, UnsafeReflectiveConstructionCast, UnsafeWildcard, UnsynchronizedOverridesSynchronized, UnusedAnonymousClass, UnusedCollectionModifiedInPlace, UnusedException, UnusedLabel, UnusedMethod, UnusedNestedClass, UnusedTypeParameter, UnusedVariable, URLEqualsHashCode, UrlInSee, UseBinds, UseCorrectAssertInTests, UsingJsr305CheckReturnValue, Validator, VarChecker, VariableNameSameAsType, Varifier, VarTypeName, VoidMissingNullable, VoidUsed, WaitNotInLoop, WakelockReleasedDangerously, WildcardImport, WithSignatureDiscouraged, WrongOneof, XorPower, YodaCondition, ZoneIdOfZ
A base class for implementing bug checkers. The
BugChecker supplies a Scanner
implementation for this checker, making it easy to use a single checker. Subclasses should also
implement one or more of the *Matcher interfaces in this class to declare which tree node
types to match against.- Author:
- Colin Decker, Eddie Aftandilian (eaftan@google.com)
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfaceprotected classATreePathScannerwhich skips trees which are suppressed for this check.static interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interface -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallNames()Returns all of the name strings that this checker should respect as part of a@SuppressWarningsannotation.buildDescription(Tree node) Returns a Description builder, which allows you to customize the diagnostic with a custom message or multiple fixes.buildDescription(com.sun.tools.javac.tree.JCTree tree) Returns a Description builder, which allows you to customize the diagnostic with a custom message or multiple fixes.buildDescription(com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition position) Returns a Description builder, which allows you to customize the diagnostic with a custom message or multiple fixes.The canonical name of the check.Set<Class<? extends Annotation>> Returns the custom suppression annotations for this checker, if custom suppression is used.describeMatch(Tree node) Helper to create a Description for the common case where there is no fix.describeMatch(Tree node, Fix fix) Helper to create a Description for the common case where there is a fix.describeMatch(com.sun.tools.javac.tree.JCTree node) Helper to create a Description for the common case where there is no fix.describeMatch(com.sun.tools.javac.tree.JCTree node, Fix fix) Helper to create a Description for the common case where there is a fix.describeMatch(com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition position) Helper to create a Description for the common case where there is no fix.describeMatch(com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition position, Fix fix) Helper to create a Description for the common case where there is a fix.booleanbooleaninthashCode()booleanisSuppressed(Tree tree, VisitorState state) Returns true if the given tree is annotated with a@SuppressWarningsthat disables this bug checker.booleanisSuppressed(com.sun.tools.javac.code.Symbol sym, VisitorState state) Returns true if the given symbol is annotated with a@SuppressWarningsor other annotation that disables this bug checker.linkUrl()message()booleanReturns true if this checker can be suppressed using@SuppressWarnings.booleansuppressedByAnyOf(Set<com.sun.tools.javac.util.Name> annotations, VisitorState s) com.google.common.collect.ImmutableRangeSet<Integer> suppressedRegions(VisitorState state) Computes a RangeSet of code regions which are suppressed by this bug checker.
-
Constructor Details
-
BugChecker
public BugChecker()
-
-
Method Details
-
describeMatch
Helper to create a Description for the common case where there is a fix. -
describeMatch
Helper to create a Description for the common case where there is a fix. -
describeMatch
@CheckReturnValue public Description describeMatch(com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition position, Fix fix) Helper to create a Description for the common case where there is a fix. -
describeMatch
Helper to create a Description for the common case where there is no fix. -
describeMatch
Helper to create a Description for the common case where there is no fix. -
describeMatch
@CheckReturnValue public Description describeMatch(com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition position) Helper to create a Description for the common case where there is no fix. -
buildDescription
Returns a Description builder, which allows you to customize the diagnostic with a custom message or multiple fixes. -
buildDescription
@CheckReturnValue public Description.Builder buildDescription(com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition position) Returns a Description builder, which allows you to customize the diagnostic with a custom message or multiple fixes. -
buildDescription
Returns a Description builder, which allows you to customize the diagnostic with a custom message or multiple fixes. -
canonicalName
Description copied from interface:SuppressibleThe canonical name of the check.- Specified by:
canonicalNamein interfaceSuppressible
-
allNames
Description copied from interface:SuppressibleReturns all of the name strings that this checker should respect as part of a@SuppressWarningsannotation.- Specified by:
allNamesin interfaceSuppressible
-
message
-
defaultSeverity
-
linkUrl
-
supportsSuppressWarnings
public boolean supportsSuppressWarnings()Description copied from interface:SuppressibleReturns true if this checker can be suppressed using@SuppressWarnings.- Specified by:
supportsSuppressWarningsin interfaceSuppressible
-
disableable
public boolean disableable() -
customSuppressionAnnotations
Description copied from interface:SuppressibleReturns the custom suppression annotations for this checker, if custom suppression is used.- Specified by:
customSuppressionAnnotationsin interfaceSuppressible
-
suppressedByAnyOf
- Specified by:
suppressedByAnyOfin interfaceSuppressible
-
isSuppressed
Returns true if the given tree is annotated with a@SuppressWarningsthat disables this bug checker. -
isSuppressed
Returns true if the given symbol is annotated with a@SuppressWarningsor other annotation that disables this bug checker. -
suppressedRegions
Computes a RangeSet of code regions which are suppressed by this bug checker. -
equals
-
hashCode
-