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] TooManyStaticImports: @SuppressWarnings("PMD.TooManyStaticImports") has stopped working #6737
Earlier the @SuppressWarnings("PMD.TooManyStaticImports") used to work when defined over a class with the file having too many static imports but now it has stopped being honoured.
Steps to reproduce:
Please provide detailed steps for how we can reproduce the bug.
Add a test class with too many static imports
Try to suppress the warning by including suppress annotation over the class
changed the title [-]@SuppressWarnings("PMD.TooManyStaticImports") has stopped working[/-][+][java] TooManyStaticImports: @SuppressWarnings("PMD.TooManyStaticImports") has stopped working[/+]on May 30, 2026
Since 7.25.0 the location for some violations has been shrunk. Previously, TooManyStaticImports reported the whole file, now it only reports the last(!) import statement. See #6084 for details.
Could you try adding //NOPMD to your last import statement?
@UncleOwen // NOPMD works but it was not on the last import but instead the first import as it currently the static import exception is reporting the failure at the first import and // NOPMD is to be added where the error is reported.
However isn't NOPMD a little strict, because if there is anything else reporting for that line, it will also miss?
I just needed a rule where my test cases can resist more than 4 static imports, I believe if possible we should also make 10-15 as default for test classes
Activity
[-]@SuppressWarnings("PMD.TooManyStaticImports") has stopped working[/-][+][java] TooManyStaticImports: @SuppressWarnings("PMD.TooManyStaticImports") has stopped working[/+]UncleOwen commentedon May 30, 2026
Since 7.25.0 the location for some violations has been shrunk. Previously,
TooManyStaticImportsreported the whole file, now it only reports the last(!) import statement. See #6084 for details.Could you try adding
//NOPMDto your last import statement?altaiezior commentedon May 30, 2026
@UncleOwen // NOPMD works but it was not on the last import but instead the first import as it currently the static import exception is reporting the failure at the first import and // NOPMD is to be added where the error is reported.
However isn't NOPMD a little strict, because if there is anything else reporting for that line, it will also miss?
altaiezior commentedon May 30, 2026
I just needed a rule where my test cases can resist more than 4 static imports, I believe if possible we should also make 10-15 as default for test classes
UncleOwen commentedon Jun 2, 2026
You could set the maximumStaticImports property to a higher value, or just not use this rule at all in your tests.
A second ruleset for tests is common practice.
[java] Fix pmd#6737: Use next annotatable sibling for supressing top …
TooManyStaticImportstriggered with explicit warning suppression #6983 as a duplicate of this issue[java] Fix pmd#6737: Use next annotatable sibling for supressing top …