[POC] Modernize codebase - Automatically fix Checkstyle violations#2300
[POC] Modernize codebase - Automatically fix Checkstyle violations#2300Pankraz76 wants to merge 1 commit intoapache:masterfrom
Checkstyle violations#2300Conversation
19cf86c to
192b9a2
Compare
Automatically fix Checkstyle violationsModernize codebase - Automatically fix Checkstyle violations
|
Ah, now, you enable the tooling. That's becoming interesting... |
Modernize codebase - Automatically fix Checkstyle violationsCheckstyle 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 |
Integration in IDE is nice to have, but more importantly refactoring at build time using a maven plugin in a profile. |
Checkstyle violationsCheckstyle 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.
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.orgref:
Modernize codebase - Bump maven-checkstyle-plugin to: 3.6.0#2301editorconfig-maven-plugin: implement IDE agnostic configuration #2321spotlesscheckstyle/checkstyle#16574