Open
Description
Affects PMD Version: 7.1.0
Rule: UnusedAssignment
Description:
a flag set in a method, and directly reset after executing some code causes a UnusedAssignment since PMD 7. In PMD 6 this was no issue
Code Sample demonstrating the issue:
@Override
public void run(@NotNull final Runnable runnable) {
if (entered || conflict) {
return;
}
try {
entered = true;
runnable.run();
} finally {
entered = false;
}
}
Expected outcome:
This should be fine as the runnable can get the set flag and can access the method again.
[INFO] PMD Failure: works.reload.relogic.recursion.RecursionGuardImpl:56 Rule:UnusedAssignment Priority:3 The value assigned to field 'entered' is never used (overwritten on line 59).
Running PMD through: Maven