Uses of Class
com.google.errorprone.BugPattern
-
Uses of BugPattern in com.google.errorprone
Methods in com.google.errorprone with parameters of type BugPattern Modifier and Type Method Description static String
BugCheckerInfo. canonicalName(String className, BugPattern pattern)
static void
BugPatternValidator. validate(BugPattern pattern)
-
Uses of BugPattern in com.google.errorprone.bugpatterns
Classes in com.google.errorprone.bugpatterns with annotations of type BugPattern Modifier and Type Class Description class
AlreadyChecked
Bugpattern to find conditions which are checked more than once.class
AlwaysThrows
ABugChecker
; see the associatedBugPattern
annotation for details.class
AmbiguousMethodReference
ABugChecker
; see the associatedBugPattern
annotation for details.class
AnnotateFormatMethod
Detects occurrences of pairs of parameters being passed straight through toString.format(java.lang.String, java.lang.Object...)
from a method not annotated withFormatMethod
.class
AnnotationMirrorToString
ABugChecker
; see the associatedBugPattern
annotation for details.class
AnnotationPosition
Checks annotation positioning, and orphaned Javadocs.class
AnnotationValueToString
ABugChecker
; see the associatedBugPattern
annotation for details.class
ArrayAsKeyOfSetOrMap
Warns that users should not have an array as a key to a Set or Mapclass
ArrayEquals
class
ArrayFillIncompatibleType
Checks when Arrays.fill(Object[], Object) is called with object types that are guaranteed to result in an ArrayStoreException.class
ArrayHashCode
class
ArraysAsListPrimitiveArray
class
ArrayToString
class
AssertFalse
class
AssertionFailureIgnored
ABugChecker
; see the associatedBugPattern
annotation for details.class
AssertThrowsMultipleStatements
ABugChecker
; see the associatedBugPattern
annotation for details.class
AsyncCallableReturnsNull
Checks thatAsyncCallable
implementations do not directlyreturn null
.class
AsyncFunctionReturnsNull
Checks thatAsyncFunction
implementations do not directlyreturn null
.class
AutoValueBuilderDefaultsInConstructor
See summary for details.class
AutoValueFinalMethods
Checks the toString(), hashCode() and equals() methods are final in AutoValue classes.class
AutoValueImmutableFields
Flags mutable collections in AutoValue.class
AutoValueSubclassLeaked
MatchesAutoValue_
uses outside the containing file.class
BadAnnotationImplementation
Checker that ensures implementations ofAnnotation
override equals and hashCode.class
BadComparable
class
BadImport
class
BadInstanceof
Matches instanceof checks where the expression is a subtype of the checked type.class
BadShiftAmount
class
BanJNDI
ABugChecker
that detects use of the unsafe JNDI API system.class
BanSerializableRead
ABugChecker
that detects use of the unsafeSerializable
API.class
BareDotMetacharacter
A BugChecker; see the associated BugPattern for details.class
BigDecimalEquals
Matches use ofBigDecimal#equals
, which compares scale as well (which is not likely to be intended).class
BigDecimalLiteralDouble
Matches usages ofnew BigDecimal(double)
which lose precision.class
BooleanParameter
ABugChecker
; see the associatedBugPattern
annotation for details.class
BoxedPrimitiveConstructor
ABugChecker
; see the associatedBugPattern
annotation for details.class
BoxedPrimitiveEquality
ABugChecker
; see the associatedBugPattern
annotation for details.class
BugPatternNaming
See thesummary
.class
ByteBufferBackingArray
Checks when ByteBuffer.array() is used without calling .arrayOffset() to know the offset of the array, or when the buffer wasn't initialized using ByteBuffer.wrap() or ByteBuffer.allocate().class
CacheLoaderNull
ABugChecker
; see the associatedBugPattern
annotation for details.class
CannotMockFinalClass
Bug pattern to recognize attempts to mock final types.class
CannotMockFinalMethod
A BugPattern; see the summaryclass
CanonicalDuration
ABugChecker
; see the associatedBugPattern
annotation for details.class
CatchAndPrintStackTrace
ABugChecker
; see the associatedBugPattern
annotation for details.class
CatchFail
ABugChecker
; see the associatedBugPattern
annotation for details.class
CatchingUnchecked
Flags code which catchesRuntimeException
s under the guise of catchingException
.class
ChainedAssertionLosesContext
Identifies calls toassertThat
and similar methods inside the implementation of aSubject
assertion method.class
ChainingConstructorIgnoresParameter
Checks, if two constructors in a class both acceptFoo foo
and one calls the other, that the caller passesfoo
as a parameter.class
CharacterGetNumericValue
Checks for use of Character.getNumericValue and UCharacter.getNumericValueclass
CheckedExceptionNotThrown
Flags checked exceptions which are claimed to be thrown, but are not.class
CheckNotNullMultipleTimes
Checks for the same variable being checked against null twice in a method.class
CheckReturnValue
class
ClassCanBeStatic
class
ClassName
ABugChecker
; see the associatedBugPattern
annotation for details.class
ClassNamedLikeTypeParameter
class
ClassNewInstance
ABugChecker
; see the associatedBugPattern
annotation for details.class
CollectionToArraySafeParameter
class
CollectorShouldNotUseState
class
ComparableAndComparator
class
ComparableType
class
CompareToZero
Suggests comparing the result ofcompareTo
to only0
.class
ComparingThisWithNull
Check for expressions containingthis != null
orthis == null
class
ComparisonContractViolated
class
ComparisonOutOfRange
class
CompileTimeConstantChecker
Detects invocations of methods with a parameter annotated@CompileTimeConstant
such that the corresponding actual parameter is not a compile-time constant expression, and initialisation of fields declared@CompileTimeConstant final
such that the actual value is not a compile-time constant expression.class
ComplexBooleanConstant
class
ComputeIfAbsentAmbiguousReference
Flags ambiguous creations of objects inMap.computeIfAbsent(K, java.util.function.Function<? super K, ? extends V>)
.class
ConditionalExpressionNumericPromotion
class
ConstantField
ABugChecker
; see the associatedBugPattern
annotation for details.class
ConstantOverflow
ABugChecker
; see the associatedBugPattern
annotation for details.class
ConstantPatternCompile
Flags variables initialized withPattern.compile(String)
calls that could be constants.class
DangerousLiteralNullChecker
ABugChecker
; see the associatedBugPattern
annotation for details.class
DateFormatConstant
ABugChecker
; see the associatedBugPattern
annotation for details.class
DeadException
class
DeadThread
ABugChecker
; see the associatedBugPattern
annotation for details.class
DeduplicateConstants
A checker that suggests deduplicating literals with existing constant variables.class
DefaultCharset
ABugChecker
; see the associatedBugPattern
annotation for details.class
DefaultPackage
Java classes shouldn't use default package.class
DepAnn
Matches the behaviour of the javac dep-ann Xlint warning.class
DeprecatedVariable
ABugChecker
; see the associatedBugPattern
annotation for details.class
DifferentNameButSame
Discourages using multiple names to refer to the same type within a file (e.g.class
DirectInvocationOnMock
A bugpattern; see the description.class
DiscardedPostfixExpression
ABugChecker
; see the associatedBugPattern
annotation for details.class
DistinctVarargsChecker
ErrorProne checker to generate warning when method expecting distinct varargs is invoked with same variable argument.class
DoNotCallChecker
ABugChecker
; see the associatedBugPattern
annotation for details.class
DoNotCallSuggester
If a method always throws an exception, consider annotating it with@DoNotCall
to prevent calls at compile-time instead failing at runtime.class
DoNotClaimAnnotations
ABugChecker
; see the associatedBugPattern
annotation for details.class
DoNotMockAutoValue
Suggests not mocking AutoValue classes.class
DoNotMockChecker
Points out if a Mockito or EasyMock mock is mocking an object that would be better off being tested using an alternative instance.class
DoubleBraceInitialization
ABugChecker
; see the associatedBugPattern
annotation for details.class
DuplicateMapKeys
Flags duplicate keys used in ImmutableMap construction.class
EmptyCatch
ABugChecker
; see the associatedBugPattern
annotation for details.class
EmptyIfStatement
This checker finds and fixes empty statements after an if, with no else part.class
EmptyTopLevelDeclaration
ABugChecker
; see the associatedBugPattern
annotation for details.class
EqualsGetClass
Discourages the use ofObject.getClass()
when implementingObject.equals(Object)
for non-final classes.class
EqualsHashCode
Classes that overrideObject.equals(java.lang.Object)
should also overrideObject.hashCode()
.class
EqualsIncompatibleType
class
EqualsNaN
class
EqualsNull
ABugChecker
; see the associatedBugPattern
annotation for details.class
EqualsReference
class
EqualsUnsafeCast
Checks forequals
implementations making unsafe casts.class
EqualsUsingHashCode
Discourages implementingequals
usinghashCode
.class
EqualsWrongThing
Checks forequals
implementations comparing non-corresponding fields.class
ErroneousBitwiseExpression
A BugPattern; see the summary.class
ErroneousThreadPoolConstructorChecker
ErrorProne checker to generate warning wheneverThreadPoolExecutor
is constructed with differentcorePoolSize
andmaximumPoolSize
using an unboundedworkQueue
class
ExpectedExceptionChecker
ABugChecker
; see the associatedBugPattern
annotation for details.class
ExtendingJUnitAssert
class
ExtendsAutoValue
Makes sure that you are not extending a class that has @AutoValue as an annotation.class
FallThrough
ABugChecker
; see the associatedBugPattern
annotation for details.class
FieldCanBeFinal
class
FieldCanBeLocal
Flags fields which can be replaced with local variables.class
FieldCanBeStatic
Finds fields which can be safely made static.class
Finally
Matches the behaviour of javac's finally Xlint warning.class
FloatCast
ABugChecker
; see the associatedBugPattern
annotation for details.class
FloatingPointAssertionWithinEpsilon
Detects usages ofFloat,DoubleSubject.isWithin(TOLERANCE).of(EXPECTED)
where there are no other floating point values other thanEXPECTED
with satisfy the assertion, butTOLERANCE
is not zero.class
FloatingPointLiteralPrecision
ABugChecker
; see the associatedBugPattern
annotation for details.class
ForEachIterable
ABugChecker
; see the associatedBugPattern
annotation for details.class
ForOverrideChecker
Verifies that methods markedForOverride
are only called from the defining class.class
FunctionalInterfaceClash
ABugChecker
; see the associatedBugPattern
annotation for details.class
FunctionalInterfaceMethodChanged
class
FutureReturnValueIgnored
See BugPattern annotation.class
FuturesGetCheckedIllegalExceptionType
Checks for calls to Guava'sFutures.getChecked
method that will always fail because they pass an incompatible exception type.class
FuzzyEqualsShouldNotBeUsedInEqualsMethod
class
GetClassOnAnnotation
ABugChecker
; see the associatedBugPattern
annotation for details.class
GetClassOnClass
class
GetClassOnEnum
ABugChecker
; see the associatedBugPattern
annotation for details.class
HashtableContains
ABugChecker
; see the associatedBugPattern
annotation for details.class
HidingField
class
IdentityBinaryExpression
ABugChecker
; see the associatedBugPattern
annotation for details.class
IdentityHashMapBoxing
ABugChecker
; see the associatedBugPattern
annotation for details.class
IdentityHashMapUsage
ABugChecker
; see the associatedBugPattern
annotation for details.class
IgnoredPureGetter
Flags ignored return values from pure getters.class
ImmutableMemberCollection
Refactoring to suggest Immutable types for member collection that are not mutated.class
ImmutableSetForContains
Refactoring to suggest usingprivate static final
ImmutableSet
overImmutableList
when using only contains, containsAll and isEmpty.class
ImplementAssertionWithChaining
Migrates Truth subjects from a manual "test and fail" approach to one usingSubject.check(...)
.class
Incomparable
ABugChecker
; see the associatedBugPattern
annotation for details.class
IncompatibleModifiersChecker
class
InconsistentCapitalization
Checker for variables under the same scope that only differ in capitalization.class
InconsistentHashCode
Looks for hashCode implementations which are inconsistent with equals.class
IncorrectMainMethod
Bugpattern for incorrect overloads of main.class
IncrementInForLoopAndHeader
class
IndexOfChar
ABugChecker
; see the associatedBugPattern
annotation for details.class
InexactVarargsConditional
ABugChecker
; see the associatedBugPattern
annotation for details.class
InfiniteRecursion
ABugChecker
; see the associatedBugPattern
annotation for details.class
InitializeInline
Bugpattern to encourage initializing effectively final variables inline with their declaration, if possible.class
InputStreamSlowMultibyteRead
Checks that InputStreams should override int read(byte[], int, int);class
InsecureCipherMode
class
InstanceOfAndCastMatchWrongType
class
InterfaceWithOnlyStatics
Bugpattern to detect interfaces used only to store static fields/methods.class
InterruptedExceptionSwallowed
Checks for cases where anInterruptedException
is caught as part of a catch block catching a supertype, and not specially handled.class
Interruption
ABugChecker
; see the associatedBugPattern
annotation for details.class
IntLongMath
ABugChecker
; see the associatedBugPattern
annotation for details.class
InvalidPatternSyntax
class
InvalidTimeZoneID
class
InvalidZoneId
Validates ZoneId.class
IsInstanceIncompatibleType
class
IsInstanceOfClass
ABugChecker
; see the associatedBugPattern
annotation for details.class
IterableAndIterator
class
IterablePathParameter
ABugChecker
; see the associatedBugPattern
annotation for details.class
JavaLangClash
ABugChecker
; see the associatedBugPattern
annotation for details.class
JavaUtilDateChecker
ABugChecker
; see the associatedBugPattern
annotation for details.class
JdkObsolete
ABugChecker
; see the associatedBugPattern
annotation for details.class
JUnit3FloatingPointComparisonWithoutDelta
Detects floating-point assertEquals() calls that will not work in JUnit 4.class
JUnit3TestNotRun
A bugpattern; see the associated summary.class
JUnit4ClassAnnotationNonStatic
@BeforeClass
or@AfterClass
should be applied to static methods.class
JUnit4ClassUsedInJUnit3
class
JUnit4SetUpNotRun
Checks for the existence of a JUnit3 style setUp() method in a JUnit4 test class or methods annotated with a non-JUnit4 @Before annotation.class
JUnit4TearDownNotRun
Checks for the existence of a JUnit3 style tearDown() method in a JUnit4 test class or methods annotated with a non-JUnit4 @After annotation.class
JUnit4TestNotRun
class
JUnit4TestsNotRunWithinEnclosed
Finds tests that won't run due to the enclosing runner.class
JUnitAmbiguousTestClass
class
JUnitAssertSameCheck
Points out if an object is tested for reference equality to itself using JUnit library.class
JUnitParameterMethodNotFound
Checks if the methods specified injunitparams.Parameters
annotation to provide parameters exists.class
LambdaFunctionalInterface
class
LiteByteStringUtf8
class
LiteEnumValueOf
Points out if #valueOf() is called on a Protocol Buffer Enum.class
LiteProtoToString
Flags calls totoString
on lite protos.class
LockNotBeforeTry
Suggests that calls toLock.lock
must be immediately followed by atry-finally
that callsLock.unlock
.class
LockOnBoxedPrimitive
Detects locks on boxed primitives.class
LogicalAssignment
ABugChecker
; see the associatedBugPattern
annotation for details.class
LongDoubleConversion
ABugChecker
; see the associatedBugPattern
annotation for details.class
LongFloatConversion
ABugChecker
; see the associatedBugPattern
annotation for details.class
LongLiteralLowerCaseSuffix
Matcher for along
literal with a lower-case ell for a suffix (e.g.class
LoopConditionChecker
ABugChecker
; see the associatedBugPattern
annotation for details.class
LoopOverCharArray
ABugChecker
; see the associatedBugPattern
annotation for details.class
LossyPrimitiveCompare
Checker to prevent usages of comparison methods where both the operands undergo lossy widening.class
MathAbsoluteRandom
class
MathRoundIntLong
Check for calls to Math'sMath.round(float)
with an integer or long parameter.class
MemberName
Flags a few ways in which member names may violate the style guide.class
MemoizeConstantVisitorStateLookups
ABugChecker
; see the associatedBugPattern
annotation for details.class
MethodCanBeStatic
ABugChecker
; see the associatedBugPattern
annotation for details.class
MissingBraces
ABugChecker
; see the associatedBugPattern
annotation for details.class
MissingCasesInEnumSwitch
ABugChecker
; see the associatedBugPattern
annotation for details.class
MissingDefault
ABugChecker
; see the associatedBugPattern
annotation for details.class
MissingFail
class
MissingImplementsComparable
ABugChecker
; see the associatedBugPattern
annotation for details.class
MissingOverride
ABugChecker
; see the associatedBugPattern
annotation for details.class
MissingSuperCall
class
MissingTestCall
Matches test helpers which require a terminating method to be called.class
MisusedDayOfYear
Ban use of D (day-of-year) in a date format pattern that also contains M (month-of-year).class
MisusedWeekYear
Ban use of YYYY in a SimpleDateFormat pattern, unless it is being used for a week date.class
MixedArrayDimensions
ABugChecker
; see the associatedBugPattern
annotation for details.class
MixedDescriptors
Checks for calls toDescriptor#findFieldByNumber
with field numbers from a different proto.class
MixedMutabilityReturnType
Flags methods which return mutable collections from some code paths, but immutable ones from others.class
MockitoUsage
ABugChecker
; see the associatedBugPattern
annotation for details.class
MockNotUsedInProduction
A BugPattern; see the summary.class
ModifiedButNotUsed
Matches creation of new collections/proto builders which are modified but never used.class
ModifyCollectionInEnhancedForLoop
class
ModifyingCollectionWithItself
class
ModifySourceCollectionInStream
Identify the backing collection source of a stream and reports if the source is mutated during the stream operations.class
MultipleParallelOrSequentialCalls
class
MultipleTopLevelClasses
ABugChecker
; see the associatedBugPattern
annotation for details.class
MultipleUnaryOperatorsInMethodCall
class
MultiVariableDeclaration
ABugChecker
; see the associatedBugPattern
annotation for details.class
MustBeClosedChecker
Checks if a constructor or method annotated withMustBeClosed
is called within the resource variable initializer of a try-with-resources statement.class
MutablePublicArray
Check for public static final declaration of Arrays.class
NarrowCalculation
A BugPattern; see the summary.class
NarrowingCompoundAssignment
ABugChecker
; see the associatedBugPattern
annotation for details.class
NCopiesOfChar
ABugChecker
; see the associatedBugPattern
annotation for details.class
NegativeCharLiteral
ABugChecker
; see the associatedBugPattern
annotation for details.class
NestedInstanceOfConditions
class
NoAllocationChecker
Checks methods annotated with@NoAllocation
to ensure they really do not allocate.class
NonAtomicVolatileUpdate
Detects non-atomic updates to volatile variables.class
NonCanonicalStaticImport
Types shouldn't be statically by their non-canonical name.class
NonCanonicalStaticMemberImport
Members shouldn't be statically imported by their non-canonical name.class
NonCanonicalType
Flags types being referred to by their non-canonical name.class
NonFinalCompileTimeConstant
Enforce that @CompileTimeConstant parameters are final or effectively final.class
NonOverridingEquals
Bug checker for equals methods that don't actually override equals.class
NonRuntimeAnnotation
class
NullableConstructor
ABugChecker
; see the associatedBugPattern
annotation for details.class
NullableOnContainingClass
A bugpattern; see the summary.class
NullablePrimitive
class
NullablePrimitiveArray
ABugChecker
; see the associatedBugPattern
annotation for details.class
NullableVoid
ABugChecker
; see the associatedBugPattern
annotation for details.class
NullOptional
Flags passing literal null toOptional
-accepting APIs.class
NullTernary
ABugChecker
; see the associatedBugPattern
annotation for details.class
ObjectEqualsForPrimitives
Check for usage ofObjects.equal
on primitive types.class
ObjectsHashCodePrimitive
Check for calls to Objects'Objects.hashCode(java.lang.Object)
with a primitive parameter.class
ObjectToString
Warns against calling toString() on Objects which don't have toString() method overridden and won't produce meaningful output.class
OperatorPrecedence
ABugChecker
; see the associatedBugPattern
annotation for details.class
OptionalEquality
ABugChecker
; see the associatedBugPattern
annotation for details.class
OptionalMapToOptional
MatchesOptional#map
mapping to anotherOptional
.class
OptionalMapUnusedValue
ReplacesOptional.map
withOptional.ifPresent
if the value is unused.class
OptionalNotPresent
class
OptionalOfRedundantMethod
Checks ifOptional#of
is chained with a redundant method.class
OrphanedFormatString
ABugChecker
; see the associatedBugPattern
annotation for details.class
OutlineNone
Check for the a11y antipattern of setting CSS outline attributes to none or 0.class
Overrides
Matches the behaviour of javac's overrides Xlint warning.class
OverrideThrowableToString
Warns against overriding toString() in a Throwable class and suggests getMessage()class
PackageInfo
ABugChecker
; see the associatedBugPattern
annotation for details.class
PackageLocation
ABugChecker
; see the associatedBugPattern
annotation for details.class
ParameterComment
ABugChecker
; see the associatedBugPattern
annotation for details.class
ParameterName
ABugChecker
; see the associatedBugPattern
annotation for details.class
ParametersButNotParameterized
Flags uses of parameters in non-parameterized tests.class
PreconditionsCheckNotNullRepeated
Checks that Precondition.checkNotNull is not invoked with same arg twice.class
PreconditionsInvalidPlaceholder
class
PreferredInterfaceType
Tightens types which refer to an Iterable, Map, Multimap, etc.class
PrimitiveArrayPassedToVarargsMethod
class
PrimitiveAtomicReference
Discourages inadvertently using reference equality on boxed primitives in AtomicReference.class
PrivateConstructorForUtilityClass
class
PrivateSecurityContractProtoAccess
Check for disallowed access to private_do_not_access_or_else proto fields.class
ProtectedMembersInFinalClass
Flags protected members in final classes.class
ProtoBuilderReturnValueIgnored
Highlights cases where a proto's build method has its return value ignored.class
ProtocolBufferOrdinal
Points out if #ordinal() is called on a Protocol Buffer Enum.class
ProtoFieldNullComparison
Matches comparison of proto fields tonull
.class
ProtoRedundantSet
Checks that protocol buffers built with chained builders don't set the same field twice.class
ProtoStringFieldReferenceEquality
class
ProtoTruthMixedDescriptors
Checks thatProtoTruth
'signoringFields
is passed field numbers from the correct proto.class
PublicApiNamedStreamShouldReturnStream
Checks if public APIs named "stream" returns a type whose name ends with Stream.class
RandomCast
ABugChecker
; see the associatedBugPattern
annotation for details.class
RandomModInteger
class
ReachabilityFenceUsage
ABugChecker
; see the associatedBugPattern
annotation for details.class
RedundantOverride
Removes overrides which purely pass through to the method in the super class.class
RedundantThrows
ABugChecker
; see the associatedBugPattern
annotation for details.class
ReferenceEquality
ABugChecker
; see the associatedBugPattern
annotation for details.class
RemoveUnusedImports
class
RequiredModifiersChecker
class
RestrictedApiChecker
Check for non-allowlisted callers to RestrictedApiChecker.class
RethrowReflectiveOperationExceptionAsLinkageError
ABugChecker
; see the associatedBugPattern
annotation for details.class
ReturnsNullCollection
Flags methods with collection return types which returnnull
in some cases but don't annotate the method as @Nullable.class
ReturnValueIgnored
A checker which produces an error when a return value is accidentally discarded.class
RobolectricShadowDirectlyOn
ABugChecker
; see the summary.class
RxReturnValueIgnored
ABugChecker
; see the associatedBugPattern
for details.class
SameNameButDifferent
Looks for types being shadowed by other types in a way that may be confusing.class
SelfAlwaysReturnsThis
Non-abstract instance methods namedself()
that return the enclosing class must alwaysreturn this
.class
SelfAssignment
TODO(eaftan): Consider cases where the parent is not a statement or there is no parent?class
SelfComparison
Points out if an object is compared to itself.class
SelfEquals
class
ShortCircuitBoolean
class
ShouldHaveEvenArgs
Checks that variable argument methods have even number of arguments.class
SizeGreaterThanOrEqualsZero
Finds instances where one usesCollection#size() >= 0
orT[].length > 0
.class
StaticAssignmentInConstructor
Checks for static fields being assigned within constructors.class
StaticAssignmentOfThrowable
Checks for static fields being assigned withThrowable
.class
StaticMockMember
ABugChecker
; see the associatedBugPattern
annotation for details.class
StaticQualifiedUsingExpression
class
StreamResourceLeak
ABugChecker
; see the associatedBugPattern
annotation for details.class
StreamToIterable
Discouragestream::iterator
to createIterable
s.class
StreamToString
ABugChecker
; see the associatedBugPattern
annotation for details.class
StringBuilderInitWithChar
class
StringSplitter
ABugChecker
; see the associatedBugPattern
annotation for details.class
StronglyTypeByteString
Flags fields which would be better expressed as ByteStrings rather than primitive byte arrays.class
SubstringOfZero
Check for calls to String'sfoo.substring(0)
.class
SuppressWarningsDeprecated
Find uses of SuppressWarnings with "deprecated".class
SuppressWarningsWithoutExplanation
Finds occurrences of@SuppressWarnings
where there is definitely no explanation for why it is safe.class
SwigMemoryLeak
class
SwitchDefault
ABugChecker
; see the associatedBugPattern
annotation for details.class
SymbolToString
Flagscom.sun.tools.javac.code.Symbol#toString
usage inBugChecker
s.class
SystemExitOutsideMain
Check for calls toSystem.exit()
outside of a main method.class
SystemOut
ABugChecker
; see the associatedBugPattern
annotation for details.class
TestExceptionChecker
ABugChecker
; see the associatedBugPattern
annotation for details.class
TestParametersNotInitialized
Flags uses of parameters in non-parameterized tests.class
TheoryButNoTheories
Flags uses of@Theory
(and others) in non-Theories
-run tests.class
ThreadJoinLoop
class
ThreadLocalUsage
ABugChecker
; see the associatedBugPattern
annotation for details.class
ThreeLetterTimeZoneID
class
ThrowIfUncheckedKnownChecked
Catches no-op calls toThrowables.throwIfUnchecked
.class
ThrowNull
ABugChecker
; see the associatedBugPattern
annotation for details.class
ThrowSpecificExceptions
Bugpattern to discourage throwing base exception classes.class
ThrowsUncheckedException
Suggests to remove the unchecked throws clause.class
TooManyParameters
ABugChecker
; see the associatedBugPattern
annotation for details.class
ToStringReturnsNull
ToString should not return null.class
TransientMisuse
Warns against use of bothstatic
andtransient
modifiers on field declarations.class
TreeToString
Flagscom.sun.source.tree.Tree#toString
usage inBugChecker
s.class
TruthAssertExpected
Detects usages of Truth assertions with the expected and actual values reversed.class
TruthConstantAsserts
Points out if Truth Library assert is called on a constant.class
TruthGetOrDefault
Flags ambiguous usages ofMap#getOrDefault
withinTruth#assertThat
.class
TruthSelfEquals
Points out if an object is tested for equality/inequality to itself using Truth Libraries.class
TryFailRefactoring
ABugChecker
; see the associatedBugPattern
annotation for details.class
TryFailThrowable
A bug checker for the following code pattern:class
TryWithResourcesVariable
ABugChecker
; see the associatedBugPattern
annotation for details.class
TypeEqualsChecker
Flags com.sun.tools.javac.code.Type#equals usage.class
TypeNameShadowing
Warns when a type parameter shadows another type name in scope.class
TypeParameterNaming
Enforces type parameters match the google style guide.class
TypeParameterQualifier
ABugChecker
; see the associatedBugPattern
annotation for details.class
TypeParameterShadowing
class
TypeParameterUnusedInFormals
class
TypeToString
Flagscom.sun.tools.javac.code.Type#toString
usage inBugChecker
s.class
UndefinedEquals
Flags types which do not have well-defined equals behavior.class
UngroupedOverloads
class
UnicodeDirectionalityCharacters
Bans, without the possibility of suppression, the use of direction-changing Unicode escapes.class
UnicodeEscape
Replaces printable ASCII unicode escapes with the literal version.class
UnicodeInCode
Bans using non-ASCII Unicode characters outside string literals and comments.class
UnnecessarilyFullyQualified
Flags uses of fully qualified names which are not ambiguous if imported.class
UnnecessarilyVisible
Suggests restricting the visibility of methods which should only be called by a framework.class
UnnecessaryAnonymousClass
ABugChecker
; see the associatedBugPattern
annotation for details.class
UnnecessaryAssignment
Discourage manual initialization or assignment to fields annotated with framework annotations.class
UnnecessaryBoxedAssignment
Finds and fixes unnecessarily boxed return expressions.class
UnnecessaryBoxedVariable
Finds and fixes unnecessarily boxed variables.class
UnnecessaryDefaultInEnumSwitch
ABugChecker
; see the associatedBugPattern
annotation for details.class
UnnecessaryFinal
Removesfinal
from non-field variables.class
UnnecessaryLambda
ABugChecker
; see the associatedBugPattern
annotation for details.class
UnnecessaryLongToIntConversion
ABugChecker
; see the associatedBugPattern
annotation for details.class
UnnecessaryMethodInvocationMatcher
Matchers.methodInvocation(Matcher)
is not exactly deprecated, but it is legacy, and in particular is not needed when the argument is a MethodMatcher, since MethodMatcher already does the unwrapping that methodInvocation does.class
UnnecessaryMethodReference
Matches unnecessary uses of method references.class
UnnecessaryOptionalGet
A refactoring to replace Optional.get() with lambda arg in expressions passed as arg to member functions of Optionals.class
UnnecessaryParentheses
ABugChecker
; see the associatedBugPattern
annotation for details.class
UnnecessarySetDefault
ABugChecker
; see the associatedBugPattern
annotation for details.class
UnnecessaryStaticImport
ABugChecker
; see the associatedBugPattern
annotation for details.class
UnnecessaryTypeArgument
ABugChecker
; see the associatedBugPattern
annotation for details.class
UnsafeFinalization
ABugChecker
; see the associatedBugPattern
annotation for details.class
UnsafeLocaleUsage
Flags unsafe usages of theLocale
constructor and class methods.class
UnsafeReflectiveConstructionCast
Checks unsafe instance creation via reflection.class
UnsynchronizedOverridesSynchronized
ABugChecker
; see the associatedBugPattern
annotation for details.class
UnusedAnonymousClass
ABugChecker
; see the associatedBugPattern
annotation for details.class
UnusedCollectionModifiedInPlace
class
UnusedException
Bugpattern for catch blocks which catch an exception but throw another one without wrapping the original.class
UnusedMethod
Bugpattern to detect unused declarations.class
UnusedNestedClass
Bugpattern to detect unused nested classes.class
UnusedTypeParameter
A BugPattern; see the summary.class
UnusedVariable
Bugpattern to detect unused declarations.class
URLEqualsHashCode
Points out on creation of Set and HashMap of type java.net.URL.class
UseCorrectAssertInTests
class
UseEnumSwitch
ABugChecker
; see the associatedBugPattern
annotation for details.class
VarChecker
ABugChecker
; see the associatedBugPattern
annotation for details.class
VariableNameSameAsType
Check for variables and types with the same nameclass
Varifier
Converts some local variables to usevar
.class
VarTypeName
ABugChecker
; see the associatedBugPattern
annotation for details.class
WaitNotInLoop
class
WildcardImport
ABugChecker
; see the associatedBugPattern
annotation for details.class
WithSignatureDiscouraged
MethodMatchers.MethodClassMatcher.withSignature(String)
is discouraged: most usages should use .named and/or .withParameters instead.class
WrongOneof
Matches always-default expressions in oneof switches.class
XorPower
ABugChecker
; see the associatedBugPattern
annotation for details. -
Uses of BugPattern in com.google.errorprone.bugpatterns.android
Classes in com.google.errorprone.bugpatterns.android with annotations of type BugPattern Modifier and Type Class Description class
BinderIdentityRestoredDangerously
class
BundleDeserializationCast
class
FragmentInjection
class
FragmentNotInstantiable
class
HardCodedSdCardPath
class
IsLoggableTagLength
class
MislabeledAndroidString
Replacement of misleading android.R.string constants with more intuitive ones.class
ParcelableCreator
BugPattern to detect classes which implement android.os.Parcelable but don't have public static CREATOR.class
RectIntersectReturnValueIgnored
class
StaticOrDefaultInterfaceMethod
class
WakelockReleasedDangerously
-
Uses of BugPattern in com.google.errorprone.bugpatterns.apidiff
Classes in com.google.errorprone.bugpatterns.apidiff with annotations of type BugPattern Modifier and Type Class Description class
AndroidJdkLibsChecker
Checks for uses of classes, fields, or methods that are not compatible with legacy Android devices.class
Java7ApiChecker
Checks for uses of classes, fields, or methods that are not compatible with JDK 7class
Java8ApiChecker
Checks for uses of classes, fields, or methods that are not compatible with JDK 8 -
Uses of BugPattern in com.google.errorprone.bugpatterns.argumentselectiondefects
Classes in com.google.errorprone.bugpatterns.argumentselectiondefects with annotations of type BugPattern Modifier and Type Class Description class
ArgumentSelectionDefectChecker
Checks the lexical distance between method parameter names and the argument names at call sites.class
AssertEqualsArgumentOrderChecker
Checker to make sure that assertEquals-like methods are called with the arguments expected and actual the right way round.class
AutoValueConstructorOrderChecker
Checker to make sure that constructors for AutoValue types are invoked with arguments in the correct order. -
Uses of BugPattern in com.google.errorprone.bugpatterns.checkreturnvalue
Classes in com.google.errorprone.bugpatterns.checkreturnvalue with annotations of type BugPattern Modifier and Type Class Description class
BuilderReturnThis
Discourages builder instance methods that do not return 'this'.class
CanIgnoreReturnValueSuggester
Checker that recommends annotating a method with@CanIgnoreReturnValue
if the method returnsthis
(or other methods that are likely to also just returnthis
).class
NoCanIgnoreReturnValueOnClasses
Checker that "pushes" the@CanIgnoreReturnValue
annotation down from classes to methods.class
UsingJsr305CheckReturnValue
Checker that recommends using ErrorProne's version of@CheckReturnValue
over the version in JSR305 (which is defunct). -
Uses of BugPattern in com.google.errorprone.bugpatterns.collectionincompatibletype
Classes in com.google.errorprone.bugpatterns.collectionincompatibletype with annotations of type BugPattern Modifier and Type Class Description class
CollectionIncompatibleType
Checker for calling Object-accepting methods with types that don't match the type arguments of their container types.class
CollectionUndefinedEquality
Highlights use ofCollection#contains
(and others) with types that do not have well-defined equals.class
CompatibleWithMisuse
class
IncompatibleArgumentType
class
TruthIncompatibleType
ABugChecker
; see the associatedBugPattern
annotation for details. -
Uses of BugPattern in com.google.errorprone.bugpatterns.flogger
Classes in com.google.errorprone.bugpatterns.flogger with annotations of type BugPattern Modifier and Type Class Description class
FloggerArgumentToString
ABugChecker
; see the associatedBugPattern
annotation for details.class
FloggerFormatString
class
FloggerLogString
Detects invocations ofLoggingApi.log(String)
for which the argument is not a compile-time constant and provides suggested alternatives.class
FloggerLogVarargs
class
FloggerLogWithCause
Flags cases where there is an exception available that could be set as the cause in a log message.class
FloggerMessageFormat
class
FloggerPassedAround
Flags flogger instances being passed around.class
FloggerRedundantIsEnabled
class
FloggerRequiredModifiers
Ensures that class-level FluentLogger objects are private static final.class
FloggerSplitLogStatement
Bugpattern to prevent splitting flogger log invocations into multiple statements.class
FloggerStringConcatenation
ABugChecker
; see the associatedBugPattern
annotation for details.class
FloggerWithCause
Flogger's withCause(Throwable) method checksclass
FloggerWithoutCause
Detects Flogger log statements that pass Exceptions to the log method instead of using withCause. -
Uses of BugPattern in com.google.errorprone.bugpatterns.formatstring
Classes in com.google.errorprone.bugpatterns.formatstring with annotations of type BugPattern Modifier and Type Class Description class
FormatString
ABugChecker
; see the associatedBugPattern
annotation for details.class
FormatStringAnnotationChecker
BugChecker
to assert validity of methods calls withFormatString
annotations.class
InlineFormatString
ABugChecker
; see the associatedBugPattern
annotation for details. -
Uses of BugPattern in com.google.errorprone.bugpatterns.inject
Classes in com.google.errorprone.bugpatterns.inject with annotations of type BugPattern Modifier and Type Class Description class
AssistedInjectAndInjectOnConstructors
class
AssistedInjectAndInjectOnSameConstructor
class
AutoFactoryAtInject
class
CloseableProvides
class
InjectedConstructorAnnotations
A checker for injected constructors with @Inject(optional=true) or binding annotations.class
InjectOnConstructorOfAbstractClass
class
InjectOnMemberAndConstructor
Checks if class constructor and members are both annotated as @Inject.class
InvalidTargetingOnScopingAnnotation
class
JavaxInjectOnAbstractMethod
class
JavaxInjectOnFinalField
class
MisplacedScopeAnnotations
Bug checker for when a scope annotation is used at injection site, which does not have any effect on the injected values.class
MoreThanOneInjectableConstructor
Matches classes that have two or more constructors annotated with @Inject.class
MoreThanOneQualifier
class
MoreThanOneScopeAnnotationOnClass
This checker matches if a class has more than one annotation that is a scope annotation(that is, the annotation is either annotated with Guice's@ScopeAnnotation
or Javax's@Scope
).class
OverlappingQualifierAndScopeAnnotation
class
QualifierOrScopeOnInjectMethod
class
QualifierWithTypeUse
class
ScopeAnnotationOnInterfaceOrAbstractClass
class
ScopeOrQualifierAnnotationRetention
-
Uses of BugPattern in com.google.errorprone.bugpatterns.inject.dagger
Classes in com.google.errorprone.bugpatterns.inject.dagger with annotations of type BugPattern Modifier and Type Class Description class
AndroidInjectionBeforeSuper
class
EmptySetMultibindingContributions
class
PrivateConstructorForNoninstantiableModule
class
ProvidesNull
Bug checker for null-returning methods annotated with@Provides
but not@Nullable
.class
RefersToDaggerCodegen
Checks that the only code that refers to Dagger generated code is other Dagger generated code.class
ScopeOnModule
Migrate users who use JSR 330 scopes on Dagger modules.class
UseBinds
-
Uses of BugPattern in com.google.errorprone.bugpatterns.inject.guice
Classes in com.google.errorprone.bugpatterns.inject.guice with annotations of type BugPattern Modifier and Type Class Description class
AssistedInjectScoping
This checker matches iff *both* of the following conditions are true: 1) The class is assisted: a) If there is a constructor that is annotated with @Inject and that constructor has at least one parameter that is annotated with @Assisted.class
AssistedParameters
class
BindingToUnqualifiedCommonType
class
InjectOnFinalField
class
OverridesGuiceInjectableMethod
This checker matches methods that 1) are not themselves annotated with @Inject (neither javax.inject.Inject nor com.google.inject.Inject) 2) descend from a method that is annotated with @com.google.inject.Injectclass
OverridesJavaxInjectableMethod
This checker matches methods that 1) are not themselves annotated with @Inject 2) descend from a method that is annotated with @javax.inject.Inject 3) do not descent from a method that is annotated with @com.google.inject.Injectclass
ProvidesMethodOutsideOfModule
-
Uses of BugPattern in com.google.errorprone.bugpatterns.inlineme
Classes in com.google.errorprone.bugpatterns.inlineme with annotations of type BugPattern Modifier and Type Class Description class
Inliner
Checker that performs the inlining at call-sites (where the invoked APIs are annotated as@InlineMe
).class
Suggester
Checker that recommends using@InlineMe
on single-statement deprecated APIs.class
Validator
Checker that ensures the@InlineMe
annotation is used correctly. -
Uses of BugPattern in com.google.errorprone.bugpatterns.javadoc
Classes in com.google.errorprone.bugpatterns.javadoc with annotations of type BugPattern Modifier and Type Class Description class
AlmostJavadoc
Flags comments which appear to be intended to be Javadoc, but are not started with an extra*
.class
EmptyBlockTag
Matches block tags (@param, @return, @throws, @deprecated) with an empty description.class
EscapedEntity
Finds unescaped entities in Javadocs.class
InheritDoc
Matches invalid usage of @inheritDoc.class
InvalidBlockTag
Matches invalid Javadoc tags, and tries to suggest fixes.class
InvalidInlineTag
Matches invalid Javadoc tags, and tries to suggest fixes.class
InvalidLink
Finds some common errors in @link tags.class
InvalidParam
Matches incorrect Javadoc @param tags.class
InvalidThrows
Matches errors in Javadoc @throws tags.class
InvalidThrowsLink
Matches misuse of link tags within throws tags.class
MalformedInlineTag
Finds malformed inline tags where @{tag is used instead of {@tag.class
MissingSummary
Matches Javadocs which are missing a required summary line.class
ReturnFromVoid
Finds common Javadoc errors, and tries to suggest useful fixes.class
UnescapedEntity
Finds unescaped entities in Javadocs.class
UnrecognisedJavadocTag
Flags tags which haven't been recognised by the Javadoc parser.class
UrlInSee
Discourages using URLs in @see tags. -
Uses of BugPattern in com.google.errorprone.bugpatterns.nullness
Classes in com.google.errorprone.bugpatterns.nullness with annotations of type BugPattern Modifier and Type Class Description class
EqualsBrokenForNull
BugChecker
adds a null check toequals()
method implementations which don't satisfy the null contract ofObject.equals(java.lang.Object)
i.e.class
EqualsMissingNullable
ABugChecker
; see the associatedBugPattern
annotation for details.class
ExtendsObject
A bugpattern: see the summary.class
FieldMissingNullable
ABugChecker
; see the associatedBugPattern
annotation for details.class
NullArgumentForNonNullParameter
ABugChecker
; see the associatedBugPattern
annotation for details.class
ParameterMissingNullable
ABugChecker
; see the associatedBugPattern
annotation for details.class
ReturnMissingNullable
ABugChecker
; see the associatedBugPattern
annotation for details.class
UnnecessaryCheckNotNull
Checks for unnecessarily performing null checks on expressions which can't be null.class
UnsafeWildcard
Check to detect unsafe upcasts ofnull
values to wildcard types.class
VoidMissingNullable
ABugChecker
; see the associatedBugPattern
annotation for details. -
Uses of BugPattern in com.google.errorprone.bugpatterns.overloading
Classes in com.google.errorprone.bugpatterns.overloading with annotations of type BugPattern Modifier and Type Class Description class
InconsistentOverloads
ABugChecker
that detects inconsistently overloaded methods in Java classes. -
Uses of BugPattern in com.google.errorprone.bugpatterns.threadsafety
Classes in com.google.errorprone.bugpatterns.threadsafety with annotations of type BugPattern Modifier and Type Class Description class
DoubleCheckedLocking
ABugChecker
; see the associatedBugPattern
annotation for details.class
GuardedByChecker
ABugChecker
; see the associatedBugPattern
annotation for details.class
ImmutableAnnotationChecker
ABugChecker
; see the associatedBugPattern
annotation for details.class
ImmutableChecker
ABugChecker
; see the associatedBugPattern
annotation for details.class
ImmutableEnumChecker
ABugChecker
; see the associatedBugPattern
annotation for details.class
ImmutableRefactoring
ABugChecker
; see the associatedBugPattern
annotation for details.class
StaticGuardedByInstance
ABugChecker
; see the associatedBugPattern
annotation for details.class
SynchronizeOnNonFinalField
ABugChecker
; see the associatedBugPattern
annotation for details.class
ThreadPriorityCheck
Bug checker to detect usage ofThread.stop()
,Thread.yield()
, and changing thread priorities. -
Uses of BugPattern in com.google.errorprone.bugpatterns.time
Classes in com.google.errorprone.bugpatterns.time with annotations of type BugPattern Modifier and Type Class Description class
DateChecker
Warns against suspect looking calls toDate
APIs.class
DurationFrom
class
DurationGetTemporalUnit
Bans calls toDuration.get(temporalUnit)
wheretemporalUnit
is notSECONDS
orNANOS
.class
DurationTemporalUnit
Bans calls toDuration
APIs where theTemporalUnit
is notChronoUnit.DAYS
or it has an estimated duration (which is guaranteed to throw anDateTimeException
).class
DurationToLongTimeUnit
Reports an error when a Duration or Instant is incorrectly decomposed in order to call an API which accepts a<long, TimeUnit>
pair.class
FromTemporalAccessor
Bans calls tojavaTimeType.from(temporalAmount)
where the call is guaranteed to either: throw aDateTimeException
at runtime (e.g.,LocalDate.from(month)
) return the same parameter (e.g.,Instant.from(instant)
)class
InstantTemporalUnit
Bans calls toInstant
APIs where theTemporalUnit
is not one of:NANOS
,MICROS
,MILLIS
,SECONDS
,MINUTES
,HOURS
,HALF_DAYS
, orDAYS
.class
InvalidJavaTimeConstant
This checker errors on calls tojava.time
methods using values that are guaranteed to throw aDateTimeException
.class
JavaDurationGetSecondsGetNano
This checker warns about calls toduration.getNano()
without a corresponding "nearby" call toduration.getSeconds()
.class
JavaDurationWithNanos
Check for calls toduration.withNanos(int)
.class
JavaDurationWithSeconds
Check for calls toduration.withSeconds(long)
.class
JavaInstantGetSecondsGetNano
This checker warns about calls toinstant.getNano()
without a corresponding "nearby" call toinstant.getEpochSecond()
.class
JavaLocalDateTimeGetNano
This checker warns about calls toLocalDateTime.getNano()
without a corresponding "nearby" call toLocalDateTime.getSecond()
.class
JavaLocalTimeGetNano
This checker warns about calls toLocalTime.getNano()
without a corresponding "nearby" call toLocalTime.getSecond()
.class
JavaPeriodGetDays
This checker warns about calls toperiod.getDays()
without a corresponding "nearby" call toperiod.getYears(), period.getMonths(), or period.getTotalMonths()
.class
JavaTimeDefaultTimeZone
Check for calls tojava.time
APIs that silently use the default system time-zone.class
JodaConstructors
Check for calls to bad JodaTime constructors.class
JodaDateTimeConstants
Checks for usages of dangerousDateTimeConstants
constants.class
JodaDurationWithMillis
Check for calls toduration.withMillis(long)
.class
JodaInstantWithMillis
Check for calls toinstant.withMillis(long)
.class
JodaNewPeriod
Match possibly incorrect use of Period to obtain a number of (e.g.) days between two dates.class
JodaPlusMinusLong
Check for calls to JodaTime'stype.plus(long)
andtype.minus(long)
where<type> = {Duration,Instant,DateTime,DateMidnight}
.class
JodaTimeConverterManager
Ban usage of Joda'sConverterManager
.class
JodaToSelf
Check for calls to Joda-Time'sfoo.toFoo()
andnew Foo(foo)
.class
JodaWithDurationAddedLong
Check for calls to JodaTime'stype.withDurationAdded(long, int)
where<type> = {Duration,Instant,DateTime}
.class
LocalDateTemporalAmount
Bans calls toLocalDate.plus(TemporalAmount)
andLocalDate.minus(TemporalAmount)
where theTemporalAmount
is a non-zeroDuration
.class
PeriodFrom
class
PeriodGetTemporalUnit
Bans calls toPeriod.get(temporalUnit)
wheretemporalUnit
is notYEARS
,MONTHS
, orDAYS
.class
PeriodTimeMath
Bans calls toPeriod#plus/minus(TemporalAmount)
where the argument is a Duration.class
PreferJavaTimeOverload
This check suggests the use ofjava.time
-based APIs, when available.class
ProtoDurationGetSecondsGetNano
This checker warns about accessing the underlying nanosecond-adjustment field of a duration without a "nearby" access of the underlying seconds field.class
ProtoTimestampGetSecondsGetNano
This checker warns about accessing the underlying nanosecond-adjustment field of a protobuf timestamp without a "nearby" access of the underlying seconds field.class
StronglyTypeTime
Flags fields which would be better expressed as time types rather than primitive integers.class
TemporalAccessorGetChronoField
Bans calls toTemporalAccessor.get(ChronoField)
where the implementation is guaranteed to throw anUnsupportedTemporalTypeException
.class
TimeUnitConversionChecker
Check for problematic or suspicious TimeUnit conversion calls.class
TimeUnitMismatch
Checker that detects likely time-unit mismatches by looking at identifier names.class
ZoneIdOfZ
This checker bans calls toZoneId.of("Z")
in favor ofZoneOffset.UTC
.