Affects PMD Version:
7.0-rc1 when upgrading from 6.55
Rule:
UnusedAssignment
Description:
A class field is not the same as a method variable as it is in scope for other method calls. This also only restores the value when an unhandled error occurs to rollback the state, so the detection is misunderstanding the behavior.
Code Sample demonstrating the issue:
public void advance(BoundedLocalCache<K, V> cache, long currentTimeNanos) { long previousTimeNanos = nanos; nanos = currentTimeNanos; try { // ... } catch (Throwable t) { nanos = previousTimeNanos; throw t; } }
Expected outcome:
PMD reports a violation but that should not apply to a class field.
Running PMD through: Gradle
This requires workaround in gradle/gradle#24502
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