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

configure and run OpenRewrite #805

Merged
merged 12 commits into from
Jan 19, 2025
Merged

Conversation

Bananeweizen
Copy link
Collaborator

@Bananeweizen Bananeweizen commented Jan 19, 2025

OpenRewrite is a mass refactoring engine to which I contribute since 2 years. This PR configures it and runs several refactorings. Every refactoring kind is in a separate commit for easier review. I intend to enable more of the recipes later and to submit more such changes until we reach a state where all enabled recipes can be run periodically and all changes can be submitted in one go.

@rnveach The main checkstyle project might profit from a similar configuration even more. Here in this project a lot of the recipes don't catch all occurrences, because the classes loaded by Tycho are not available to the type system inside OpenRewrite. In the main project everything is plain maven, therefore each recipe should apply everywhere. If you want me to configure something (like the "RemoveTestPrefix" recipe or similar) for a demo PR, then mention me, please.

@romani
Copy link
Member

romani commented Jan 19, 2025

Checkstyle is not enforced over plugin due a lot of violations.
Is it make it close to enforcing?

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's try this auto fixer.

@romani romani requested a review from Calixte January 19, 2025 19:41
@Bananeweizen
Copy link
Collaborator Author

Bananeweizen commented Jan 19, 2025

Checkstyle is not enforced over plugin due a lot of violations. Is it make it close to enforcing?

No. While this change fixes some of them, there are still thousands of violations. As I mentioned already in #388 and other issues, it would be simple to fix 90% of those several thousands violations in an automated way, e.g. using OpenRewrite, the Eclipse clean actions and the Eclipse formatter. I already did that locally in 2022 within 4 hours of work. However, these fixes for the 90% of violations would lead to the patch filter raising many of the remaining 10% of issues because they happen to be in the same lines. And I don't want to do any manual changes for these 10% just to pass the diff filter. I just want to commit the automated changes for the 90% of issues ignoring the diff filter, because it fixes some thousand violations, and requiring zero remaining violations in 20.000 changed lines is just not useful.
And as long as that is rejected (as it has been every time I suggested it), I'll not even start doing the 90% fixes.

Let's try this auto fixer.

I've been using it on more than a million lines of production code already over the last 2 years. While it does have some bugs in corner cases, it still makes cleaning up old code bases much more efficient. Some projects like the Spring project meanwhile have all their upgrade guides as OpenRewrite refactorings, such that all Spring users can upgrade automatically.

@Bananeweizen Bananeweizen merged commit ba07ad9 into checkstyle:master Jan 19, 2025
7 checks passed
@Bananeweizen Bananeweizen deleted the rewrite branch January 19, 2025 21:13
@romani
Copy link
Member

romani commented Jan 19, 2025

@Bananeweizen , please keep @Calixte in loop of all changes before merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants