Add `rewrite` support for `errorprone.refasterrules`
- Dominant language
- Java
- Stars
- 7.2k
- Forks
- 820
- Avg merge
- 5h 9m
- Merged PRs (30d)
- 50
Description
### 1. What are you trying to do?
## Add `rewrite` support for `errorprone.refasterrules`
I’d like to propose integrating [Google’s Error Prone](https://github.com/google/error-prone) and its Picnic extension (demonstrated in [Automating Away Bugs with Error Prone | PlatformCon 2023](https://www.youtube.com/watch?v=6llnrUtVlrE)) 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:
- https://github.com/checkstyle/checkstyle/pull/17545
- https://github.com/pmd/pmd/pull/5956
- https://github.com/opensearch-project/OpenSearch/pull/18791
- https://github.com/diffplug/spotless/pull/2576
- https://github.com/apache/kafka/pull/20219
## Proposal
1. Add support for `errorprone.refasterrules`-based rewrites
2. Implement with opt-in adoption (no breaking changes)
3. 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:
- https://github.com/checkstyle/checkstyle/issues/16543
Contributor guide
Assessment
This issue has not been assessed yet.