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
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