Repository navigation
Releases
Error Prone 2.52.0
New checks:
AlmostExhaustiveTestParameter: Prefer an exhaustive@TestParameterwith an assumption to filter out specific enum values, so newly added enum values are automatically tested (disabled by default).SingleTestParameter: Suggest@TestParameteron the parameter instead of@TestParameterswhen there is only one test parameter, replacingPreferTestParameter(disabled by default).SingleValueTestParameter: Suggest replacing a@TestParameterthat has only a single value with a local variable in the test method (disabled by default).ValueClassEquals: Require non-record concretevalueclasses to explicitly overrideequalsandhashCode.
Other changes:
LoopToTestParameter: Changed severity toSUGGESTION(disabled by default).DistinctVarargsChecker: Allow duplicate arguments toIterables.concat(#6239) and Mockito argument matchers such asany()(#6240).UnusedVariable: Treat fields accessed viaMethodHandles.Lookup(VarHandle/getter/setter lookups) orAtomic*FieldUpdater.newUpdateras used.StringBuilderInitWithChar/StringBufferrefactoring: RefactorStringBuffertoStringBuildereven when used withMatcher.appendReplacementandappendTail(when supported by the target JDK or AndroidminSdkVersion).CompileTimeConstant: Treatrecordandinterfacefields and field accesses on compile-time constants (compileTimeConstant.compileTimeConstantField) as compile-time constants.ValueClassIdentity/ReferenceEquality: Handle JEP 401valueclasses.FieldCanBeFinal/ThreadSafety: Improve compile-time performance on large classes and deep type hierarchies, and update SafeRE to 1.1.0 (#6230).- Added
ClassNamefor caching resolvedClassSymbol,Type, and binaryNamelookups across a compilation.
Closed issues: #5964, #6165, #6230, #6239, #6240, #6275
Full changelog: v2.51.0...v2.52.0
Error Prone 2.51.0
New checks:
HashCodeInObjectsHash: Detect redundanthashCode()orObjects.hash()calls insideObjects.hash(...), and simplify single-argumentObjects.hash(x)calls toObjects.hashCode(x).LoopToTestParameter: Suggest migrating loops in unit tests toTestParameterInjector.MissingJavadoc: Flag public types that are missing Javadoc comments (disabled by default).PreferCharsetOverload: Prefer calling method and constructor overloads that accept aCharsetover those that accept aStringencoding name.PreferPreconditions: Suggest using Guava'sPreconditionsinstead of explicitif-throwstatements for parameter validation (disabled by default).RequireNonNullRefactoring: Refactor explicitif (x == null) { throw new NullPointerException(...); }checks toObjects.requireNonNull(disabled by default).SimplifyTestParameter: Remove redundant explicit value lists on@TestParameterannotations forbooleanandEnumtypes when all values are specified (disabled by default).TraditionalJavadocToMarkdown: Convert traditional/** ... */Javadoc comments into///Markdown Javadoc comments (disabled by default).ValueClassIdentity: Flag reliance on identity semantics (such as synchronization,WeakReference,IdentityHashMap, orSystem.identityHashCode) of value-based classes (disabled by default).
Other changes:
CompareToZero: Upgraded from warning to error, and expanded to flag non-relational operations, unary negation, andswitchstatements/expressions oncompareToandcompareresults withoutInteger.signum.IfChainToSwitch: Enabled by default as a warning.UndefinedEquals: MergedArrayAsKeyOfSetOrMapandCollectionUndefinedEqualityintoUndefinedEquals(retaining their names asaltNames), and generalized detection of types without well-definedequalsorhashCodeacross direct equality, collection containment, and hash-based containers.EqualsIncompatibleType/TruthIncompatibleType: Flag equality comparisons between distinctrecordtypes (#6107).ReferenceEquality: Allow==comparisons onprivateclasses whose type hierarchy does not overrideObject.equals(#5865),private static finalsentinel fields,Thread(#5900), andcom.sun.source.tree.Tree.PatternMatchingInstanceof: Supportwhileandforloops, parenthesized expressions (#5843), and replacing additional redundant casts when theinstanceofalready introduces a pattern variable.DistinctVarargsChecker: Expanded to checkObjects.hash,CompletableFuture.allOf/anyOf,EnumSet.of,Sets.union/intersection/difference,Stream.concat,Math.min/max, and additional JDK, Guava, Protobuf, Truth, and Mockito methods.MustBeClosedChecker: Requirejava.lang.foreign.Arena.ofConfinedandArena.ofSharedto be closed.ImpossibleNullComparison: Flag null checks on the return value ofClass.forName.RestrictedApi/RestrictedInheritance: Added anallowedPathsattribute to allow calls or inheritance from matching file paths without a regular expression.InlineMeInliner: Support substituting type arguments at call sites when inlining generic@InlineMemethods.WellKnownKeep: Recognize Apache BeamDoFnannotations and retain open-source library annotations (Gson,Mockito,Guice,Objectify,TestParameterInjector,AutoFactory).- Per-check timing collection is now disabled by default, reducing Error Prone compile-time overhead by ~3β5%; pass
-XepPrintTimingsto print a timing report after compilation or-XepRecordTimingsto record timings programmatically (#6079). CompilationTestHelpernow reports all lines with mismatched diagnostic expectations in a single test run rather than failing on the first mismatch (#6116).- Replaced the RE2/J dependency with SafeRE.
Closed issues: #4914, #5182, #5843, #5857, #5865, #5878, #5900, #6029, #6079, #6107, #6116, #6133
Full changelog: v2.50.0...v2.51.0
Error Prone 2.50.0
New checks:
BoxingComparator: Detect implicitly-boxing Comparator.comparing key extractorsExposedPrivateType: Discourage references to private member classes from non-private APIsJUnitMethodInvoked: Discourage directly invoking JUnit test methodsListRemoveAmbiguous: Detect ambiguous calls toList.remove(int|Integer)PreferTestParameter: suggests using@TestParameterinstead of@TestParametersfor exhaustive boolean and enum parameters on single-element parameterized testsRecordComponentAccessorAnnotationConflict: Detect conflicts between record components and explicit accessor methodsRecordComponentOverride: Discourage@Overrideon record component declarations that don't override
anythingThrowableEqualsHashCode: Discourage overridingThrowable.equals()andhashCode()
Closed issues: #5553, #5649, #5778
Full changelog: v2.49.0...v2.50.0
Error Prone 2.49.0
This release includes several changes to Matcher APIs, and removed some deprecated or problematic APIs:
- Remove deprecated
MethodMatchers.withSignatureAPI, which relies on fragiletoStringbehaviour. Alternatives for matching on method signatures with varargs and type parameters were added in a98a1c5. - Removed
variableType(Matcher)API.Matchers.variableType(Matcher)usesVariableTree#getTypeto match variable types, which own't work for lambda parameters with inferred types after JDK-8268850. The recommended replacement isvariableType(TypePredicate). - Make
enclosingPackagereturn an optional. Module elements are not enclosed by a package, checks usingenclosingPackageshouldn't assume an enclosing package exists when processing arbitrary elements. - New
FieldMatchersAPI, similar toMethodMatchers(1dd9c3a).
New checks:
AssertThrowsBlockToExpression: Discourage unnecessary block lambdas inassertThrows.AssertThrowsMinimizer: Suggest minimizing the amount of logic inassertThrows.MemorySegmentReferenceEquality: Discourage using reference equality forMemorySegments.PreferThrowsTag: Recommends using@throwsinstead of the legacy@exceptionjavadoc tag.RecordAccessorInCompactConstructor: detect record accessors inside the compact canonical ctors, which read uninitialized fields.
Closed issues: #2283, #3503, #5210, #5289, #5548, #5548, #5554, #5609, #5614, #5656
Full changelog: v2.48.0...v2.49.0
Error Prone 2.48.0
Error Prone 2.47.0
New checks:
InterruptedInCatchBlock: Detect accidental calls toThread.interrupted()inside ofcatch(InterruptedException e)blocks.RefactorSwitch: Refactorings to simplify arrow switchesUnnamedVariable: Rename unused variables to_
Closed issues: #1811, #4168, #5459, #5460
Full changelog: v2.46.0...v2.47.0
Error Prone 2.46.0
Changes:
- The javac flag
-XDaddTypeAnnotationsToSymbol=trueis now required for Error Prone invocations on JDK 21, to enable the javac fix for JDK-8225377: type annotations are not visible to javac plugins across compilation boundaries. See #5426 for details. - Remove deprecated
valueattribute from@IncompatibleModifiersand@RequiredModifiers(#2122) - Error Prone API changes to encapsulate references to internal javac APIs for end position handling (
EndPosTable,DiagnosticPosition) (5440bb4, 06c2905, f3915ec)
New checks:
DuplicateAssertion: detect duplicated assertion lines where the argument toassertThatis pureIfChainToSwitch: suggest converting chains of if-statements into arrow switchesScannerUseDelimiter: discourageScanner.useDelimiter("\\A")AddNullMarkedToClass: refactoring to add@NullMarkedannotation to top level classes
Full changelog: v2.45.0...v2.46.0
Error Prone 2.45.0
Changes:
- Improved compatibility with latest JDK 26 EA builds.
New checks:
AssertSameIncompatible: Detect calls toassertSameand similar assertions, where the calls are guaranteed to either succeed or fail.FormatStringShouldUsePlaceholders: Suggests using a format string instead of string concatenation operations on format methods
Closed issues: #5335
Full changelog: v2.44.0...v2.45.0
Error Prone 2.44.0
Changes
- The default severity for
LabelledBreakTargetis now an error - Update dependency on Guava (#5108)
Full changelog: v2.43.0...v2.44.0
Error Prone 2.43.0
The minimum supported JDK version to run Error Prone is now JDK 21 (#4867).
Changes:
-XepPatchChecksnow skips disabled checks (#4943)AndroidJdkLibsCheckerhas been removed, the recommended replacement for Android code is Android Lint's NewApi check
New checks:
NullNeedsCastForVarargs: Detect calls that incorrectly passes anullarray instead of anullelement.RedundantNullCheck: detect checks on expressions that are non-null.
Closed issues: #4943, #5102, #5107, #5121, #5158, #5217, #5239
Full changelog: v2.42.0...v2.43.0