openrewrite / rewrite

Automated mass refactoring of source code.
https://docs.openrewrite.org
Apache License 2.0
2.15k stars 321 forks source link

OrderImports with removeUnused=true removes types+annotations used in record components #2965

Closed fprochazka closed 1 year ago

fprochazka commented 1 year ago

I've created this config

---
type: specs.openrewrite.org/v1beta/recipe
name: com.fprochazka.Experiments
recipeList:
  - org.openrewrite.java.OrderImports:
      removeUnused: true

and then executed that over my project that uses a lot of records. It removed every import, that was used within a file only in record components.

knutwannheden commented 1 year ago

@fprochazka Thanks for the detailed report! A fix has been integrated and will be available in the next release (and the next SNAPSHOT build).