PreferLiteralJavadocInlineTag
Since Checkstyle 13.11.0
Description
Checks that Javadoc inline tags are preferred over escaping entities. According to OpenJDK Style Guidelines v6 Javadoc inline tags should be preferred over their HTML equivalents. Entities that are flagged by the check are:
- <
- >
- &
- "
- '
Reason of only these entities are flagged is given here : Predefined Entities
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.11.0 |
Examples
To configure the check:
<module name="Checker">
<module name="TreeWalker">
<module name="PreferLiteralJavadocInlineTag"/>
</module>
</module>
Example:
public class Example1 {
// 5 violations 7 lines below:
// 'Prefer literal or code javadoc inline tag over '<'.'
// 'Prefer literal or code javadoc inline tag over '>'.'
// 'Prefer literal or code javadoc inline tag over '&'.'
// 'Prefer literal or code javadoc inline tag over '"'.'
// 'Prefer literal or code javadoc inline tag over '''.'
/**
* Entities are : <, >, &, ", '.
*/
public void badMethod() {
}
/**
* Entities are : {@literal <}, {@literal >},
* {@literal &}, {@literal "}, {@literal '}.
*/
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






