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] MissingStaticMethodInNonInstantiatableClass should consider Lombok's @NoArgsConstructor · Issue #4225 · pmd/pmd

[java] MissingStaticMethodInNonInstantiatableClass should consider Lombok's @NoArgsConstructor #4225

New issue
Copy link
New issue
Copy link
Closed
#4227
Closed
[java] MissingStaticMethodInNonInstantiatableClass should consider Lombok's @NoArgsConstructor#4225
#4227
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 22, 2022

Affects PMD Version:6.51.0

Rule: MissingStaticMethodInNonInstantiatableClass

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

Description:
In the following code example, the @NoArgsConstructor generates a public constructor public C() but PMD considers the C class only has private constructor and does not have any static methods or fields cannot be used which triggers MissingStaticMethodInNonInstantiatableClass

Lombok Documentation: https://projectlombok.org/features/constructor

Note: there are more annotations, like @RequiredArgsConstructor and @AllArgsConstructor.

Code Sample demonstrating the issue:

Original code:

import lombok.NoArgsConstructor;

@NoArgsConstructor
public class C {
    private C(int a, int b, int c, String abc, long d, double p,
                             String[] arr, int data, long in, float fl, String res) { }
}

Changed:

public class C {
    private C(int a, int b, int c, String abc, long d, double p, String[] arr, int data, long in, float fl, String res) {
    }

    public C() {
    }
}

Expected outcome:

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

Running PMD through: CLI

Activity

  1. ghost added
    a:false-positivePMD flags a piece of code that is not problematic
    on Nov 22, 2022
  2. adangel
    changed the title [-][java] MissingStaticMethodInNonInstantiatableClass should considers lombok's @NoArgsConstructor[/-] [+][java] MissingStaticMethodInNonInstantiatableClass should consider Lombok's @NoArgsConstructor[/+] on Nov 22, 2022
  3. adangel
    modified the milestones: 6.53.0, 6.52.0 on Nov 22, 2022
  4. adangel
    closed this as completedin #4227on Nov 25, 2022
  5. adangel
    added a commit that references this issue on Nov 25, 2022

    [doc] Update release notes (pmd#4225, pmd#4227)

    ddb60c5
  6. adangel
    closed this as completedin 376d4fbon Nov 25, 2022
  7. adangel
    added a commit that references this issue on Nov 25, 2022

    Merge pull request pmd#4227 from LynnBroe:issue4225

    This issue will close once commit a5cce75 is merged into the 'main' branch.
    a5cce75
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.