Skip to content

[java] Fix #6737: Use next annotatable sibling for suppressing top level - #6902

Merged
UncleOwen merged 3 commits into
pmd:mainfrom
adangel:java/issue-6737-suppress-warnings
Aug 2, 2026
Merged

UncleOwen merged 3 commits into
pmd:mainfrom
adangel:java/issue-6737-suppress-warnings

Conversation

@adangel

@adangel adangel commented Jul 22, 2026

Copy link
Copy Markdown
Member

Describe the PR

If the node itself is not annotatable and if the node is a top level node (like ImportStatement), then use the next annotatable sibling node. This is then most likely the main class declaration in the file.

This restores the ability to suppress warnings with annotations.

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

@adangel adangel added this to the 7.27.0 milestone Jul 22, 2026
@pmd-actions-helper

pmd-actions-helper Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Preview

Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
There are 0 changed duplications, 0 new duplications and 0 removed duplications.
There are 0 changed CPD errors, 0 new CPD errors and 0 removed CPD errors.

Regression Tester Report

(comment created at 2026-08-02 18:23:38+00:00 for 66636fa)

@UncleOwen UncleOwen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@UncleOwen
UncleOwen merged commit 67e3c55 into pmd:main Aug 2, 2026
13 checks passed
@adangel
adangel deleted the java/issue-6737-suppress-warnings branch August 13, 2026 15:02
@adangel adangel changed the title [java] Fix #6737: Use next annotatable sibling for supressing top level [java] Fix #6737: Use next annotatable sibling for suppressing top level Aug 28, 2026
Will-6543 pushed a commit to Will-6543/pmd that referenced this pull request Oct 7, 2026
…level (pmd#6902)

* [java] Fix pmd#6737: Use next annotatable sibling for supressing top level

* Fix spelling

---------

Co-authored-by: Sören Glimm <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[java] TooManyStaticImports: @SuppressWarnings("PMD.TooManyStaticImports") has stopped working

2 participants