A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/4618 below:

[java] UnusedAssignment false positive with conditional assignments of fields · Issue #4618 · pmd/pmd · GitHub

Affects PMD Version:
7.0.0-SNAPSHOT

Rule:

https://pmd.github.io/pmd/pmd_rules_java_bestpractices.html#unusedassignment

Description:

Code Sample demonstrating the issue:

Expected outcome:

PMD reports violations, but that's wrong. These are false positives:

Selftest.java:162:	UnusedAssignment:	The value assigned to field 'withIssues' is never used (overwritten on line 168)
Selftest.java:177:	UnusedAssignment:	The value assigned to field 'withIssues' is never used (overwritten on line 184)
Selftest.java:666:	UnusedAssignment:	The value assigned to field 'modified' is never used (overwritten on lines 682 and 703)
Selftest.java:703:	UnusedAssignment:	The value assigned to field 'modified' is never used (reassigned every iteration)
Selftest.java:704:	UnusedAssignment:	The value assigned to field 'withIssues' is never used (overwritten on lines 704 and 762)

The values are assigned conditionally, within an if-clause.

Running PMD through: CLI/Maven

Files attached.
file-and-ruleset3.zip


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