JavadocSeeTagOrder
Since Checkstyle 14.2.0
Description
@see tags are ordered in a predictable way, roughly following the order in which their arguments are searched for by javadoc, from nearest to farthest access, from least-qualified to fully-qualified. The order of @see tags should be:
- local members first
- simple class references after local members
- simple class member references after simple class references
- qualified class references after simple class member references
- qualified class member references after qualified class references
- package references last
Inside each member group, fields come first, then constructors, then methods. Overloaded constructors and methods with the same name must be grouped together and ordered by the number of parameters, with the fewest parameters first.
For example, this is the order recommended by the OpenJDK documentation comments style guide:
@see #field
@see #Constructor(Type, Type...)
@see #Constructor(Type id, Type id...)
@see #method(Type, Type,...)
@see #method(Type id, Type, id...)
@see Class
@see Class#field
@see Class#Constructor(Type, Type...)
@see Class#Constructor(Type id, Type id)
@see Class#method(Type, Type,...)
@see Class#method(Type id, Type id,...)
@see package.Class
@see package.Class#field
@see package.Class#Constructor(Type, Type...)
@see package.Class#Constructor(Type id, Type id)
@see package.Class#method(Type, Type,...)
@see package.Class#method(Type id, Type, id)
@see package
References that are not in a recognizable structured form (for example @see "Effective Java", or an HTML anchor) are ignored for ordering purposes, so the check only reports violations when it is confident about the correct order. References using the Type##fragment syntax to link to a named fragment within a page (rather than to a member) are intentionally ignored as well, since such fragments are not javadoc type or member references and cannot be meaningfully compared to one.
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 |
14.2.0 |
Examples
To configure the check:
<module name="Checker">
<module name="TreeWalker">
<module name="JavadocSeeTagOrder"/>
</module>
</module>
Example:
class Example1 {
private String field;
Example1() {}
private void method() {}
private void method(String value) {}
// violation 9 lines below """@see tag '#method()' should be placed before
// '#method(java.lang.String)'."""
// violation 8 lines below """@see tag '#Example1()' should be placed before
// '#method()'."""
/**
* Incorrect order: local method first, then constructor, and overloaded
* methods not in telescoping order.
*
* @see #method(java.lang.String)
* @see #method()
* @see #Example1()
*/
void wrongSeeTags() {}
// ok, local member before simple class before qualified class
/**
* Correct order of {@code @see} tags.
*
* @see #field
* @see #method()
* @see OtherClass
* @see java.util.List
*/
void validSeeTags() {}
}
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.JavadocSeeTagOrderCheck
Use this fully qualified class name in configuration when an exact class reference is required.






