Skip to content

Rewrite non-used variables to _ #720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
koppor opened this issue May 9, 2025 · 0 comments
Open

Rewrite non-used variables to _ #720

koppor opened this issue May 9, 2025 · 0 comments
Labels
java 21+ recipe Recipe requested

Comments

@koppor
Copy link

koppor commented May 9, 2025

(Coming from https://rewriteoss.slack.com/archives/C01A843MWG5/p1746783424812409?thread_ts=1746773248.912599&cid=C01A843MWG5)

What problem are you trying to solve?

I use Java 24. There, JEP 456: Unnamed Variables & Patterns is supported very well.

Example:

-        this.customizeExpertSettings.addListener((observableValue, oldValue, newValue) ->
+        this.customizeExpertSettings.addListener((_, _, newValue) ->

Full example of our prject: https://github.com/JabRef/jabref/pull/13084/files

What precondition(s) should be checked before applying this recipe?

Variable unused.

Describe the situation before applying the recipe

Variable not used in a lambda input

Describe the situation after applying the recipe

Variable replaced by _

Have you considered any alternatives or workarounds?

Following IntelliJs auto marking as gray and replacing by _.

Any additional context

Are you interested in contributing this recipe to OpenRewrite?

If I only had time...

@timtebeek timtebeek moved this to Backlog in OpenRewrite May 9, 2025
@timtebeek timtebeek moved this from Backlog to Recipes Wanted in OpenRewrite May 9, 2025
@timtebeek timtebeek added the recipe Recipe requested label May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
java 21+ recipe Recipe requested
Projects
Status: Recipes Wanted
Development

No branches or pull requests

2 participants