Skip to content

Rewrite non-used variables to _ #720

@koppor

Description

@koppor

(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...

Metadata

Metadata

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions