Bug patterns

This list is auto-generated from our sources. Each bug pattern includes code
examples of both positive and negative cases; these examples are used in our
regression test suite.

Patterns which are marked Experimental will not be evaluated against your
code, unless you specifically configure Error Prone. The default checks are
marked On by default, and each release promotes some experimental checks
after we’ve vetted them against Google’s codebase.

ChainingConstructorIgnoresParameter
The called constructor accepts a parameter with the same name and type as one of its caller's parameters, but its caller doesn't pass that parameter to it. It's likely that it was intended to.

CheckReturnValue
Ignored return value of method that is annotated with @CheckReturnValue

ConditionalExpressionNumericPromotion
A conditional expression with numeric operands of differing types will perform binary numeric promotion of the operands; when these operands are of reference types, the expression's result may not be of the expected type.

FunctionalInterfaceMethodChanged
Casting a lambda to this @FunctionalInterface can cause a behavior change from casting to a functional superinterface, which is surprising to users. Prefer decorator methods to this surprising behavior.

PrivateSecurityContractProtoAccess
Access to a private protocol buffer field is forbidden. This protocol buffer carries a security contract, and can only be created using an approved library. Direct access to the fields is forbidden.

DateFormatConstant
DateFormat is not thread-safe, and should not be used as a constant field.

DefaultCharset
Implicit use of the platform default charset, which can result in differing behavior between JVM executions or incorrect behavior if the encoding of the data source doesn't match expectations.

OverridesGuiceInjectableMethod
This method is not annotated with @Inject, but it overrides a method that is annotated with @com.google.inject.Inject. Guice will inject this method, and it is recommended to annotate it explicitly.

TypeParameterUnusedInFormals
Declaring a type parameter that is only used in the return type is a misuse of generics: operations on the type parameter are unchecked, it hides unsafe casts at invocations of the method, and it interacts badly with method overload resolution.

URLEqualsHashCode
Avoid hash-based containers of java.net.URL–the containers rely on equals() and hashCode(), which cause java.net.URL to make blocking internet connections.

WaitNotInLoop
Because of spurious wakeups, Object.wait() and Condition.await() must always be called in a loop

WakelockReleasedDangerously
A wakelock acquired with a timeout may be released by the system before calling release, even after checking isHeld(). If so, it will throw a RuntimeException. Please wrap in a try/catch block.

BinderIdentityRestoredDangerously
A call to Binder.clearCallingIdentity() should be followed by Binder.restoreCallingIdentity() in a finally block. Otherwise the wrong Binder identity may be used by subsequent code.

InconsistentOverloads
The ordering of parameters in overloaded methods should be as consistent as possible (when viewed from left to right)

MissingDefault
The Google Java Style Guide requires that each switch statement includes a default statement group, even if it contains no code. (This requirement is lifted for any switch statement that covers all values of an enum.)

MutableMethodReturnType
Method return type should use the immutable type (such as ImmutableList) instead of the general collection interface type (such as List)