Skip to content

Conversation

@timtebeek
Copy link
Member

What's changed?

Added a new recipe with very limited scope in applying var only where initialized by a type cast within methods.

What's your motivation?

This seemed like a simple and safe, non-controversial usage of var that we can then adopt in our tests, which frequently unpack and cast.

Anything in particular you'd like reviewers to focus on?

Any edge cases where this might be unsafe?

Have you considered any alternatives or workarounds?

Could have also tackled static initializer blocks, but that seemed rare to me to have casts there.

@timtebeek timtebeek requested a review from MBoegers January 11, 2026 12:20
@timtebeek timtebeek self-assigned this Jan 11, 2026
@timtebeek timtebeek added the recipe Recipe requested label Jan 11, 2026
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Jan 11, 2026
@timtebeek timtebeek moved this from In Progress to Ready to Review in OpenRewrite Jan 12, 2026
Copy link
Contributor

@MBoegers MBoegers left a comment

Choose a reason for hiding this comment

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

LGTM, great to see another edge case closed.

@timtebeek timtebeek merged commit 170b248 into main Jan 13, 2026
2 checks passed
@timtebeek timtebeek deleted the use-var-for-type-casts-only branch January 13, 2026 11:01
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Jan 13, 2026
@timtebeek
Copy link
Member Author

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

Labels

recipe Recipe requested

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants