-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[POC] Modernize codebase - Automatically fix Checkstyle violations
#2300
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
[POC] Modernize codebase - Automatically fix Checkstyle violations
#2300
Conversation
19cf86c
to
192b9a2
Compare
Automatically fix Checkstyle violations
Modernize codebase - Automatically fix Checkstyle violations
Ah, now, you enable the tooling. That's becoming interesting... |
Modernize codebase - Automatically fix Checkstyle violations
Checkstyle violations
Not sure I understand here. As we are using spotless already for the code, what is this PR providing? |
We still use checkstyle for things other than code formatting. |
But I'm quite bored with rules that fail. I'd much rather have tooling that fixes things automatically (or at least is able to do so, same as spotless). |
So the workflow would rather be: run openrewrite rules and make sure there's no changes. |
Right. So it might be better to have this in the maven-parent? |
@Pankraz76 do you want to focus on that, rather than not-enforced checkstyle rules and results of openrewrite recipes ? |
yes good idea. Thanks |
yes its very nice, but still not fully automated, kind of demanding
Editorconfig has autofix as well but not for custom IDE specs like this tool really plays out its cards. Just giving you my noob exp upfront. Its fixing itself, like magic, but not for imports, failing the build.
this issue unsolved to me. 1 LOC will fix for all: ij_java_names_count_to_use_import_on_demand = 999 ![]() |
Integration in IDE is nice to have, but more importantly refactoring at build time using a maven plugin in a profile. |
Checkstyle violations
Checkstyle violations
![]() Would be nice to have it in place running like rewrite, via github actions: openrewrite/rewrite-static-analysis#497 (comment) Its nifty that we have outdated stuff gone in , but its not banned and fixed on the long run; still causing friction, needed to be automated. As local run is optional, but the way to do. We would add all wanted styles and make like spotless. Then after clean install code would be fixed, but not forces to be pushed again. Checkstyle will ensure spotless violations, but not rewrite recipes (e.g. unused methods). Would need to add rewrite checks and auto apply them, or kind of prevent merge, until resolved to solve this. feels wierd. Whats your advice, how to fix this on the long run? @timtebeek
![]() |
I don't think changing the code in an action would be a good idea. I'd really favor the same behavior we use with spotless, i.e. a profile (activated by default) which fails the build if a rule cannot be validated (in the case of open rewrite, if a rule would actually apply and change the code) and a profile which would actually apply the rules. |
might be not configured nor supported; this seems to be a gap in project setup, as despite nice tooling, still having misaligned code:
|
The OpenRewrite maven plugin seems a much better way to fix the problems imho: The @Pankraz76 could you please close all the PRs about refactoring that use openrewrite and focus on adding the plugin in the build instead ? |
actually done:
|
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-checkstyle-plugin</artifactId> | ||
<version>3.6.0</version> | ||
<configuration> | ||
<configLocation>http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-checkstyle-plugin/src/main/resources/config/maven_checks.xml</configLocation> | ||
</configuration> | ||
</plugin> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we already have a checkstyle configuration in parent pom ..... and rules have a different source
successor: #2322 |
At OpenRewrite, and others like Langchain4j, we run recipes that suggest fix comments on PRs as documented here:https://www.moderne.ai/blog/stop-breaking-ci-annotate-prs-with-openrewrite-recipe-fixes-as-quality-gate |
we need strict leadership on our suggestions enforcing them like good cop, bad cop. |
enjoy |
Modernize codebase - Automatically fix
Checkstyle violations
- implement IDE agnostic configuration witheditorconfig.org
ref:
Modernize codebase - Bump maven-checkstyle-plugin to: 3.6.0
#2301editorconfig-maven-plugin
: implement IDE agnostic configuration #2321editorconfig.org
checkstyle/checkstyle#16574