A RetroSearch Logo

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

Search Query:

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

[java] UnusedAssignment false positive in record compact constructor · Issue #4603 · pmd/pmd · GitHub

Affects PMD Version: 7.0.0-rc3 (works fine in 6.55.0)

Rule: UnusedAssignment

Description:

False-positive is reported when a variable is assigned in record compact constructor.

 UnusedAssignment:       The value assigned to variable 'foo' is never used

Code Sample demonstrating the issue:

class Main {
    public static void main(String[] args) {
        System.out.println(new TestRecord(2).foo());
    }
}

record TestRecord(int foo) {
    TestRecord {
        foo = Math.min(foo, 1); // <!--- violation here
    }
}

Expected outcome:

PMD should not report false-positive about unused foo in compact constructor.

Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
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