Skip to content

Issue #18673: Organize openrewrite staticanalysis composite recipes by groups as it is done on openrewrite website#18676

Closed
Brijeshthummar02 wants to merge 0 commit into
checkstyle:masterfrom
Brijeshthummar02:openrewrite_recipe
Closed

Issue #18673: Organize openrewrite staticanalysis composite recipes by groups as it is done on openrewrite website#18676
Brijeshthummar02 wants to merge 0 commit into
checkstyle:masterfrom
Brijeshthummar02:openrewrite_recipe

Conversation

@Brijeshthummar02

Copy link
Copy Markdown
Contributor

Issue #18673

I made grouping of the composite recipes (BufferedWriterCreationRecipes, SimplifyTernaryRecipes, URLEqualsHashCodeRecipes) together with appropriate comments, and separating them from the non-composite recipes.

Comment thread config/rewrite.yml Outdated
- org.openrewrite.java.recipes.JavaRecipeBestPractices
- org.openrewrite.java.recipes.RecipeTestingBestPractices
- org.openrewrite.maven.BestPractices
# Composite Recipes

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

no please make full dedication like assumed here:

#18627 (comment)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kindly consider:

---
type: specs.openrewrite.org/v1beta/recipe
name: org.checkstyle.AllAutoFixes
displayName: Auto Fixes
description: List of auto fixes from different providers.
recipeList:
  - org.checkstyle.CodeCleanup
  - org.checkstyle.autofix.CheckstyleAutoFix:
      violationReportPath: target/cs_errors.xml
      configurationPath: config/checkstyle-checks.xml
      propertiesPath: config/openrewrite-recipes-checkstyle.properties
  - org.openrewrite.java.RemoveUnusedImports
  - org.openrewrite.java.format.NormalizeFormat
  - org.openrewrite.java.format.NormalizeLineBreaks
  - org.openrewrite.java.format.RemoveTrailingWhitespace
  - org.openrewrite.java.migrate.UpgradeToJava21
  - org.openrewrite.java.migrate.lang.StringRulesRecipes
  - org.openrewrite.java.migrate.util.MigrateInflaterDeflaterToClose
  - org.openrewrite.java.migrate.util.ReplaceStreamCollectWithToList
  - org.openrewrite.java.migrate.util.SequencedCollection
  - org.openrewrite.java.recipes.JavaRecipeBestPractices
  - org.openrewrite.java.recipes.RecipeTestingBestPractices
  - org.openrewrite.maven.BestPractices
  - org.openrewrite.staticanalysis.BufferedWriterCreationRecipes
  - org.openrewrite.staticanalysis.InlineVariable
  - org.openrewrite.staticanalysis.JavaApiBestPractices
  - org.openrewrite.staticanalysis.LowercasePackage
  - org.openrewrite.staticanalysis.MissingOverrideAnnotation
  - org.openrewrite.staticanalysis.ModifierOrder
  - org.openrewrite.staticanalysis.NoFinalizer
  - org.openrewrite.staticanalysis.NoToStringOnStringType
  - org.openrewrite.staticanalysis.RemoveUnusedLocalVariables
  - org.openrewrite.staticanalysis.RemoveUnusedPrivateFields
  - org.openrewrite.staticanalysis.RemoveUnusedPrivateMethods
  - org.openrewrite.staticanalysis.ReplaceLambdaWithMethodReference
  - org.openrewrite.staticanalysis.SimplifyTernaryRecipes
  - org.openrewrite.staticanalysis.URLEqualsHashCodeRecipes
  - org.openrewrite.staticanalysis.UnnecessaryCloseInTryWithResources
  - org.openrewrite.staticanalysis.UnnecessaryExplicitTypeArguments
  - org.openrewrite.staticanalysis.UnnecessaryReturnAsLastStatement
  - org.openrewrite.staticanalysis.UseLambdaForFunctionalInterface
  - tech.picnic.errorprone.refasterrules.BigDecimalRulesRecipes
  - tech.picnic.errorprone.refasterrules.CharSequenceRulesRecipes
  - tech.picnic.errorprone.refasterrules.ClassRulesRecipes
  - tech.picnic.errorprone.refasterrules.CollectionRulesRecipes
  - tech.picnic.errorprone.refasterrules.ComparatorRulesRecipes
  - tech.picnic.errorprone.refasterrules.FileRulesRecipes
  - tech.picnic.errorprone.refasterrules.MapRulesRecipes
  - tech.picnic.errorprone.refasterrules.MicrometerRulesRecipes
  - tech.picnic.errorprone.refasterrules.MockitoRulesRecipes
  - tech.picnic.errorprone.refasterrules.PatternRulesRecipes
  - tech.picnic.errorprone.refasterrules.PreconditionsRulesRecipes
  - tech.picnic.errorprone.refasterrules.PrimitiveRulesRecipes
  - tech.picnic.errorprone.refasterrules.StreamRulesRecipes
  - tech.picnic.errorprone.refasterrules.TimeRulesRecipes
