Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade errorprone to 2.36.0 #14216

Merged
merged 1 commit into from
Feb 12, 2025
Merged

Conversation

risdenk
Copy link
Contributor

@risdenk risdenk commented Feb 8, 2025

Description

Builds on top of #14201 which started with 2.18.0 and helps with the error described here #14200. This adds all the rules to error-prone.gradle and upgrades to the latest error prone plugin version (https://github.com/tbroyer/gradle-errorprone-plugin/releases) and error prone version.

This was checked with

./gradlew check -x test -Pvalidation.errorprone=true -Pjavac.failOnWarnings=false -Pvalidation.git.failOnModified=false

These are ones that potentially have problems but are commented out since the fixes were not trivial

  • ArrayRecordComponent
  • ClassInitializationDeadlock
  • LockOnNonEnclosingClassLiteral

All the rules from the different versions are linked below:

https://github.com/google/error-prone/releases/tag/v2.19.0

https://github.com/google/error-prone/releases/tag/v2.20.0

https://github.com/google/error-prone/releases/tag/v2.21.0

https://github.com/google/error-prone/releases/tag/v2.22.0

https://github.com/google/error-prone/releases/tag/v2.23.0

https://github.com/google/error-prone/releases/tag/v2.24.0

https://github.com/google/error-prone/releases/tag/v2.25.0

https://github.com/google/error-prone/releases/tag/v2.26.0

  • SystemConsoleNull: Null-checking System.console() is not a reliable way to detect if the console is connected to a terminal.
  • EnumOrdinal: Discourage uses of Enum.ordinal()

https://github.com/google/error-prone/releases/tag/v2.27.0

  • ClassInitializationDeadlock detects class initializers that reference subtypes of the current class, which can result in deadlocks.
  • MockitoDoSetup suggests using when/thenReturn over doReturn/when for additional type safety.
  • VoidUsed suggests using a literal null instead of referring to a Void-typed variable.
  • TruthSelfEquals has been renamed and generalized as SelfAssertion

https://github.com/google/error-prone/releases/tag/v2.28.0

https://github.com/google/error-prone/releases/tag/v2.29.0

https://github.com/google/error-prone/releases/tag/v2.30.0

https://github.com/google/error-prone/releases/tag/v2.31.0

  • AutoValueBoxedValues: AutoValue instances should not usually contain boxed types that are not Nullable. We recommend removing the unnecessary boxing.

https://github.com/google/error-prone/releases/tag/v2.32.0

  • no rule changes

https://github.com/google/error-prone/releases/tag/v2.33.0

https://github.com/google/error-prone/releases/tag/v2.34.0

https://github.com/google/error-prone/releases/tag/v2.35.0

https://github.com/google/error-prone/releases/tag/v2.36.0

@@ -391,11 +391,7 @@ public void testSort() throws IOException {
for (int j = 0; j < numSortFields; ++j) {
sortFields[j] = randomIndexSortField();
}
if (supportsHasBlocks()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why this was the same for both...

break

case ":lucene:queryparser":
options.errorprone.excludedPaths.set("" +
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tries to avoid checking all the generated code. The list was taken from the Spotless module and modified into regex form.

'-Xep:NonOverridingEquals:WARN',
'-Xep:NotJavadoc:WARN',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where all the /** to /* comes from

@@ -429,6 +508,8 @@ allprojects { prj ->
'-Xep:OverrideThrowableToString:WARN',
'-Xep:Overrides:WARN',
// '-Xep:OverridesGuiceInjectableMethod:OFF', // we don't use guice
'-Xep:OverridingMethodInconsistentArgumentNamesChecker:WARN',
'-Xep:PatternMatchingInstanceof:WARN',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where a majority of the changes come from. I do think it makes things a lot clearer, but am happy to revert this change too.

@risdenk risdenk requested a review from rmuir February 8, 2025 03:13
@risdenk risdenk changed the title errorprone-improvements Upgrade errorprone to 2.36.0 Feb 8, 2025
@risdenk risdenk marked this pull request as ready for review February 8, 2025 03:14
@@ -288,8 +341,10 @@ allprojects { prj ->
// '-Xep:ChainedAssertionLosesContext:OFF', // we don't use truth
// '-Xep:CharacterGetNumericValue:OFF', // noisy
// '-Xep:ClassCanBeStatic:OFF', // noisy
// '-Xep:ClassInitializationDeadlock:OFF', // TODO: there are problems
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you've got my curiosity :)

Copy link
Member

@rmuir rmuir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

serious chunk of work, thank you for working through it all!

Copy link
Contributor

@dweiss dweiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Thank you, @risdenk

@dweiss dweiss merged commit b0ebaae into apache:main Feb 12, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment