Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ repositories {
apply from: rootProject.file('gradle/java-publish.gradle')
apply from: rootProject.file('gradle/changelog.gradle')
allprojects {
apply from: rootProject.file('gradle/error-prone.gradle')
apply from: rootProject.file('gradle/rewrite.gradle')
apply from: rootProject.file('gradle/spotless.gradle')
}
Expand Down
66 changes: 66 additions & 0 deletions gradle/error-prone.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import static java.lang.System.getenv

apply plugin: 'net.ltgt.errorprone'

dependencies {
errorprone('com.google.errorprone:error_prone_core:2.42.0')
errorprone('tech.picnic.error-prone-support:error-prone-contrib:0.25.0')
errorprone('tech.picnic.error-prone-support:refaster-runner:0.25.0')
constraints {
errorprone('com.google.guava:guava') {
version {
require('33.4.8-jre')
}
because('Older versions use deprecated methods in sun.misc.Unsafe')
// https://github.com/junit-team/junit-framework/pull/5039#discussion_r2414490581
}
}
}

tasks.withType(JavaCompile).configureEach {
options.errorprone {
errorproneArgs.add('-XepOpt:Refaster:NamePattern=^(?!.*Rules\\$).*')
error(
'DirectReturn',
// 'ConstantNaming',
// 'LexicographicalAnnotationAttributeListing',
// 'LexicographicalAnnotationListing',
// 'MissingOverride',
// 'NonStaticImport',
// 'OptionalMapUnusedValue',
// 'OptionalOfRedundantMethod',
// 'RedundantSetterCall',
// 'RedundantStringConversion',
// 'RedundantStringEscape',
// 'StaticImport',
// 'StringJoin',
// 'UnnecessaryCheckNotNull',
// 'UnnecessaryTypeArgument',
// 'UnusedAnonymousClass',
// 'UnusedCollectionModifiedInPlace',
)
if (!getenv().containsKey('CI') && getenv('IN_PLACE')?.toBoolean()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

activating IN_PLACE allowing removal of allErrorsAsWarnings resulting in local passing, on CI, without patching of course, positive failing build.

How to automate prone without having this glitch? @rickie Patching only cares for the XepPatchChecks like the documentation tells. XepPatchLocation Only works in paid, despite having it seen in gradle not being the case its a very random plugin behaviour sometimes.

Copy link

Choose a reason for hiding this comment

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

Only works in paid, despite having it seen in gradle not being the case its a very random plugin behaviour sometimes.

I don't fully understand this comment, can you elaborate?

I agree the usage of the XepPatchChecks and location is a bit finicky and requires some effort to get right. You work on a lot of PRs which is cool to see. But right now I don't have time to dive into all of them and find the exact cause. Will try to also look tomorrow, but can't make promises right now.

I once created a demo project (it's in Maven though) but perhaps you can look into that, and based on that try to configure it for one of the projects you're working on: https://github.com/rickie/error-prone-demo.

errorproneArgs.addAll(
'-XepPatchLocation:IN_PLACE',
'-XepPatchChecks:' +
'DirectReturn,'
// 'ConstantNaming,' +
// 'MissingOverride,' +
// 'StaticImport,' +
// LexicographicalAnnotationAttributeListing,' +
// LexicographicalAnnotationListing,' +
// NonStaticImport,' +
// OptionalMapUnusedValue,' +
// OptionalOfRedundantMethod,' +
// RedundantSetterCall,' +
// RedundantStringConversion,' +
// RedundantStringEscape,' +
// StringJoin,' +
// UnnecessaryCheckNotNull,' +
// UnnecessaryTypeArgument,' +
// UnusedAnonymousClass,' +
// UnusedCollectionModifiedInPlace,'
)
}
}
}
1 change: 0 additions & 1 deletion rewrite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ tags:
- cleanup
recipeList:
- org.openrewrite.gradle.EnableGradleBuildCache
- org.openrewrite.gradle.EnableGradleParallelExecution
- org.openrewrite.gradle.GradleBestPractices
- org.openrewrite.java.RemoveUnusedImports
- org.openrewrite.java.format.NormalizeFormat
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ plugins {
id 'com.gradle.develocity' version '4.2.1'
// https://github.com/equodev/equo-ide/blob/main/plugin-gradle/CHANGELOG.md
id 'dev.equo.ide' version '1.7.8' apply false
id 'net.ltgt.errorprone' version '4.3.0' apply false
id 'org.openrewrite.rewrite' version '7.17.0' apply false
}

Expand Down
Loading