[java] MissingStaticMethodInNonInstantiatableClass should consider Lombok's @NoArgsConstructor #4225
Labels
a:false-positive
PMD flags a piece of code that is not problematic
Milestone
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 constructorpublic C()
but PMD considers theC
class only has private constructor and does not have any static methods or fields cannot be used which triggersMissingStaticMethodInNonInstantiatableClass
Lombok Documentation: https://projectlombok.org/features/constructor
Note: there are more annotations, like
@RequiredArgsConstructor
and@AllArgsConstructor
.Code Sample demonstrating the issue:
Original code:
Changed:
Expected outcome:
PMD reports a violation at line 4, but that's wrong. That's a false positive.
Running PMD through: CLI
The text was updated successfully, but these errors were encountered: