GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [java] New Rule: DanglingJavadoc by zbynek · Pull Request #5916 · pmd/pmd

Conversation

@zbynek

@zbynek zbynek commented Jul 18, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Describe the PR

Report javadoc not belonging to any class or method.

Related issues

None.

IntelliJ inspection: https://www.jetbrains.com/help/inspectopedia/DanglingJavadoc.html
CheckStyle check: https://checkstyle.sourceforge.io/checks/javadoc/invalidjavadocposition.html
Errorprone check: https://errorprone.info/bugpattern/NotJavadoc

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)

Questions

  • is this within the scope of PMD, or is it enough that it's handled by CheckStyle?
  • better name ideas?
  • should /// be always treated like Javadoc, even if given project is not using Java 23?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@zbynek
zbynek marked this pull request as draft July 18, 2025 02:26
@zbynek
zbynek force-pushed the dangling-javadoc branch 3 times, most recently from 3fe32c0 to 96821c2 Compare July 18, 2025 18:59
@github-actions

github-actions Bot commented Jul 18, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Documentation Preview

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

Regression Tester Report

(comment created at 2025-07-18 22:14:18+00:00 for 9d61ef4)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zbynek
[java] new rule: Dangling Javadoc
9d61ef4
@zbynek
zbynek force-pushed the dangling-javadoc branch from 96821c2 to 9d61ef4 Compare July 18, 2025 21:57
@zbynek
zbynek marked this pull request as ready for review August 27, 2025 21:22
@adangel adangel changed the title [java] new rule: Dangling Javadoc [java] New rule: Dangling Javadoc Sep 8, 2025
@adangel adangel added the a:new-rule Proposal to add a new built-in rule label Sep 9, 2025
adangel
adangel reviewed Sep 11, 2025
View reviewed changes

@adangel adangel left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this 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!

is this within the scope of PMD, or is it enough that it's handled by CheckStyle?

Yes, I think so. We have a couple of style related rules in category "Code Style". And the category "Documentation" for this new rule sounds correct as well.

better name ideas?

DanglingJavadoc sounds good. Let's go with that.

should /// be always treated like Javadoc, even if given project is not using Java 23?

I'd say yes. Let's keep it simple for now.


I'll fix the small things myself and merge it afterwards for 7.17.0.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/DanglingJavadocRule.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/DanglingJavadocRule.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pmd-java/src/main/resources/category/java/documentation.xml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pmd-java/src/main/resources/category/java/documentation.xml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pmd-java/src/main/resources/category/java/documentation.xml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pmd-java/src/main/resources/category/java/documentation.xml Resolved

Uh oh!

There was an error while loading. Please reload this page.

@adangel adangel added this to the 7.17.0 milestone Sep 11, 2025
adangel added 3 commits September 11, 2025 09:39
@adangel
[java] DanglingJavadoc - update from review
1ec3a41
@adangel
Merge branch 'main' into pr-5916
414d1f5
@adangel
[doc] Update release notes (pmd#5916)
683c820
@pmd-actions-helper

pmd-actions-helper Bot commented Sep 11, 2025

Copy link
Copy Markdown
Contributor

Documentation Preview

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

Regression Tester Report

(comment created at 2025-09-11 08:26:46+00:00 for 683c820)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@adangel
adangel merged commit 576e682 into pmd:main Sep 11, 2025
@adangel adangel changed the title [java] New rule: Dangling Javadoc [java] New Rule: DanglingJavadoc Sep 12, 2025
@zbynek zbynek mentioned this pull request Mar 28, 2026
[java] DanglingJavadoc: False positive on /// comments for Java < 23 #6450
Closed
@fudianchn fudianchn mentioned this pull request Aug 6, 2026
[java] Fix #6450: DanglingJavadoc should ignore markdown javadoc (///) before Java 23 #6951
Merged
fudianchn added a commit to fudianchn/pmd that referenced this pull request Aug 8, 2026
@fudianchn
[java] Fix pmd#6450: DanglingJavadoc ignores markdown javadoc (///) b…
b06b539
…efore Java 23

DanglingJavadoc reported the new markdown javadoc syntax (///) as
dangling even on Java versions that don't support it (< 23, JEP 467).
Only treat /// as a markdown javadoc comment from Java 23 onwards;
before that it is plain commentary and not dangling.

Addresses zbynek's review:
- release note and test descriptions refer to markdown javadoc as ///
  (not ////).
- scope kept at the rule layer (no parser-level change), aligning with
  the keep-simple decision in pmd#5916; a parser-level /// recognition is
  left for the maintainer to decide.

Signed-off-by: 付典 <[email protected]>
fudianchn added a commit to fudianchn/pmd that referenced this pull request Aug 15, 2026
@fudianchn
[java] Fix pmd#6450: Treat /// comments as markdown javadoc only sinc…
5927caf
…e Java 23

Markdown documentation comments (JEP 467) are available since Java 23.
ASTCompilationUnit#setComments now collapses consecutive /// comments
into JavadocComments only when the language version is >= 23, so on
older versions they stay ordinary single line comments and are no
longer reported by DanglingJavadoc. Other comment consumers see the
same consistent model.

This supersedes the "keep it simple for now" decision from pmd#5916, see
the discussion in pmd#6450 and pmd#6951.

Signed-off-by: 付典 <[email protected]>
UncleOwen added a commit that referenced this pull request Sep 10, 2026
@fudianchn @UncleOwen
[java] Fix #6450: DanglingJavadoc should ignore markdown javadoc (///…
73aa712
…) before Java 23 (#6951)

* [java] Fix #6450: Treat /// comments as markdown javadoc only since Java 23

Markdown documentation comments (JEP 467) are available since Java 23.
ASTCompilationUnit#setComments now collapses consecutive /// comments
into JavadocComments only when the language version is >= 23, so on
older versions they stay ordinary single line comments and are no
longer reported by DanglingJavadoc. Other comment consumers see the
same consistent model.

This supersedes the "keep it simple for now" decision from #5916, see
the discussion in #6450 and #6951.

Signed-off-by: 付典 <[email protected]>

* fix comment

* fix which versions to test

---------

Signed-off-by: 付典 <[email protected]>
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

Reviewers

@adangel adangel adangel left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

a:new-rule Proposal to add a new built-in rule

Projects

None yet

Milestone

7.17.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@zbynek @adangel
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.