openrewrite / rewrite-gradle-plugin

OpenRewrite's Gradle plugin.
Apache License 2.0
56 stars 34 forks source link

Allow opt-out from recipe groups #243

Closed vlsi closed 8 months ago

vlsi commented 8 months ago

What problem are you trying to solve?

I wanted adding org.openrewrite.staticanalysis.CodeCleanup recipe, however, it implies HideUtilityClassConstructorStyle which breaks backward compatibility.

Describe the solution you'd like

I would like to exclude certain rules even if they are included with "group recipe".

Have you considered any alternatives or workarounds?

An alternative option could probably be adding boolean isEnabled at org.openrewrite.style.Style level, so the rules could be selectively disabled with rewrite.yml

Are you interested in contributing this feature to OpenRewrite?

It depends on the preferred implementation

timtebeek commented 8 months ago

Thanks for reporting your issue here. It sounds like you want to exclude one recipe when running a composite recipe, is that correct? It comes up from time to time, leading us to add it to the frequently asked questions. In short it's not easy to exclude a single recipe, as other recipes might expect other recipes to have run already. We suggest you create a copy of such a composite recipe only containing the recipes you want to run.

Especially for libraries I understand you're more sensitive to backwards compatibility. A custom recipe set would then make most sense.

timtebeek commented 8 months ago

Hope you don't mind me closing this issue as there's more details in the link above. I'll still monitor any replies that come in below.

vlsi commented 8 months ago

Thanks for the link. I suggest adding an explicit link from https://docs.openrewrite.org/recipes/staticanalysis/codecleanup and https://docs.openrewrite.org/recipes/staticanalysis/commonstaticanalysis to https://github.com/openrewrite/rewrite-static-analysis/blob/main/src/main/resources/META-INF/rewrite/static-analysis.yml and similar group recipes.

The only practical way of listing 30+ recipes is to copy-paste them, and it would help to reference the relevant source.

timtebeek commented 8 months ago

Thanks for the link. I suggest adding an explicit link from https://docs.openrewrite.org/recipes/staticanalysis/codecleanup and https://docs.openrewrite.org/recipes/staticanalysis/commonstaticanalysis to https://github.com/openrewrite/rewrite-static-analysis/blob/main/src/main/resources/META-INF/rewrite/static-analysis.yml and similar group recipes.

The only practical way of listing 30+ recipes is to copy-paste them, and it would help to reference the relevant source.

That's what the GitHub link under Source does right? Or did I misunderstand? Maybe we should add an icon there to make it clear /cc @mike-solomon Or listing the last element of that path as a clickable link like FindAndReplace.java or static-analysis.yml

mike-solomon commented 8 months ago

Thanks for the link. I suggest adding an explicit link from https://docs.openrewrite.org/recipes/staticanalysis/codecleanup and https://docs.openrewrite.org/recipes/staticanalysis/commonstaticanalysis to https://github.com/openrewrite/rewrite-static-analysis/blob/main/src/main/resources/META-INF/rewrite/static-analysis.yml and similar group recipes. The only practical way of listing 30+ recipes is to copy-paste them, and it would help to reference the relevant source.

That's what the GitHub link under Source does right? Or did I misunderstand? Maybe we should add an icon there to make it clear /cc @mike-solomon Or listing the last element of that path as a clickable link like FindAndReplace.java or static-analysis.yml

I'm not sure I understand what you're suggesting. Is the idea that we'd want the GitHub logo next to the GitHub link? I'm not sure I follow how that would make the link clearer but maybe I'm misunderstanding something.

timtebeek commented 8 months ago

Adding the logo might help indeed, as folks are likely to skip over the text (I know I have in the past).

mike-solomon commented 8 months ago

Adding the logo might help indeed, as folks are likely to skip over the text (I know I have in the past).

Fair enough! Opened an issue to add that.

vlsi commented 8 months ago

Adding the logo might help indeed, as folks are likely to skip over the text (I know I have in the past).

I thought the link points to rewrite-docs github, so users could update the docs :-/

mike-solomon commented 8 months ago

Adding the logo might help indeed, as folks are likely to skip over the text (I know I have in the past).

I thought the link points to rewrite-docs github, so users could update the docs :-/

Thanks for the feedback and clarification @vlsi !

Do you think that updating the section to say Recipe Source instead of Source would make that clearer?

vlsi commented 8 months ago

Recipe source would indeed be great!

mike-solomon commented 8 months ago

Added a note and updated the title - so hopefully that addresses all the concerns with this. Thanks again for the feedback!

image