Update Error Prone to v2.50.0 - #4847
Conversation
b4e2a97 to
ce979af
Compare
9244f7b to
a342c87
Compare
…dead code Error Prone 2.50.0 (PR apache#4847) flags several categories of real issues across the codebase, fixed here (ReferenceEquality suppressions are handled separately in the next commit): - NotJavadoc: /** */ comments attached to methods inside local/anonymous classes, or stacked duplicate /** */ blocks, converted to regular comments or merged as appropriate. - TypeParameterQualifier: T::toString replaced with Object::toString in RequestReplicaListTransformerGenerator, since a generic type parameter used as an unbound method reference qualifier is erased to Object anyway. - A latent bug in CommandOperation.getStr(String, String) where the ROOT_OBJ branch returned null instead of the default value when the underlying object was null, inconsistent with the sibling branch and the single-arg overload. - Excluded vendored Tika sources and noggit from Error Prone checks, matching existing precedent for other vendored/generated code. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Error Prone 2.50.0's ReferenceEquality check is a purely syntactic heuristic: it flags any == / != between two objects of a type that overrides equals(), regardless of whether the comparison is actually a deliberate identity check. It cannot distinguish that from a genuine missed-.equals() bug. Every occurrence suppressed here was individually reviewed and is a legitimate identity comparison: sentinel objects, "same instance means no-op" idioms, singleton comparisons (e.g. Calcite Convention, an IdentityNormalizer instance), heavyweight resource identity (SolrCore, Thread, JettySolrRunner), or identity semantics already documented via System.identityHashCode() in the corresponding hashCode(). Each suppression is scoped to the smallest enclosing method or constructor and, where the reasoning wasn't already evident from context, annotated with a short comment explaining why identity (not value) equality is correct there. This is broken out as its own commit since the sheer number of suppressions may warrant a different overall approach (e.g. a targeted excludedPaths/allowlist) rather than suppressing case-by-case. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
The new ErrorProne brought a set of new rules, some that are great, and one that maybe needs discussion. This commit is all reasonable seeming fixes/cleanups: 0743dd4, however the suppression of We could also disable it via I think I am leaning towards this, but would love other opinoins! |
Edited/Blocked NotificationRenovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR. You can manually request rebase by checking the rebase/retry box above. |
dsmiley
left a comment
There was a problem hiding this comment.
The reference equality thing is a shame. I wish there was an annotation that could either be used on a type (say Aliases) or on field with a constant initializer, that means -- this thing is used with reference equality. Basically -- opt-in. Instead, with error-prone, we can only flag a method that uses equality somewhere inside, without clarity on what line had the issue; and it only applies to that method.
Any way, I actually think it's a fairly positive change because it should catch bugs. On the other hand, we may want to reconsider hard-line static analysis of error-prone as we consider adopting SonarQube soon, which raises matters but doesn't block us on anything. Error-prone blocks us and/or compells an annotation, so I suppose it's fair to say error-prone doesn't block either. It does force an annotation for a suppression... which maybe has some enduring quality value of communicating to a future reader that this reference equality is intentional. That brings me back to basically agreeing with what's here.
| countDistinct(false, distinctValues), | ||
| percentiles(true) { | ||
| /** special for percentiles * */ | ||
| /* special for percentiles */ |
There was a problem hiding this comment.
I disagree with NotJavadoc rule. The creator of the rule apparently thinks the only point of Javadoc is to publish it. I rarely look at published javadoc nowadays. I view javadoc as the normal way that a class/field/member is documented. And it even looks fairly nice nowadays in IntelliJ with the rendered view.
There was a problem hiding this comment.
Further argument: Imagine I have some class with javadoc... and then I do a refactoring that turns it into an anonymous inner class. Why should I then be forced to turn javadocs to non-javadoc? Seems arbitrary.
This PR contains the following updates:
2.41.0→2.50.02.41.0→2.50.0Release Notes
google/error-prone (com.google.errorprone:error_prone_core)
v2.50.0: Error Prone 2.50.0New 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 overrideanything
ThrowableEqualsHashCode: Discourage overridingThrowable.equals()andhashCode()Closed issues: #5553, #5649, #5778
Full changelog: google/error-prone@v2.49.0...v2.50.0
v2.49.0: Error Prone 2.49.0This release includes several changes to
MatcherAPIs, and removed some deprecated or problematic APIs:MethodMatchers.withSignatureAPI, which relies on fragiletoStringbehaviour. Alternatives for matching on method signatures with varargs and type parameters were added ina98a1c5.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).enclosingPackagereturn an optional. Module elements are not enclosed by a package, checks usingenclosingPackageshouldn't assume an enclosing package exists when processing arbitrary elements.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: google/error-prone@v2.48.0...v2.49.0
v2.48.0: Error Prone 2.48.0Changes:
@-files) (8e84edf)New checks:
AvoidValueSetterUnnecessarySemicolonClosed issues: #5529, #5537, #5522, #5521
Full changelog: google/error-prone@v2.47.0...v2.48.0
v2.47.0: Error Prone 2.47.0New 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: google/error-prone@v2.46.0...v2.47.0
v2.46.0: Error Prone 2.46.0Changes:
-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.valueattribute from@IncompatibleModifiersand@RequiredModifiers(#2122)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 classesFull changelog: google/error-prone@v2.45.0...v2.46.0
v2.45.0: Error Prone 2.45.0Changes:
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 methodsClosed issues: #5335
Full changelog: google/error-prone@v2.44.0...v2.45.0
v2.44.0: Error Prone 2.44.0Changes
LabelledBreakTargetis now an errorClosed issues: #5218, #5278
Full changelog: google/error-prone@v2.43.0...v2.44.0
v2.43.0: Error Prone 2.43.0The 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 checkNew 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: google/error-prone@v2.42.0...v2.43.0
v2.42.0: Error Prone 2.42.0New checks:
ExplicitArrayForVarargs: discourage unnecessary explicit construction of an array to provide varargs.FloggerPerWithoutRateLimit: discourage Flogger'sperUniquewithout rate limitingStringJoin: BanString.join(CharSequence)andString.join(CharSequence, CharSequence)ThreadBuilderNameWithPlaceholder: Do not allow placeholders inThread.Builder.name(String)orname(String, int).Changes:
ASTHelpers.asFlagSethas changed. The previous type wasEnumSet<Flags.Flag>, whereFlags.Flagis an enum in the javac classFlags. A recent JDK change has replaced that enum with a new top-level enum calledFlagsEnum. It is not possible to changeASTHelpers.asFlagSetin a way that would be type-safe and compatible with the enums from JDKs both before and after the change. Instead, the method now returnsImmutableSet<String>, where the strings come from thetoString()of the enum constants. That means they are"native","abstract", etc.IO.print[ln]()inSystemOut.Full changelog: google/error-prone@v2.41.0...v2.42.0
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about these updates again.
This PR has been generated by Renovate Bot