rewrite-static-analysis icon indicating copy to clipboard operation
rewrite-static-analysis copied to clipboard

`RemoveUnused(Local)Parameter/RemoveUnusedParameters`

Open Pankraz76 opened this issue 2 months ago • 2 comments

What problem are you trying to solve?

  • https://github.com/spring-projects/spring-boot/pull/47694
  • https://errorprone.info/bugpattern/UnusedVariable

It seems this one the missing in the "gang of four" handling all unused stuff.

  • https://docs.openrewrite.org/recipes/staticanalysis/removeunusedprivatemethods
  • https://docs.openrewrite.org/recipes/staticanalysis/removeunusedlocalvariables
  • https://docs.openrewrite.org/recipes/staticanalysis/removeunusedprivatefields

Checking into localvars and fields it seems parameters are not taken care yet.

It should simply remove as happy path. Maybe some hybrid mode via opt in switch would help to keep public api stable by changing the name to unused to pass inspection and dont make a breaking change on top lvl.

Describe the solution you'd like

Have you considered any alternatives or workarounds?

Additional context

Are you interested in contributing this feature to OpenRewrite?

Pankraz76 avatar Nov 11 '25 10:11 Pankraz76

  • https://github.com/openrewrite/rewrite-static-analysis/pull/560

timtebeek avatar Nov 11 '25 10:11 timtebeek

Kindly asking if this is something you would like to pick up as well. @JarvisCraft

Assuming it's just a polish and final touch needed to fix the new recipe. For sure your skillful approach will make this work. Tim and the community are very supportive if there are some details needed. Thinking about you as I'm assuming we also need this kind of adjustment in rewrite, as we sometimes wipe out JUnit stuff as well.

  • https://github.com/google/error-prone/pull/5210

Thanks.

Pankraz76 avatar Nov 11 '25 10:11 Pankraz76