GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [java] UnusedPrivateField - false positive with Lombok @ToString.Include · Issue #4033 · pmd/pmd

[java] UnusedPrivateField - false positive with Lombok @ToString.Include #4033

New issue
Copy link
New issue
Copy link
Closed
#4100
Closed
[java] UnusedPrivateField - false positive with Lombok @ToString.Include#4033
#4100
Copy link
Labels
a:false-positivePMD flags a piece of code that is not problematic
Milestone
6.50.0

Description

@ghost
ghost
opened on Jul 4, 2022

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]

Activity

  1. ghost added
    a:false-positivePMD flags a piece of code that is not problematic
    on Jul 4, 2022
  2. adangel
    changed the title [-]A false positive about the rule UnusedPrivateField[/-] [+][java] UnusedPrivateField - false positive with Lombok @ToString.Include[/+] on Jul 7, 2022
  3. adangel
    added this to the 6.50.0 milestone on Sep 30, 2022
  4. adangel
    added a commit that references this issue on Sep 30, 2022

    [doc] Update release notes (pmd#4100, pmd#4033, pmd#4037)

    2105bde
  5. adangel
    closed this as completedin #4100on Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-positivePMD flags a piece of code that is not problematic

    Type

    No type

    Projects

    No projects

      Milestone

      • 6.50.0

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.