Add rewrite support for errorprone.refasterrules
I’d like to propose integrating Google’s Error Prone and its Picnic extension (demonstrated in Automating Away Bugs with Error Prone | PlatformCon 2023) to enable automated bug fixes via rewrite rules. This would complement Checkstyle’s static analysis capabilities by addressing semantic bugs rather than stylistic issues.
Motivation
Error Prone’s refaster/rewrite rules can automatically:
- Fix common bug patterns (e.g.,
String.equals() misuse)
- Modernize code (e.g., JDK migration helpers)
- Enforce best practices (e.g., null-check improvements)
Real-world adoptions show tangible benefits:
Proposal
- Add support for
errorprone.refasterrules-based rewrites
- Implement with opt-in adoption (no breaking changes)
- Include suppression mechanisms for API constraints
Discussion Points
- Need consensus on:
- Scope of auto-fixes
- Preferred suppression strategy
- Integration approach
Next Steps
I’m happy to:
- Prepare a PoC demonstrating the value
- Collaborate on implementation strategy
- Address any concerns about compatibility
relates to:
- org.openrewrite.java.RemoveUnusedImports
- org.openrewrite.java.format.RemoveTrailingWhitespace
- org.openrewrite.java.migrate.Java8toJava11
- org.openrewrite.staticanalysis.LowercasePackage
- org.openrewrite.staticanalysis.MissingOverrideAnnotation
- org.openrewrite.staticanalysis.ModifierOrder
- org.openrewrite.staticanalysis.NoFinalizer
- org.openrewrite.staticanalysis.RemoveUnusedLocalVariables
- org.openrewrite.staticanalysis.RemoveUnusedPrivateFields
- org.openrewrite.staticanalysis.RemoveUnusedPrivateMethods
- tech.picnic.errorprone.refasterrules.BigDecimalRulesRecipes
- tech.picnic.errorprone.refasterrules.CharSequenceRulesRecipes
- tech.picnic.errorprone.refasterrules.ClassRulesRecipes
- tech.picnic.errorprone.refasterrules.MicrometerRulesRecipes
- tech.picnic.errorprone.refasterrules.TimeRulesRecipes
# - org.openrewrite.java.recipes.JavaRecipeBestPractices
# - org.openrewrite.java.recipes.RecipeNullabilityBestPractices
# - org.openrewrite.java.recipes.RecipeTestingBestPractices
# - org.openrewrite.maven.BestPractices
# - org.openrewrite.staticanalysis.CodeCleanup
# - org.openrewrite.staticanalysis.CommonStaticAnalysis
# - org.openrewrite.staticanalysis.EqualsAvoidsNull
# - org.openrewrite.staticanalysis.JavaApiBestPractices
# - org.openrewrite.staticanalysis.UnnecessaryThrows
# - tech.picnic.errorprone.refasterrules.CollectionRulesRecipes
# - tech.picnic.errorprone.refasterrules.ComparatorRulesRecipes
# - tech.picnic.errorprone.refasterrules.EqualityRulesRecipes
# - tech.picnic.errorprone.refasterrules.FileRulesRecipes
# - tech.picnic.errorprone.refasterrules.NullRulesRecipes
# - tech.picnic.errorprone.refasterrules.OptionalRulesRecipes
# - tech.picnic.errorprone.refasterrules.PatternRulesRecipes
# - tech.picnic.errorprone.refasterrules.PreconditionsRulesRecipes
# - tech.picnic.errorprone.refasterrules.PrimitiveRulesRecipes
# - tech.picnic.errorprone.refasterrules.StreamRulesRecipes
# - tech.picnic.errorprone.refasterrules.StringRulesRecipes
Add
rewritesupport forerrorprone.refasterrulesI’d like to propose integrating Google’s Error Prone and its Picnic extension (demonstrated in Automating Away Bugs with Error Prone | PlatformCon 2023) to enable automated bug fixes via
rewriterules. This would complement Checkstyle’s static analysis capabilities by addressing semantic bugs rather than stylistic issues.Motivation
Error Prone’s
refaster/rewriterules can automatically:String.equals()misuse)Real-world adoptions show tangible benefits:
Proposal
errorprone.refasterrules-based rewritesDiscussion Points
Next Steps
I’m happy to:
relates to:
editorconfig.org#16543Spotlessto reduce the pain on fixing checkstyle issues #17732