---
type: specs.openrewrite.org/v1beta/recipe
name: org.checkstyle.CodeCleanup
displayName: Code cleanup
recipeList:
  - org.openrewrite.java.ShortenFullyQualifiedTypeReferences
  - org.openrewrite.java.SimplifySingleElementAnnotation
  - org.openrewrite.java.format.EmptyNewlineAtEndOfFile
  - org.openrewrite.java.format.MethodParamPad
  - org.openrewrite.java.format.PadEmptyForLoopComponents
  - org.openrewrite.staticanalysis.ChainStringBuilderAppendCalls
  - org.openrewrite.staticanalysis.CustomImportOrder
  - org.openrewrite.staticanalysis.DefaultComesLast
  - org.openrewrite.staticanalysis.EmptyBlock
  - org.openrewrite.staticanalysis.EqualsAvoidsNull
  - org.openrewrite.staticanalysis.ExplicitInitialization
  - org.openrewrite.staticanalysis.FallThrough
  - org.openrewrite.staticanalysis.FinalizePrivateFields
  - org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators
  - org.openrewrite.staticanalysis.HideUtilityClassConstructor
  - org.openrewrite.staticanalysis.NeedBraces
  - org.openrewrite.staticanalysis.OperatorWrap
  - org.openrewrite.staticanalysis.ReplaceStringBuilderWithString
  - org.openrewrite.staticanalysis.ReplaceThreadRunWithThreadStart
  - org.openrewrite.staticanalysis.TypecastParenPad
  - org.openrewrite.staticanalysis.UnnecessaryParentheses
  # - org.openrewrite.java.format.NoWhitespaceAfter # incompatible
  # - org.openrewrite.java.format.NoWhitespaceBefore # incompatible
---

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we should use name, the same as in "Yaml Recipe List" tab at
https://docs.openrewrite.org/recipes/staticanalysis/codecleanup

---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.staticanalysis.CodeCleanup
displayName: Code cleanup
description: |
  Automatically cleanup code, e.g. remove unnecessary parentheses, simplify expressions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have replaced ~20 individual org.openrewrite.staticanalysis.* recipes with the single composite org.openrewrite.staticanalysis.CodeCleanup recipe.

Removed duplicates (recipes that are already included in CodeCleanup)

Used the exact name as shown in the OpenRewrite documentation's "Yaml Recipe List" tab

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Brijeshthummar02 , please use above suggestion and use name name: org.openrewrite.staticanalysis.CodeCleanup to make it clear it is list from openrewrite, not us. And only comments on disablement are from us.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@romani i made changes but - Using the same name as org.openrewrite.staticanalysis.CodeCleanup causes a runtime failure due to duplicate recipe keys.
What should i do?

we can keep the OpenRewrite recipe in the recipeList but rename the wrapper recipe to avoid the conflict.
Something like name: org.checkstyle.OpenRewriteCodeCleanup??

@Brijeshthummar02

Copy link
Copy Markdown
Contributor Author

@romani do i need to make any further changes?

@Brijeshthummar02 Brijeshthummar02 force-pushed the openrewrite_recipe branch 2 times, most recently from 11a6a8c to 5e98610 Compare January 22, 2026 16:39
@Brijeshthummar02

Copy link
Copy Markdown
Contributor Author

@romani The CI shows multiple Formatting Braces Spacing Array initializer spacing Issues, should i see to it and make changes or let it as it is??

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do you see that new violations comes from previously inactive recipes ?
If yes. We need to make copy list of what they have and explicitly comment out what we not ready to apply for now. We can discuss separately if this is temporary disablement or permanent

Items

Comment thread config/rewrite.yml
displayName: Auto Fixes
description: List of auto fixes from different providers.
recipeList:
- org.checkstyle.autofix.CheckstyleAutoFix:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let put above this line a comment # composite recipes

