Repository navigation
[java] New Rule: DanglingJavadoc - #5916
Conversation
3fe32c0 to
96821c2
Compare
|
Compared to main: (comment created at 2025-07-18 22:14:18+00:00 for 9d61ef4) |
adangel
left a comment
There was a problem hiding this comment.
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.
|
Compared to main: (comment created at 2025-09-11 08:26:46+00:00 for 683c820) |
…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]>
…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]>
…) 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]>
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?
./mvnw clean verifypasses (checked automatically by github actions)Questions
///be always treated like Javadoc, even if given project is not using Java 23?