openrewrite / openrewrite/rewrite
Code style cleanup support for Checkstyle's ImportOrder and IllegalImport
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 570
- Avg merge
- 13h 12m
- Merged PRs (30d)
- 261
Description
What problem are you trying to solve?
Automatically reformat Java imports according to our Checkstyle configuration.
Describe the solution you'd like
The org.openrewrite.staticanalysis.CodeCleanup plugin suggested by Automatically fix checkstyle violations could support determining the import style by importing the ImportOrder and IllegalImport modules from the checkstyle config.
Have you considered any alternatives or workarounds?
Duplicating the checkstyle import config in an OpenRewrite style: https://docs.openrewrite.org/concepts-explanations/styles
Additional context
I initially thought that https://docs.openrewrite.org/recipes/java/orderimports would support it, but it seems like OpenRewrite's styles are not based on the checkstyle config at all (looking at https://github.com/openrewrite/rewrite/blob/1b487f58b6a2f4839d73afd085ec2ed3f075ab40/rewrite-java/src/main/java/org/openrewrite/java/style/CheckstyleConfigLoader.java).
Are you interested in contributing this feature to OpenRewrite?
Depends on how hard it is. This is the first time I'm using OpenRewrite so at this point I'm still just learning how to use it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with rewrite-java/src/main/java/org/openrewrite/java/style/CheckstyleConfigLoader.java and the org.openrewrite.staticanalysis.CodeCleanup plugin. Review how the OrderImports recipe currently obtains style information, then determine how Checkstyle ImportOrder and IllegalImport configuration should be consumed. Done means CodeCleanup can automatically reformat imports and enforce the relevant Checkstyle restrictions without duplicated OpenRewrite style configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100