Skip to content

[Java] (JDK24 in my case) use of underscore variable triggers checkstyle LambdaParameterName #913

Open
@patpatpat123

Description

@patpatpat123

Hello team,

I am using JDK 24, and since a couple of last Java versions, we can use the underscore sign to substitute a variable that will not be used, what Java called an unnamed variable.

https://medium.com/@benweidig/looking-at-java-22-unnamed-variables-patterns-f9de0b1e2750

For instance:

final boolean someboolean = Optional.ofNullable(getMap()).map(_ -> getHeaders()) [...]

While this is perfectly fine and compiles, checkstyle will flag:

LambdaParameterName

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>3.6.0</version>
                <configuration>
                    <outputDirectory>target/reports/checkstyle</outputDirectory>
                    <configLocation>google_checks.xml</configLocation>
                    <outputFileFormat>xml</outputFileFormat>
                </configuration>
            </plugin>

Could you please help take into account the new java underscore unnamed variable?

Thank you very much and good day.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions