You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[java] MissingStaticMethodInNonInstantiatableClass: False positive with multiple top-level classes #4531
Description:
The rule fails to properly handle when there is more than one top-level class.
In the following example, Bar2 is correctly flagged by the rule, but as a top-level class is annotated with @UtilityClass, all top-level classes are analyzed as if annotated, and hence Bar1 is also flagged.
Code Sample demonstrating the issue:
importlombok.experimental.UtilityClass;
classBar1 {} // report a warning, but this is a FP@UtilityClassclassBar2 {} // report a warning
The problem lies with this line:
let $isLombokUtility := exists($topLevelClass[pmd-java:hasAnnotation('lombok.experimental.UtilityClass')]) return
This exists check is not bound to the particular top-level class being analyzed.
Expected outcome:
PMD reports a violation at line 2, but that's wrong. That's a false positive.
changed the title [-][java] A false positive about MissingStaticMethodInNonInstantiatableClass[/-][+][java] MissingStaticMethodInNonInstantiatableClass: False positive with multiple top-level classes[/+]on Dec 19, 2025
Activity
[-][java] A false positive about MissingStaticMethodInNonInstantiatableClass[/-][+][java] MissingStaticMethodInNonInstantiatableClass: False positive with multiple top-level classes[/+][java] Fix pmd#4531: MissingStaticMethodInNonInstantiatableClass with…
[java] Fix pmd#4531: MissingStaticMethodInNonInstantiatableClass fals…