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

Code style cleanup support for Checkstyle's ImportOrder and IllegalImport #4440

Open
slovdahl opened this issue Aug 23, 2024 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@slovdahl
Copy link

slovdahl commented Aug 23, 2024

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.

@slovdahl slovdahl added the enhancement New feature or request label Aug 23, 2024
@slovdahl
Copy link
Author

We also happen to have the import order (not the "illegal imports") duplicated already in an .editorconfig file exported for IntelliJ using the ij_java_imports_layout property in a [*.java] section. It doesn't seem like OpenRewrite can use this either?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

1 participant