Skip to content

Conversation

@lukasgraef
Copy link
Contributor

@lukasgraef lukasgraef commented Jun 9, 2025

Describe the PR

This should catch some FPs when referencing Classes/Methods/Fields from (static) on-demand imports in JavaDoc.
One case I explicitly didn't add support for was when referencing a static method in JavaDoc without its class, since IntelliJ also doesn't support such links.

Examples:

This is supported:

import java.util.function.*;
/**
 * {@link Predicate#isEqual(Object)}}
 */

But this not: (this is also not supported by javadoc)

import static java.util.function.Predicate.*;
/**
 * {@link isEqual(Object)}}
 */

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)

@github-actions
Copy link

github-actions bot commented Jun 9, 2025

Documentation Preview

Compared to main:
This changeset changes 1 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 1 violations, 25 errors and 8 configuration errors.

Regression Tester Report

(comment created at 2025-06-20 12:08:46+00:00 for f274956)

@oowekyala oowekyala self-requested a review June 10, 2025 11:06
Copy link
Member

@adangel adangel left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

For the test cases, I think, we shouldn't allow more than java/javadoc itself allows. Means - if javadoc can't resolve a reference because of a missing import, we shouldn't try to resolve it either.

@lukasgraef
Copy link
Contributor Author

lukasgraef commented Jun 20, 2025

Hi @adangel,
thanks for the feedback. I've adjusted the rule and testcases to only allow the cases that are allowed by javadoc itself.

@adangel adangel added this to the 7.15.0 milestone Jun 20, 2025
Copy link
Member

@adangel adangel left a comment

Choose a reason for hiding this comment

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

Thanks!

@adangel adangel merged commit f274956 into pmd:main Jun 22, 2025
12 checks passed
adangel added a commit that referenced this pull request Jun 22, 2025
adangel added a commit that referenced this pull request Jun 22, 2025
…oc (#5818)

Merge pull request #5818 from lukasgraef:issue2304
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] UnnecessaryImport false positive for on-demand imports in JavaDoc

2 participants