PreferLiteralJavadocInlineTag
Since Checkstyle 13.10.0
Description
Checks that Javadoc inline tags are preferred over HTML equivalents.
Per OpenJDK Style Guidelines v6 Javadoc inline tags should be preferred over their HTML equivalents.
Violations:
{@literal <}or{@code <}over<{@literal >}or{@code >}over>
Not flagged:
- Content inside
<pre>and<code>blocks (code examples) - Content inside
{@code},{@literal},{@snippet}inline tags
Properties
| name | description | type | default value | since |
|---|---|---|---|---|
| violateExecutionOnNonTightHtml | Control when to print violations if the Javadoc being examined by this check violates the tight html rules defined at Tight-HTML Rules. | boolean | false |
13.10.0 |
Examples
To configure the check:
<module name="Checker">
<module name="TreeWalker">
<module name="PreferLiteralJavadocInlineTag"/>
</module>
</module>
Example:
public class Example1 {
// 2 violations 4 lines below:
// 'Prefer literal or code javadoc inline tag over '<'.'
// 'Prefer literal or code javadoc inline tag over '>'.'
/**
* Type parameter is <E> here.
*/
public void badMethod() {
}
/**
* Type parameter is {@literal <E>} here.
*/
public void goodMethod() {
}
// violation 4 lines below """Prefer literal or code javadoc
// inline tag over '>'."""
/**
* <p>
* > is the greater than sign.
* </p>
*/
public void gtEntityAtStart() {
}
/**
* Content inside pre blocks is allowed:
* <pre>
* <code>sample</code>;
* <a href="#method">link</a>
* </pre>
*/
public void insidePreBlock() { }
/**
* Content inside inline tags is allowed:
* Literal: {@literal <code><T></code>}
* {@snippet :
* <T>
* }
*/
public void insideInlineTags() { }
}
Example of Usage
Violation Messages
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
Fully Qualified Name
com.puppycrawl.tools.checkstyle.checks.javadoc.PreferLiteralJavadocInlineTagCheck






