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] ClassWithOnlyPrivateConstructorsShouldBeFinal false positive with Lombok's `@NoArgsConstructor` · Issue #4188 · pmd/pmd

[java] ClassWithOnlyPrivateConstructorsShouldBeFinal false positive with Lombok's @NoArgsConstructor #4188

New issue
Copy link
New issue
Copy link
Closed
#4192
Closed
[java] ClassWithOnlyPrivateConstructorsShouldBeFinal false positive with Lombok's @NoArgsConstructor#4188
#4192
Copy link
Labels
a:false-positivePMD flags a piece of code that is not problematic
Milestone
6.52.0

Description

@ghost
ghost
opened on Nov 3, 2022

Affects PMD Version:6.51.0

Rule:ClassWithOnlyPrivateConstructorsShouldBeFinal

Please provide the rule name and a link to the rule documentation:
https://pmd.sourceforge.io/pmd-6.51.0/pmd_rules_java_design.html#classwithonlyprivateconstructorsshouldbefinal

Description:
Hi, I found a false positive about this rule, please read the following code example. PMD should not report a warning for this class because @NoArgsConstructor can add a constructor for this class. Hence, I think this is a false positive.

  • https://projectlombok.org/features/constructor
  • https://projectlombok.org/api/lombok/NoArgsConstructor

Code Sample demonstrating the issue:

import lombok.NoArgsConstructor;
@NoArgsConstructor
public class C {
    private C(String[] arr, long in, String res) {}
}

Expected outcome:

PMD reports a violation at line 3, but that's wrong. That's a false positive.

Running PMD through: [Maven]

Activity

  1. ghost added
    a:false-positivePMD flags a piece of code that is not problematic
    on Nov 3, 2022
  2. adangel
    changed the title [-][java] A false positive about the rule ClassWithOnlyPrivateConstructorsShouldBeFinal[/-] [+][java] ClassWithOnlyPrivateConstructorsShouldBeFinal false positive with Lombok's `@NoArgsConstructor`[/+] on Nov 4, 2022
  3. adangel
    added this to the 6.52.0 milestone on Nov 4, 2022
  4. adangel
    added a commit that references this issue on Nov 4, 2022

    [java] ClassWithOnlyPrivateConstructorsShouldBeFinal: Exclude lombok …

    This issue will close once commit 66b6893 is merged into the 'main' branch.
    66b6893
  5. adangel
    closed this as completedin 66b6893on Nov 25, 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.52.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.