-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
a:false-positivePMD flags a piece of code that is not problematicPMD flags a piece of code that is not problematic
Milestone
Description
Affects PMD Version:
7.17.0
Rule:
AssignmentInOperand
Please provide the rule name and a link to the rule documentation:
AssignmentInOperand
Description:
The fix for issue #3434 causes version 7.17.0 to flag assignment in case assignments.
Code Sample demonstrating the issue:
public final class FPTestAssignmentInOperand {
private FPTestAssignmentInOperand() {}
public static void main(String[] args)
{
String a = null;
String b = null;
String c = null;
switch (args[0])
{
case "A" -> a = "a";
case "B" -> b = "b";
case "C" -> c = "c";
default -> {/*Do Nothing*/}
}
System.out.println("A: " + a + ", B: " + b + ", C: " + c);
}
}Expected outcome:
PMD reports a violation at lines 12,13, and 14, but that's wrong. That's a false positive.
Running PMD through: Eclipse
Metadata
Metadata
Assignees
Labels
a:false-positivePMD flags a piece of code that is not problematicPMD flags a piece of code that is not problematic