GeezerVison is showing github.com — False positive: JavadocParagraph reports violation when `<p>` is after tags · Issue #18486 · checkstyle/checkstyle
False positive: JavadocParagraph reports violation when <p> is after tags #18486DescriptionI have read check documentation: https://checkstyle.org/checks/javadoc/javadocparagraph.html
I have downloaded the latest checkstyle from: https://checkstyle.org/cmdline.html#Download_and_Run
I have executed the cli and showed it below, as cli describes the problem better than 1,000 words
E:\temp\CheckstyleReport>type config.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="TreeWalker">
<module name="JavadocParagraph" />
</module>
</module>
E:\temp\CheckstyleReport>type Test.java
public interface Test {
/**
* Test method.
*
* @return some result
*
* <p>For example this is a nice "string", the previous line is empty so Checkstyle shouldn't complain</p>
*/
String someMethod();
}
E:\temp\CheckstyleReport>set RUN_LOCALE="-Duser.language=en -Duser.country=US"
E:\temp\CheckstyleReport>java %RUN_LOCALE% -jar checkstyle-12.3.1-all.jar -c config.xml Test.java
Starting audit...
[ERROR] E:\temp\CheckstyleReport\Test.java:8:12: <p> tag should be preceded with an empty line. [JavadocParagraph]
Audit done.
Checkstyle ends with 1 errors.
Describe what you expect in detail.
Since there is an empty line before the tag <p> there should not be complaint about missing empty line.
It affects at least <p> tags inside the @return Javadoc block
Activitylrozenblyum commented on Jan 5, 2026 NOTE: the problem is reproduced also in other contexts, not just after the @return tag (e.g. after the @implNote tag changed the title [-]False positive: JavadocParagraph reports violation when `<p>` is after the @return tag[/-] [+]False positive: JavadocParagraph reports violation when `<p>` is after tags[/+] on Jan 5, 2026romani commented on Jan 25, 2026 $ javadoc Test.java
Loading source file Test.java...
Constructing Javadoc information...
Building index for all the packages and classes...
Standard Doclet version 21.0.9+7-LTS-338
Building tree for all the packages and classes...
Generating ./Test.html...
Test.java:1: warning: no comment
public interface Test {
^
Generating ./package-summary.html...
Generating ./package-tree.html...
Generating ./overview-tree.html...
Building index for all classes...
Generating ./allclasses-index.html...
Generating ./allpackages-index.html...
Generating ./index-all.html...
Generating ./search.html...
Generating ./index.html...
Generating ./help-doc.html...
1 warning
~/tmp$ cat Test.java
public interface Test {
/**
* Test method.
*
* @return some result
*
* <p>For example this is a nice "string", the previous line is empty so Checkstyle shouldn't complain</p>
*/
String someMethod();
}
 romani commented on Jan 25, 2026 we should investigate what Google style opinion on such case, we should use auto formatter to see what it is doing on such cases. navin-oss commented on Jan 26, 2026 romani commented on Jan 27, 2026 @navin-oss, please share output of Google formatter on such snippet of java navin-oss commented on Jan 27, 2026
Hi @romani,
I ran Google Java Format on the same snippet.
Command used:
google-java-format Test.java
Formatted output:
public interface Test {
/**
* Test method.
*
* @return some result
*
* <p>For example this is a nice "string", the previous line is empty so
* Checkstyle shouldn't complain</p>
*/
String someMethod();
}
Google Java Formatter keeps the empty line before the <p> tag and does not move or collapse it.
romani commented on Jan 28, 2026 Ok this is 100% checkstyle defect navin-oss commented on Jan 28, 2026 Thanks for the confirmation 👍
I’ve verified that this is indeed a Checkstyle defect by comparing against Google Java Format output.
I won’t be able to continue with the fix right now, but I wanted to share the formatter results so the issue is well-documented for whoever picks it up next.
Thanks for the quick feedback!..... Aman-Baliyan commented on Jan 28, 2026 Input File ->
package temp;
public interface Test {
/**
* Test method.
*
* @return some result
*
* <p>For example this is a nice "string", the previous line is empty so Checkstyle shouldn't complain</p>
*/
String someMethod();
}
command used ->
java -jar google-java-format-1.33.0-all-deps.jar Test.java
output ->
package temp;
public interface Test {
/**
* Test method.
*
* @return some result
* <p>For example this is a nice "string", the previous line is empty so Checkstyle shouldn't
* complain
*/
String someMethod();
}
Two key Rules for this ->
7.1.2 Paragraphs
One blank line—that is, a line containing only the aligned leading asterisk (*)—appears between paragraphs, and before the group of block tags if present. Each paragraph except the first has <p> immediately before the first word, with no space after it. HTML tags for other block-level elements, such as <ul> or <table>, are not preceded with <p>.
7.1.3 Block tags
Any of the standard "block tags" that are used appear in the order @param, @return, @throws, @deprecated, and these four types never appear with an empty description. When a block tag doesn't fit on a single line, continuation lines are indented four (or more) spaces from the position of the @.
In think according to these rules there should be no description present after Block tags and if present then it should be considered as a part of descirption of block tag that's why the p block in the input is merged in the return tag description with 4 indentation.
the description should always present before Block tags. romani commented on Jan 29, 2026 P html-tag inside javadoc-block-tag could be skipped from validation if there any problem to validate them in javadoc-block-tags.
I pretty sure that 7.1.2 Paragraphs is for general content of javadoc to ease reading from sources. We can looks at guava or any other google code if they ever do P tag in jvadoc-block-tags and what they do for formating. Aman-Baliyan commented on Jan 29, 2026 i checked guava code but i did not find any example in which p tag is used inside block tag although it can be used inside block tags so i try examples by myself and format them by java-google-format the results are -
example -
input -
package temp;
public interface Test {
/**
* Test method.
*
* @return some result
*
* <p>For example this is a nice "string", the previous line is empty so Checkstyle shouldn't complain</p>
*
* <p>This is some comment</p>
*/
String someMethod();
}
command used ->
java -jar google-java-format-1.33.0-all-deps.jar Test.java
output ->
package temp;
public interface Test {
/**
* Test method.
*
* @return some result
* <p>For example this is a nice "string", the previous line is empty so Checkstyle shouldn't
* complain
* <p>This is some comment
*/
String someMethod();
}
Aman-Baliyan commented on Jan 29, 2026 so we have to extend the check so that it checks for p blocks inside the block tags and give violations according to google format like in this example there is no space between p blocks inside block tags when formatted navin-oss commented on Jan 29, 2026 @Aman-Baliyan thanks for the detailed investigation with Google Java Format.
Just to clarify the findings:
When Google Java Format processes @return followed by <p> tags, it behaves in one of two ways:
- It keeps the empty line before
<p> (as seen in the earlier test), or
- It merges the
<p> content into the @return description, indenting it by 4 spaces (as seen in the later test).
In both cases, Checkstyle’s current behavior of requiring an empty line before <p> is incorrect because:
- The empty line already exists (a line containing only
*), or
- The
<p> tag is semantically part of the block tag content, where different formatting rules apply.
So I agree with @romani that we should either:
- Skip paragraph validation for
<p> tags inside Javadoc block tags, or
- Adjust the empty-line detection logic to properly handle javadoc-block-tag contexts.
This would align Checkstyle’s behavior more closely with Google Java Format and the Google Javadoc style. romani commented on Jan 30, 2026 yes, lets align,
Should be no violation around "P" tag that is under javadoc block tags. Aman-Baliyan commented on Jan 31, 2026 romani commented on Feb 3, 2026
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|