A RetroSearch Logo

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

Search Query:

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

[java] UnusedPrivateField - false positive with Lombok @ToString.Include · Issue #4033 · pmd/pmd · GitHub

Affects PMD Version:LATEST

Rule:UnusedPrivateField

Please provide the rule name and a link to the rule documentation:
https://pmd.github.io/latest/pmd_rules_java_bestpractices.html#unusedprivatefield

Description:
Hi, I found a false positive about the rule UnusedPrivateField, please read the following code example. @tostring is from lombok library Link, and it can generate a toString method to use the private field. Its similar annotations in lombok have been considered. Hence, I think we should consider this annotation.

I think we can add one more line lombok.ToString.Include in method defaultSuppressionAnnotations of UnusedPrivateFieldRule 😄

Code Sample demonstrating the issue:

@ToString
public class C {
    @ToString.Include
    private int a;  // Should not report a warning in this line
}

Expected outcome:
PMD should not report a violation at line 4, but doesn't. This is a false-positive.

Running PMD through: [Maven]


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