Package com.google.errorprone.bugpatterns
Checks added to the java compiler which detect common bug patterns.
-
-
Class Summary Class Description AbstractAsKeyOfSetOrMap Check for usage ofSet<T>
orMap<T, E>
.AbstractMockChecker<T extends Annotation> Helper for enforcing Annotations that disallow mocking.AbstractMockChecker.Reason An explanation of what type should not be mocked, and the reason why.AbstractMustBeClosedChecker An abstract check for resources that must be closed; used byStreamResourceLeak
andMustBeClosedChecker
.AbstractMustBeClosedChecker.Change Error Prone's fix application logic doesn't like it when a fix suggests multiple identical insertions at the same position.AbstractPatternSyntaxChecker Finds calls to regex-accepting methods with literal strings.AbstractReferenceEquality Abstract implementation of a BugPattern that detects the use of reference equality to compare classes with value semantics.AbstractReturnValueIgnored An abstract base class to match API usages in which the return value is not used.AbstractToString An abstract matcher for implicit and explicit calls toObject.toString()
, for use on types that do not have a human-readabletoString()
implementation.AbstractUseSwitch Helper for refactoring from if-else chains to switches.AlreadyChecked Bugpattern to find conditions which are checked more than once.AlwaysThrows ABugChecker
; see the associatedBugPattern
annotation for details.AmbiguousMethodReference ABugChecker
; see the associatedBugPattern
annotation for details.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
.AnnotationMirrorToString ABugChecker
; see the associatedBugPattern
annotation for details.AnnotationPosition Checks annotation positioning, and orphaned Javadocs.AnnotationValueToString ABugChecker
; see the associatedBugPattern
annotation for details.ArrayAsKeyOfSetOrMap Warns that users should not have an array as a key to a Set or MapArrayEquals ArrayFillIncompatibleType Checks when Arrays.fill(Object[], Object) is called with object types that are guaranteed to result in an ArrayStoreException.ArrayHashCode ArraysAsListPrimitiveArray ArrayToString AssertFalse AssertionFailureIgnored ABugChecker
; see the associatedBugPattern
annotation for details.AssertThrowsMultipleStatements ABugChecker
; see the associatedBugPattern
annotation for details.AssertThrowsUtils Utility methods for refactoring try-fail pattern to assertThrows, which is preferred.ASTHelpersSuggestions A BugPattern; see the summaryAsyncCallableReturnsNull Checks thatAsyncCallable
implementations do not directlyreturn null
.AsyncFunctionReturnsNull Checks thatAsyncFunction
implementations do not directlyreturn null
.AutoValueBuilderDefaultsInConstructor See summary for details.AutoValueFinalMethods Checks the toString(), hashCode() and equals() methods are final in AutoValue classes.AutoValueImmutableFields Flags mutable collections in AutoValue.AutoValueSubclassLeaked MatchesAutoValue_
uses outside the containing file.AvoidObjectArrays ABugChecker
; see the associatedBugPattern
annotation for details.BadAnnotationImplementation Checker that ensures implementations ofAnnotation
override equals and hashCode.BadComparable BadImport BadInstanceof Matches instanceof checks where the expression is a subtype of the checked type.BadShiftAmount BanJNDI ABugChecker
that detects use of the unsafe JNDI API system.BanSerializableRead ABugChecker
that detects use of the unsafeSerializable
API.BareDotMetacharacter A BugChecker; see the associated BugPattern for details.BigDecimalEquals Matches use ofBigDecimal#equals
, which compares scale as well (which is not likely to be intended).BigDecimalLiteralDouble Matches usages ofnew BigDecimal(double)
which lose precision.BooleanParameter ABugChecker
; see the associatedBugPattern
annotation for details.BoxedPrimitiveConstructor ABugChecker
; see the associatedBugPattern
annotation for details.BoxedPrimitiveEquality ABugChecker
; see the associatedBugPattern
annotation for details.BugChecker A base class for implementing bug checkers.BugPatternNaming See thesummary
.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().CacheLoaderNull ABugChecker
; see the associatedBugPattern
annotation for details.CanBeStaticAnalyzer Analyzes trees for references to their enclosing instance.CanBeStaticAnalyzer.CanBeStaticResult Stores the result of a can-be-static query.CannotMockFinalClass Bug pattern to recognize attempts to mock final types.CannotMockMethod A BugPattern; see the summaryCanonicalDuration ABugChecker
; see the associatedBugPattern
annotation for details.CatchAndPrintStackTrace ABugChecker
; see the associatedBugPattern
annotation for details.CatchFail ABugChecker
; see the associatedBugPattern
annotation for details.CatchingUnchecked Flags code which catchesRuntimeException
s under the guise of catchingException
.ChainedAssertionLosesContext Identifies calls toassertThat
and similar methods inside the implementation of aSubject
assertion method.ChainingConstructorIgnoresParameter Checks, if two constructors in a class both acceptFoo foo
and one calls the other, that the caller passesfoo
as a parameter.CharacterGetNumericValue Checks for use of Character.getNumericValue and UCharacter.getNumericValueCheckedExceptionNotThrown Flags checked exceptions which are claimed to be thrown, but are not.CheckNotNullMultipleTimes Checks for the same variable being checked against null twice in a method.CheckReturnValue ClassCanBeStatic ClassName ABugChecker
; see the associatedBugPattern
annotation for details.ClassNamedLikeTypeParameter ClassNewInstance ABugChecker
; see the associatedBugPattern
annotation for details.CollectionToArraySafeParameter CollectorShouldNotUseState ComparableAndComparator ComparableType CompareToZero Suggests comparing the result ofcompareTo
to only0
.ComparingThisWithNull Check for expressions containingthis != null
orthis == null
ComparisonContractViolated ComparisonOutOfRange ABugChecker
; see the associatedBugPattern
annotation for details.CompileTimeConstantChecker A Bugpattern; see the accompanying Markdown documentation.ComplexBooleanConstant ComputeIfAbsentAmbiguousReference Flags ambiguous creations of objects inMap.computeIfAbsent(K, java.util.function.Function<? super K, ? extends V>)
.ConditionalExpressionNumericPromotion ConstantField ABugChecker
; see the associatedBugPattern
annotation for details.ConstantOverflow ABugChecker
; see the associatedBugPattern
annotation for details.ConstantPatternCompile Flags variables initialized withPattern.compile(String)
calls that could be constants.DangerousLiteralNullChecker ABugChecker
; see the associatedBugPattern
annotation for details.DateFormatConstant ABugChecker
; see the associatedBugPattern
annotation for details.DeadException DeadThread ABugChecker
; see the associatedBugPattern
annotation for details.DeduplicateConstants A checker that suggests deduplicating literals with existing constant variables.DefaultCharset ABugChecker
; see the associatedBugPattern
annotation for details.DefaultPackage Java classes shouldn't use default package.DepAnn Matches the behaviour of the javac dep-ann Xlint warning.DeprecatedVariable ABugChecker
; see the associatedBugPattern
annotation for details.DifferentNameButSame Discourages using multiple names to refer to the same type within a file (e.g.DirectInvocationOnMock A bugpattern; see the description.DiscardedPostfixExpression ABugChecker
; see the associatedBugPattern
annotation for details.DistinctVarargsChecker ErrorProne checker to generate warning when method expecting distinct varargs is invoked with same variable argument.DoNotCallChecker ABugChecker
; see the associatedBugPattern
annotation for details.DoNotCallSuggester If a method always throws an exception, consider annotating it with@DoNotCall
to prevent calls at compile-time instead failing at runtime.DoNotClaimAnnotations ABugChecker
; see the associatedBugPattern
annotation for details.DoNotMockAutoValue Suggests not mocking AutoValue classes.DoNotMockChecker Points out if a Mockito or EasyMock mock is mocking an object that would be better off being tested using an alternative instance.DoubleBraceInitialization ABugChecker
; see the associatedBugPattern
annotation for details.DuplicateMapKeys Flags duplicate keys used in ImmutableMap construction.EmptyCatch ABugChecker
; see the associatedBugPattern
annotation for details.EmptyIfStatement This checker finds and fixes empty statements after an if, with no else part.EmptyTopLevelDeclaration ABugChecker
; see the associatedBugPattern
annotation for details.EqualsGetClass Discourages the use ofObject.getClass()
when implementingObject.equals(Object)
for non-final classes.EqualsHashCode Classes that overrideObject.equals(java.lang.Object)
should also overrideObject.hashCode()
.EqualsIncompatibleType EqualsNaN EqualsNull ABugChecker
; see the associatedBugPattern
annotation for details.EqualsReference EqualsUnsafeCast Checks forequals
implementations making unsafe casts.EqualsUsingHashCode Discourages implementingequals
usinghashCode
.EqualsWrongThing Checks forequals
implementations comparing non-corresponding fields.ErroneousBitwiseExpression A BugPattern; see the summary.ErroneousThreadPoolConstructorChecker ErrorProne checker to generate warning wheneverThreadPoolExecutor
is constructed with differentcorePoolSize
andmaximumPoolSize
using an unboundedworkQueue
ExpectedExceptionChecker ABugChecker
; see the associatedBugPattern
annotation for details.ExtendingJUnitAssert ExtendsAutoValue Makes sure that you are not extending a class that has @AutoValue as an annotation.FallThrough ABugChecker
; see the associatedBugPattern
annotation for details.FieldCanBeFinal FieldCanBeLocal Flags fields which can be replaced with local variables.FieldCanBeStatic Finds fields which can be safely made static.Finalize ABugChecker
; see the associatedBugPattern
annotation for details.Finally Matches the behaviour of javac's finally Xlint warning.FloatCast ABugChecker
; see the associatedBugPattern
annotation for details.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.FloatingPointLiteralPrecision ABugChecker
; see the associatedBugPattern
annotation for details.ForEachIterable ABugChecker
; see the associatedBugPattern
annotation for details.ForOverrideChecker Verifies that methods markedForOverride
are only called from the defining class.FunctionalInterfaceClash ABugChecker
; see the associatedBugPattern
annotation for details.FunctionalInterfaceMethodChanged FutureReturnValueIgnored See BugPattern annotation.FuturesGetCheckedIllegalExceptionType Checks for calls to Guava'sFutures.getChecked
method that will always fail because they pass an incompatible exception type.FuzzyEqualsShouldNotBeUsedInEqualsMethod GetClassOnAnnotation ABugChecker
; see the associatedBugPattern
annotation for details.GetClassOnClass GetClassOnEnum ABugChecker
; see the associatedBugPattern
annotation for details.HashtableContains ABugChecker
; see the associatedBugPattern
annotation for details.HidingField IdentityBinaryExpression ABugChecker
; see the associatedBugPattern
annotation for details.IdentityHashMapBoxing ABugChecker
; see the associatedBugPattern
annotation for details.IdentityHashMapUsage ABugChecker
; see the associatedBugPattern
annotation for details.IgnoredPureGetter Flags ignored return values from pure getters.ImmutableCollections Common utility functions for immutable collections.ImmutableMemberCollection Refactoring to suggest Immutable types for member collection that are not mutated.ImmutableSetForContains Refactoring to suggest usingprivate static final
ImmutableSet
overImmutableList
when using only contains, containsAll and isEmpty.ImplementAssertionWithChaining Migrates Truth subjects from a manual "test and fail" approach to one usingSubject.check(...)
.ImpossibleNullComparison Matches comparison of proto fields tonull
.Incomparable ABugChecker
; see the associatedBugPattern
annotation for details.IncompatibleModifiersChecker InconsistentCapitalization Checker for variables under the same scope that only differ in capitalization.InconsistentHashCode Looks for hashCode implementations which are inconsistent with equals.IncorrectMainMethod Bugpattern for incorrect overloads of main.IncrementInForLoopAndHeader IndexOfChar ABugChecker
; see the associatedBugPattern
annotation for details.InexactVarargsConditional ABugChecker
; see the associatedBugPattern
annotation for details.InfiniteRecursion ABugChecker
; see the associatedBugPattern
annotation for details.InitializeInline Bugpattern to encourage initializing effectively final variables inline with their declaration, if possible.InjectOnBugCheckers A BugPattern; see the summary.InputStreamSlowMultibyteRead Checks that InputStreams should override int read(byte[], int, int);InsecureCipherMode InstanceOfAndCastMatchWrongType InterfaceWithOnlyStatics Bugpattern to detect interfaces used only to store static fields/methods.InterruptedExceptionSwallowed Checks for cases where anInterruptedException
is caught as part of a catch block catching a supertype, and not specially handled.Interruption ABugChecker
; see the associatedBugPattern
annotation for details.IntLongMath ABugChecker
; see the associatedBugPattern
annotation for details.InvalidPatternSyntax InvalidTimeZoneID InvalidZoneId Validates ZoneId.IsInstanceIncompatibleType IsInstanceOfClass ABugChecker
; see the associatedBugPattern
annotation for details.IterableAndIterator IterablePathParameter ABugChecker
; see the associatedBugPattern
annotation for details.JavaLangClash ABugChecker
; see the associatedBugPattern
annotation for details.JavaUtilDateChecker ABugChecker
; see the associatedBugPattern
annotation for details.JdkObsolete ABugChecker
; see the associatedBugPattern
annotation for details.JUnit3FloatingPointComparisonWithoutDelta Detects floating-point assertEquals() calls that will not work in JUnit 4.JUnit3TestNotRun A bugpattern; see the associated summary.JUnit4ClassAnnotationNonStatic @BeforeClass
or@AfterClass
should be applied to static methods.JUnit4ClassUsedInJUnit3 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.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.JUnit4TestNotRun JUnit4TestsNotRunWithinEnclosed Finds tests that won't run due to the enclosing runner.JUnitAmbiguousTestClass JUnitAssertSameCheck Points out if an object is tested for reference equality to itself using JUnit library.JUnitParameterMethodNotFound Checks if the methods specified injunitparams.Parameters
annotation to provide parameters exists.LabelledBreakTarget A BugPattern; see the summary.LambdaFunctionalInterface LenientFormatStringValidation A BugPattern; see the summary.LiteByteStringUtf8 LiteEnumValueOf Points out if #valueOf() is called on a Protocol Buffer Enum.LiteProtoToString Flags calls totoString
on lite protos.LockNotBeforeTry Suggests that calls toLock.lock
must be immediately followed by atry-finally
that callsLock.unlock
.LockOnBoxedPrimitive Detects locks on boxed primitives.LogicalAssignment ABugChecker
; see the associatedBugPattern
annotation for details.LongDoubleConversion ABugChecker
; see the associatedBugPattern
annotation for details.LongFloatConversion ABugChecker
; see the associatedBugPattern
annotation for details.LongLiteralLowerCaseSuffix Matcher for along
literal with a lower-case ell for a suffix (e.g.LoopConditionChecker ABugChecker
; see the associatedBugPattern
annotation for details.LoopOverCharArray ABugChecker
; see the associatedBugPattern
annotation for details.LossyPrimitiveCompare Checker to prevent usages of comparison methods where both the operands undergo lossy widening.MathAbsoluteNegative MathRoundIntLong Check for calls to Math'sMath.round(float)
with an integer or long parameter.MemberName Flags a few ways in which member names may violate the style guide.MemoizeConstantVisitorStateLookups ABugChecker
; see the associatedBugPattern
annotation for details.MethodCanBeStatic ABugChecker
; see the associatedBugPattern
annotation for details.MissingBraces ABugChecker
; see the associatedBugPattern
annotation for details.MissingCasesInEnumSwitch ABugChecker
; see the associatedBugPattern
annotation for details.MissingDefault ABugChecker
; see the associatedBugPattern
annotation for details.MissingFail MissingImplementsComparable ABugChecker
; see the associatedBugPattern
annotation for details.MissingOverride ABugChecker
; see the associatedBugPattern
annotation for details.MissingSuperCall MissingTestCall Matches test helpers which require a terminating method to be called.MisusedDateFormat Base class for checks which find common errors in date format patterns.MisusedDayOfYear Ban use of D (day-of-year) in a date format pattern that also contains M (month-of-year).MisusedWeekYear Ban use of YYYY in a SimpleDateFormat pattern, unless it is being used for a week date.MixedArrayDimensions ABugChecker
; see the associatedBugPattern
annotation for details.MixedDescriptors Checks for calls toDescriptor#findFieldByNumber
with field numbers from a different proto.MixedMutabilityReturnType Flags methods which return mutable collections from some code paths, but immutable ones from others.MockitoUsage ABugChecker
; see the associatedBugPattern
annotation for details.MockNotUsedInProduction A BugPattern; see the summary.ModifiedButNotUsed Matches creation of new collections/proto builders which are modified but never used.ModifyCollectionInEnhancedForLoop ModifyingCollectionWithItself ModifySourceCollectionInStream Identify the backing collection source of a stream and reports if the source is mutated during the stream operations.MultipleParallelOrSequentialCalls MultipleTopLevelClasses ABugChecker
; see the associatedBugPattern
annotation for details.MultipleUnaryOperatorsInMethodCall MultiVariableDeclaration ABugChecker
; see the associatedBugPattern
annotation for details.MustBeClosedChecker Checks if a constructor or method annotated withMustBeClosed
is called within the resource variable initializer of a try-with-resources statement.MutablePublicArray Check for public static final declaration of Arrays.NarrowCalculation A BugPattern; see the summary.NarrowingCompoundAssignment ABugChecker
; see the associatedBugPattern
annotation for details.NCopiesOfChar ABugChecker
; see the associatedBugPattern
annotation for details.NegativeCharLiteral ABugChecker
; see the associatedBugPattern
annotation for details.NestedInstanceOfConditions NewFileSystem ABugChecker
; see the associatedBugPattern
annotation for details.NoAllocationChecker Checks methods annotated with@NoAllocation
to ensure they really do not allocate.NonAtomicVolatileUpdate Detects non-atomic updates to volatile variables.NonCanonicalStaticImport Types shouldn't be statically by their non-canonical name.NonCanonicalStaticMemberImport Members shouldn't be statically imported by their non-canonical name.NonCanonicalType Flags types being referred to by their non-canonical name.NonFinalCompileTimeConstant Enforce that @CompileTimeConstant parameters are final or effectively final.NonOverridingEquals Bug checker for equals methods that don't actually override equals.NonRuntimeAnnotation NullableConstructor ABugChecker
; see the associatedBugPattern
annotation for details.NullableOnContainingClass A bugpattern; see the summary.NullablePrimitive NullablePrimitiveArray ABugChecker
; see the associatedBugPattern
annotation for details.NullableVoid ABugChecker
; see the associatedBugPattern
annotation for details.NullOptional Flags passing literal null toOptional
-accepting APIs.NullTernary ABugChecker
; see the associatedBugPattern
annotation for details.ObjectEqualsForPrimitives Check for usage ofObjects.equal
on primitive types.ObjectsHashCodePrimitive Check for calls to Objects'Objects.hashCode(java.lang.Object)
with a primitive parameter.ObjectToString Warns against calling toString() on Objects which don't have toString() method overridden and won't produce meaningful output.OperatorPrecedence ABugChecker
; see the associatedBugPattern
annotation for details.OptionalEquality ABugChecker
; see the associatedBugPattern
annotation for details.OptionalMapToOptional MatchesOptional#map
mapping to anotherOptional
.OptionalMapUnusedValue ReplacesOptional.map
withOptional.ifPresent
if the value is unused.OptionalNotPresent OptionalOfRedundantMethod Checks ifOptional#of
is chained with a redundant method.OrphanedFormatString ABugChecker
; see the associatedBugPattern
annotation for details.OutlineNone Check for the a11y antipattern of setting CSS outline attributes to none or 0.Overrides Matches the behaviour of javac's overrides Xlint warning.OverrideThrowableToString Warns against overriding toString() in a Throwable class and suggests getMessage()PackageInfo ABugChecker
; see the associatedBugPattern
annotation for details.PackageLocation ABugChecker
; see the associatedBugPattern
annotation for details.ParameterComment ABugChecker
; see the associatedBugPattern
annotation for details.ParameterName ABugChecker
; see the associatedBugPattern
annotation for details.ParametersButNotParameterized Flags uses of parameters in non-parameterized tests.PreconditionsCheckNotNullRepeated Checks that Precondition.checkNotNull is not invoked with same arg twice.PreconditionsInvalidPlaceholder PreferredInterfaceType Tightens types which refer to an Iterable, Map, Multimap, etc.PrimitiveArrayPassedToVarargsMethod PrimitiveAtomicReference Discourages inadvertently using reference equality on boxed primitives in AtomicReference.PrivateConstructorForUtilityClass PrivateSecurityContractProtoAccess Check for disallowed access to private_do_not_access_or_else proto fields.ProtectedMembersInFinalClass Flags protected members in final classes.ProtoBuilderReturnValueIgnored Highlights cases where a proto's build method has its return value ignored.ProtocolBufferOrdinal Points out if #ordinal() is called on a Protocol Buffer Enum.ProtoRedundantSet Checks that protocol buffers built with chained builders don't set the same field twice.ProtoStringFieldReferenceEquality ProtoTruthMixedDescriptors Checks thatProtoTruth
'signoringFields
is passed field numbers from the correct proto.PublicApiNamedStreamShouldReturnStream Checks if public APIs named "stream" returns a type whose name ends with Stream.RandomCast ABugChecker
; see the associatedBugPattern
annotation for details.RandomModInteger ReachabilityFenceUsage ABugChecker
; see the associatedBugPattern
annotation for details.RedundantOverride Removes overrides which purely pass through to the method in the super class.RedundantThrows ABugChecker
; see the associatedBugPattern
annotation for details.ReferenceEquality ABugChecker
; see the associatedBugPattern
annotation for details.RemoveUnusedImports ReplacementVariableFinder Utility methods to find replacement variables with similar names.RequiredModifiersChecker RestrictedApiChecker Check for non-allowlisted callers to RestrictedApiChecker.RethrowReflectiveOperationExceptionAsLinkageError ABugChecker
; see the associatedBugPattern
annotation for details.ReturnsNullCollection Flags methods with collection return types which returnnull
in some cases but don't annotate the method as @Nullable.ReturnValueIgnored A checker which produces an error when a return value is accidentally discarded.RobolectricShadowDirectlyOn ABugChecker
; see the summary.RxReturnValueIgnored ABugChecker
; see the associatedBugPattern
for details.SameNameButDifferent Looks for types being shadowed by other types in a way that may be confusing.SelfAlwaysReturnsThis ABugChecker
; see the associatedBugPattern
annotation for details.SelfAssignment TODO(eaftan): Consider cases where the parent is not a statement or there is no parent?SelfComparison Points out if an object is compared to itself.SelfEquals SerializableReads List of banned methods forBanSerializableRead
.ShortCircuitBoolean ShortCircuitBoolean.TreeScannerBinary Replaces the operators when visiting the binary nodesShouldHaveEvenArgs Checks that variable argument methods have even number of arguments.SizeGreaterThanOrEqualsZero Finds instances where one usesCollection#size() >= 0
orT[].length > 0
.StatementSwitchToExpressionSwitch Checks for statement switches that can be expressed as an equivalent expression switch.StaticAssignmentInConstructor Checks for static fields being assigned within constructors.StaticAssignmentOfThrowable Checks for static fields being assigned withThrowable
.StaticImports Logic for inspecting static imports used byNonCanonicalStaticImport
,NonCanonicalStaticMemberImport
, andUnnecessaryStaticImport
.StaticImports.StaticImportInfo Information about a static import.StaticMockMember ABugChecker
; see the associatedBugPattern
annotation for details.StaticQualifiedUsingExpression StreamResourceLeak ABugChecker
; see the associatedBugPattern
annotation for details.StreamToIterable Discouragestream::iterator
to createIterable
s.StreamToString ABugChecker
; see the associatedBugPattern
annotation for details.StringBuilderInitWithChar StringCaseLocaleUsage ABugChecker
that flags calls toString.toLowerCase()
andString.toUpperCase()
, as these methods implicitly rely on the environment's default locale.StringSplitter ABugChecker
; see the associatedBugPattern
annotation for details.StronglyType Helper for strongly typing fields.StronglyType.Builder Builder forStronglyType
StronglyTypeByteString Flags fields which would be better expressed as ByteStrings rather than primitive byte arrays.SubstringOfZero Check for calls to String'sfoo.substring(0)
.SuppressWarningsDeprecated Find uses of SuppressWarnings with "deprecated".SuppressWarningsWithoutExplanation Finds occurrences of@SuppressWarnings
where there is definitely no explanation for why it is safe.SwigMemoryLeak SwitchDefault ABugChecker
; see the associatedBugPattern
annotation for details.SymbolToString Flagscom.sun.tools.javac.code.Symbol#toString
usage inBugChecker
s.SystemExitOutsideMain Check for calls toSystem.exit()
outside of a main method.SystemOut ABugChecker
; see the associatedBugPattern
annotation for details.TestExceptionChecker ABugChecker
; see the associatedBugPattern
annotation for details.TestParametersNotInitialized Flags uses of parameters in non-parameterized tests.TheoryButNoTheories Flags uses of@Theory
(and others) in non-Theories
-run tests.ThreadJoinLoop ThreadLocalUsage ABugChecker
; see the associatedBugPattern
annotation for details.ThreeLetterTimeZoneID ThrowIfUncheckedKnownChecked Catches no-op calls toThrowables.throwIfUnchecked
.ThrowNull ABugChecker
; see the associatedBugPattern
annotation for details.ThrowSpecificExceptions Bugpattern to discourage throwing base exception classes.ThrowsUncheckedException Suggests to remove the unchecked throws clause.TooManyParameters ABugChecker
; see the associatedBugPattern
annotation for details.ToStringReturnsNull ToString should not return null.TransientMisuse Warns against use of bothstatic
andtransient
modifiers on field declarations.TreeToString Flagscom.sun.source.tree.Tree#toString
usage inBugChecker
s.TruthAssertExpected Detects usages of Truth assertions with the expected and actual values reversed.TruthConstantAsserts Points out if Truth Library assert is called on a constant.TruthGetOrDefault Flags ambiguous usages ofMap#getOrDefault
withinTruth#assertThat
.TruthSelfEquals Points out if an object is tested for equality/inequality to itself using Truth Libraries.TryFailRefactoring ABugChecker
; see the associatedBugPattern
annotation for details.TryFailThrowable A bug checker for the following code pattern:TryWithResourcesVariable ABugChecker
; see the associatedBugPattern
annotation for details.TypeCompatibilityUtils Logical utility methods to answer the question: Are these two types "compatible" with each other, in the context of an equality check.TypeCompatibilityUtils.TypeCompatibilityReport TypeEqualsChecker Flags com.sun.tools.javac.code.Type#equals usage.TypeNameShadowing Warns when a type parameter shadows another type name in scope.TypeParameterNaming Enforces type parameters match the google style guide.TypeParameterQualifier ABugChecker
; see the associatedBugPattern
annotation for details.TypeParameterShadowing TypeParameterUnusedInFormals TypeToString Flagscom.sun.tools.javac.code.Type#toString
usage inBugChecker
s.UndefinedEquals Flags types which do not have well-defined equals behavior.UngroupedOverloads UnicodeDirectionalityCharacters Bans, without the possibility of suppression, the use of direction-changing Unicode escapes.UnicodeEscape Replaces printable ASCII unicode escapes with the literal version.UnicodeInCode Bans using non-ASCII Unicode characters outside string literals and comments.UnnecessarilyFullyQualified Flags uses of fully qualified names which are not ambiguous if imported.UnnecessarilyVisible Suggests restricting the visibility of methods which should only be called by a framework.UnnecessaryAnonymousClass ABugChecker
; see the associatedBugPattern
annotation for details.UnnecessaryAssignment Discourage manual initialization or assignment to fields annotated with framework annotations.UnnecessaryBoxedAssignment Finds and fixes unnecessarily boxed return expressions.UnnecessaryBoxedVariable Finds and fixes unnecessarily boxed variables.UnnecessaryDefaultInEnumSwitch ABugChecker
; see the associatedBugPattern
annotation for details.UnnecessaryFinal Removesfinal
from non-field variables.UnnecessaryLambda ABugChecker
; see the associatedBugPattern
annotation for details.UnnecessaryLongToIntConversion ABugChecker
; see the associatedBugPattern
annotation for details.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.UnnecessaryMethodReference Matches unnecessary uses of method references.UnnecessaryOptionalGet A refactoring to replace Optional.get() with lambda arg in expressions passed as arg to member functions of Optionals.UnnecessaryParentheses ABugChecker
; see the associatedBugPattern
annotation for details.UnnecessarySetDefault ABugChecker
; see the associatedBugPattern
annotation for details.UnnecessaryStaticImport ABugChecker
; see the associatedBugPattern
annotation for details.UnnecessaryTestMethodPrefix See the summary.UnnecessaryTypeArgument ABugChecker
; see the associatedBugPattern
annotation for details.UnqualifiedYield ABugChecker
; see the associatedBugPattern
annotation for details.UnsafeFinalization ABugChecker
; see the associatedBugPattern
annotation for details.UnsafeLocaleUsage Flags unsafe usages of theLocale
constructor and class methods.UnsafeReflectiveConstructionCast Checks unsafe instance creation via reflection.UnsynchronizedOverridesSynchronized ABugChecker
; see the associatedBugPattern
annotation for details.UnusedAnonymousClass ABugChecker
; see the associatedBugPattern
annotation for details.UnusedCollectionModifiedInPlace UnusedException Bugpattern for catch blocks which catch an exception but throw another one without wrapping the original.UnusedLabel A BugPattern; see the summary.UnusedMethod Bugpattern to detect unused declarations.UnusedNestedClass Bugpattern to detect unused nested classes.UnusedTypeParameter A BugPattern; see the summary.UnusedVariable Bugpattern to detect unused declarations.URLEqualsHashCode Points out on creation of Set and HashMap of type java.net.URL.UseCorrectAssertInTests UseEnumSwitch ABugChecker
; see the associatedBugPattern
annotation for details.VarChecker ABugChecker
; see the associatedBugPattern
annotation for details.VariableNameSameAsType Check for variables and types with the same nameVarifier Converts some local variables to usevar
.VarTypeName ABugChecker
; see the associatedBugPattern
annotation for details.WaitNotInLoop WildcardImport ABugChecker
; see the associatedBugPattern
annotation for details.WithSignatureDiscouraged MethodMatchers.MethodClassMatcher.withSignature(String)
is discouraged: most usages should use .named and/or .withParameters instead.WrongOneof Matches always-default expressions in oneof switches.XorPower ABugChecker
; see the associatedBugPattern
annotation for details.YodaCondition See the summary. -
Enum Summary Enum Description TypeParameterNaming.TypeParameterNamingClassification An enum that classifies a String name into different types, based on the Google Java Style Guide's rules for Type Parameters.TypesWithUndefinedEquality Enumerates types which have poorly-defined behaviour for equals.