Skip to content

Add rewrite support for errorprone.refasterrules.FileRulesRecipes #20219

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

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

Pankraz76
Copy link

@Pankraz76 Pankraz76 commented Jul 22, 2025

refs:

The code seems to be out of sync considering the changes made when applying the config/convention:

(Assuming the version bump alone did not make these changes in the headers)

Also assuming that Java files currently have no header check besides Checkstyle. It seems considerable to have the Spot config in one place, giving it Separation of Concerns as well as Single Source of Truth.

Copy link
Author

@Pankraz76 Pankraz76 left a comment

Choose a reason for hiding this comment

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

outdated dependencies.

@Pankraz76 Pankraz76 marked this pull request as ready for review July 22, 2025 14:55
@github-actions github-actions bot removed the triage PRs from the community label Jul 23, 2025
@Pankraz76 Pankraz76 force-pushed the rewrite- branch 2 times, most recently from 3f6ade4 to 4564214 Compare July 25, 2025 10:42
@Pankraz76
Copy link
Author

BUILD SUCCESSFUL in 38m 46s
374 actionable tasks: 90 executed, 284 up-to-date
➜  kafka git:(rewrite-) ./gradlew build -x test 

Kindly request your feedback. Thanks for consideration.

Is this is any good?

@m1a2st
@sjhajharia
@ravikalla
@apoorvmittal10
@CalvinConfluent
@chia7712
@frankvicky

@Pankraz76 Pankraz76 requested a review from timtebeek July 25, 2025 11:12
Copy link

@ravikalla ravikalla left a comment

Choose a reason for hiding this comment

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

The PR is marked as "[Experimental]" but makes changes that would affect all developers immediately. This includes modifying the main build configuration, adding new required tasks to the check lifecycle, enabling build caching globally, and changing existing tool configurations. For an experimental feature, I'd suggest using a separate build file or opt-in flag instead. It would also be helpful to create a feature branch for testing, provide a way to disable the rewrite checks, and add proper documentation about the experimental nature of these changes.

Choose a reason for hiding this comment

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

Both Spotless and Rewrite are configured to handle imports: Spotless has importOrder() configuration and Rewrite has RemoveUnusedImports recipe active.

This creates overlapping responsibilities and potential conflicts. Consider either:

  1. Using only Spotless for formatting/imports and Rewrite for code cleanup
  2. Disabling import handling in one of the tools

Copy link
Author

Choose a reason for hiding this comment

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

Yes, thanks for pointing out.

Indeed, Rewrite has the ability to take over, making Spot and Check obsolete, considering the recipe:

As a potential migration is too much for now, this PR is considered kind of PoC.

The import case is a good example - Rewrite has also bugs of course, but in this case seems to be stronger due to the type awareness.
Assuming Spot (which uses Google's formatter) is just a simple file parser like Checkstyle, it has a lot of blind spots in the unused imports theme again.

2. Disabling import handling in one of the tools

yes shifted from spot to rewrite demonstrating the leftovers.

  • Using only Spotless for formatting/imports and Rewrite for code cleanup

yes thats the goal to later on check if spot is still necessary.

But first start small then continue.

Choose a reason for hiding this comment

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

Thanks for clarifying. I agree that starting small is better. Since you're demonstrating Rewrite's capabilities as a PoC, I suggest you to document in the PR description that this is exploring Rewrite as a potential Spotless replacement. For now, you can explicitly disable import handling in Spotless to avoid conflicts. Consider creating a follow-up issue to track the full migration evaluation.

@Pankraz76
Copy link
Author

The PR is marked as "[Experimental]" but makes changes that would affect all developers immediately. This includes modifying the main build configuration, adding new required tasks to the check lifecycle, enabling build caching globally, and changing existing tool configurations. For an experimental feature, I'd suggest using a separate build file or opt-in flag instead. It would also be helpful to create a feature branch for testing, provide a way to disable the rewrite checks, and add proper documentation about the experimental nature of these changes.

Maybe [PoC] would reflect my intention better as this is just some suggestion offered.

It needs to be wanted and pulled by the dev team, as it's a conventional change, not designed to opt in, as the nature of this can be (once) invasive and is meant to sustain therefore be constantly checked against. Same approach like spot but more flexible.

I would suggest to make a decision about using the potential benefit this tool has to offer and then integrate it non-breaking/colliding with anything of course, making it ready (opt-in/out) to be removed afterwards again, if it turns out, not to be practical.

The import statement is a good starter and the removals as they should flag only once and non-critical stuff as overhead is normally obsolete, ready to be reconsidered and resolved.

As the task is meant to run in cloud only it's about time and stability, as the recipes are individual.
Only the dev teams choose which to leverage and apply.

@Pankraz76 Pankraz76 changed the title [Experimental] Add rewrite support for RemoveUnusedPrivateMethods & RemoveUnusedImports [PoC] Add rewrite support for RemoveUnusedPrivateMethods & RemoveUnusedImports Jul 26, 2025
@Pankraz76 Pankraz76 changed the title [PoC] Add rewrite support for RemoveUnusedPrivateMethods & RemoveUnusedImports Add rewrite support for errorprone.refasterrules.FileRulesRecipes Jul 26, 2025
@Pankraz76
Copy link
Author

BUILD SUCCESSFUL in 12m 31s
133 actionable tasks: 133 executed
16:38:11: Execution finished 'rewriteRun'.

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

Successfully merging this pull request may close these issues.

3 participants