Affects PMD Version:
7.2.0
Rule:
LocalVariableCouldBeFinal
Code Sample demonstrating the issue:
private Optional<FileWatcher> createFileWatcher() { @SuppressWarnings("PMD.LocalVariableCouldBeFinal") Optional<FileWatcher> optionalFileWatcher; // false positive in PMD 7.2.0, cannot be final try { optionalFileWatcher = Optional.of(new FileWatcher()); } catch (final IOException e) { optionalFileWatcher = Optional.empty(); } return optionalFileWatcher; }
Expected outcome:
This is new in 7.2.0 and worked in prior versions.
PMD reports a violation, but that's wrong. That's a false positive.
Running PMD through:
Maven
c0va23, vik4es, alexsandrospecht, zman0900, lexinator and 2 more
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