Affects PMD Version:
6.27.0
Description:
The UnusedAssignment rule claims the decrement of a
is unused. The if
clauses are necessary to provoke the bug. If only
try { return somethingThatCanThrowRandomly(1); } ...
is used, there is no false positive.
Code Sample demonstrating the issue:
class Test { int a() { int a = 10; while (a > 0) { a--; try { if (dummy) { return somethingThatCanThrowRandomly(1); } else { return somethingThatCanThrowRandomly(2); } } catch (RuntimeException e) { // retry } } return 0; } }
Steps to reproduce:
pmd pmd -d srcdir -rulesets category/java/bestpractices.xml
Running PMD through:
CLI / Gradle
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4