And move org.openrewrite.staticanalysis.CodeCleanup to be under org.checkstyle.autofix.CheckstyleAutoFix

Comment thread config/rewrite.yml
propertiesPath: config/openrewrite-recipes-checkstyle.properties
# Code Cleanup includes: EmptyNewlineAtEndOfFile, PadEmptyForLoopComponents,
# ShortenFullyQualifiedTypeReferences, SimplifySingleElementAnnotation
- org.openrewrite.java.RemoveUnusedImports

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please put above ground individual recipes a comment "# individual recipes"

@Brijeshthummar02

Copy link
Copy Markdown
Contributor Author

Do you see that new violations comes from previously inactive recipes ? If yes. We need to make copy list of what they have and explicitly comment out what we not ready to apply for now. We can discuss separately if this is temporary disablement or permanent

Items

Yes — the new violations are coming from previously inactive recipes, mainly introduced via the composite org.openrewrite.staticanalysis.CodeCleanup recipe.

@Brijeshthummar02

Copy link
Copy Markdown
Contributor Author

@romani .
After restructuring the recipes (moving CodeCleanup under the composite CheckstyleAutoFix and clearly separating composite vs individual recipes), CI is now passing and no additional diffs are produced.
At this point:

  • No new violations are introduced
  • No rewrite-generated diffs remain
  • CI is clean

So there is nothing to explicitly disable right now.

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Items

Comment thread config/rewrite.yml Outdated
configurationPath: config/checkstyle-checks.xml
propertiesPath: config/openrewrite-recipes-checkstyle.properties
recipeList:
- org.openrewrite.staticanalysis.CodeCleanup

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure why you put recipeList under other recipeList.

In my mind it should be like

recipeList:
  # composite recipes
  - org.checkstyle.autofix.CheckstyleAutoFix
    ...
  - org.openrewrite.staticanalysis.CodeCleanup

And in same file we have

---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.staticanalysis.CodeCleanup

That is copy from web and some recipe are explicitly commented out

Comment thread config/rewrite.yml Outdated
- org.openrewrite.staticanalysis.CodeCleanup
# individual recipes
# Code Cleanup includes: EmptyNewlineAtEndOfFile, PadEmptyForLoopComponents,
# ShortenFullyQualifiedTypeReferences, SimplifySingleElementAnnotation

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this is hard to underatand please consider SOLID design principles regarding S meaning: SRP SOC

Pankraz76 pushed a commit to Pankraz76/checkstyle that referenced this pull request Jan 24, 2026
… recipes by groups as it is done on openrewrite website checkstyle#18676
Pankraz76 pushed a commit to Pankraz76/checkstyle that referenced this pull request Jan 24, 2026
Pankraz76 pushed a commit to Pankraz76/checkstyle that referenced this pull request Jan 24, 2026
Pankraz76 pushed a commit to Pankraz76/checkstyle that referenced this pull request Jan 24, 2026
Pankraz76 pushed a commit to Pankraz76/checkstyle that referenced this pull request Jan 24, 2026
Pankraz76 pushed a commit to Pankraz76/checkstyle that referenced this pull request Jan 24, 2026
Pankraz76 pushed a commit to Pankraz76/checkstyle that referenced this pull request Jan 24, 2026
Pankraz76 pushed a commit to Pankraz76/checkstyle that referenced this pull request Jan 24, 2026
Pankraz76 pushed a commit to Pankraz76/checkstyle that referenced this pull request Jan 24, 2026
Pankraz76 pushed a commit to Pankraz76/checkstyle that referenced this pull request Jan 24, 2026
Pankraz76 pushed a commit to Pankraz76/checkstyle that referenced this pull request Jan 24, 2026

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

item:

Comment thread config/rewrite.yml Outdated
---
type: specs.openrewrite.org/v1beta/recipe
name: org.checkstyle.AllAutoFixes
name: org.openrewrite.staticanalysis.CodeCleanup

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this list is our list, as it has org.checkstyle.autofix.CheckstyleAutoFix:

create new in this file new block:

---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.staticanalysis.CodeCleanup

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am not getting why we are adding a empty new block.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it isnot empty I just copied top 3 line for you to hint, but you should take all from openrewrite

@Brijeshthummar02 Brijeshthummar02 force-pushed the openrewrite_recipe branch 5 times, most recently from 863fc2d to 64f1271 Compare January 30, 2026 15:04
Pankraz76 pushed a commit to Pankraz76/checkstyle that referenced this pull request Jan 30, 2026
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