Skip to content

[java] ShortVariable false positive for java 22 unnamed variable _ #5892

@emouty

Description

@emouty

Affects PMD Version:

Rule: ShortVariable

Description:
_ is being flagged as shortvariable

Code Sample demonstrating the issue:

 switch (myValue) {
        case FirstClass _ -> throw new IllegalStateException("");
		case SecondClass _ -> System.out.print("I'm in second class");
		}

Expected outcome:

_ should not be flagged as short variable since its a special variable name

Running PMD through: Maven | PMD Intellij plugin

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-positivePMD flags a piece of code that is not problematic

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions