Since Checkstyle 6.0
Checks the order of javadoc block-tags or javadoc tags.
Note: Google used the term "at-clauses" for block tags in their guide till 2017-02-28.
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 | 8.3 |
target | Specify the list of targets to check at-clauses. | subset of tokens TokenTypes | CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF | 6.0 |
tagOrder | Specify the order by tags. | String Set | @author, @deprecated, @exception, @param, @return, @see, @serial, @serialData, @serialField, @since, @throws, @version | 6.0 |
Default configuration
<module name="AtclauseOrder"> <property name="tagOrder" value="@author, @version, @param, @return, @throws, @exception, @see, @since, @serial, @serialField, @serialData, @deprecated"/> <property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/> </module>
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.javadoc
Since Checkstyle 8.23
Checks that Javadocs are located at the correct position. As specified at Documentation Comment Specification for the Standard Doclet, Javadocs are recognized only when placed immediately before module, package, class, interface, constructor, method, or field declarations. Any other position, like in the body of a method, will be ignored by the javadoc tool and is considered invalid by this check.
To configure the check:
<module name="InvalidJavadocPosition"/>
The following code produces a violation because Javadocs should be before all annotations of the Javadoc's target:
@SuppressWarnings("serial") /** * This comment looks like javadoc but it at an invalid location. * Therefore, the text will not get into TestClass.html and the check will produce a violation. */ public class TestClass { }
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.javadoc
Since Checkstyle 8.24
Checks that a javadoc block tag appears only at the beginning of a line, ignoring leading asterisks and white space. A block tag is a token that starts with @ symbol and is preceded by a whitespace. This check ignores block tags in comments and inside inline tags {@code } and {@literal }.
Rationale: according to the specification all javadoc block tags should be placed at the beginning of a line. Tags that are not placed at the beginning are treated as plain text. To recognize intentional tag placement to text area it is better to escape the @ symbol, and all non-escaped tags should be located at the beginning of the line. See NOTE section for details on how to escape.
To place a tag explicitly as text, escape the @ symbol with HTML entity @ or place it inside {@code }, for example:
/** * @serial literal in {@code @serial} Javadoc tag. */
name | description | type | default value | since |
---|---|---|---|---|
tags | Specify the javadoc tags to process. | String Set | author, deprecated, exception, hidden, param, provides, return, see, serial, serialData, serialField, since, throws, uses, version | 8.24 |
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 | 8.24 |
To configure the default check:
<module name="JavadocBlockTagLocation"/>
Example:
/** * Escaped tag @version (OK) * Plain text with {@code @see} (OK) * A @custom tag (OK) * * email@author (OK) * (@param in parentheses) (OK) * '@param in single quotes' (OK) * @since 1.0 (OK) * text @return (violation) * * @param (violation) +* @serial (violation) * @see first (OK) @see second (violation) */ public int field;
To configure the check to verify tags from JEP 8068562 only:
<module name="JavadocBlockTagLocation"> <property name="tags" value="apiNote, implSpec, implNote"/> </module>
To configure the check to verify all default tags and some custom tags in addition:
<module name="JavadocBlockTagLocation"> <!-- default tags --> <property name="tags" value="author, deprecated, exception, hidden"/> <property name="tags" value="param, provides, return, see, serial"/> <property name="tags" value="serialData, serialField, since, throws"/> <property name="tags" value="uses, version"/> <!-- additional tags used in the project --> <property name="tags" value="noinspection"/> </module>
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.javadoc
Since Checkstyle 8.27
Checks that the Javadoc content begins from the same position for all Javadoc comments in the project. Any leading asterisks and spaces are not counted as the beginning of the content and are therefore ignored.
It is possible to enforce two different styles:
/** Summary text. * More details. */ public void method();
/** * Summary text. * More details. */ public void method();
This check does not validate the Javadoc summary itself nor its presence. The check will not report any violations for missing or malformed javadoc summary. To validate the Javadoc summary use SummaryJavadoc check.
The Documentation Comment Specification permits leading asterisks on the first line. For these Javadoc comments:
/*** * Some text. */ /************ * Some text. */ /** ** * Some text. */
The documentation generated will be just "Some text." without any asterisks. Since these asterisks will not appear in the generated documentation, they should not be considered as the beginning of the Javadoc content. In such cases, the check assumes that the Javadoc content begins on the second line.
name | description | type | default value | since |
---|---|---|---|---|
location | Specify the policy on placement of the Javadoc content. | Javadoc Content Location | second_line | 8.27 |
By default Check validate that the Javadoc content starts from the second line:
<module name="JavadocContentLocationCheck"/>
This setting produces a violation for each multi-line comment starting on the same line as the initial asterisks:
/** This comment causes a violation because it starts from the first line * and spans several lines. */ /** * This comment is OK because it starts from the second line. */ /** This comment is OK because it is on the single line. */
To ensure that Javadoc content starts from the first line:
<module name="JavadocContentLocationCheck"> <property name="location" value="first_line"/> </module>
This setting produces a violation for each comment not starting on the same line as the initial asterisks:
/** This comment is OK because it starts on the first line. * There may be additional text. */ /** * This comment causes a violation because it starts on the second line. */ /** This single-line comment also is OK. */
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.javadoc
Since Checkstyle 3.0
Checks the Javadoc of a method or constructor. The scope to verify is specified using the Scope class and defaults to Scope.PRIVATE. To verify another scope, set property scope to a different scope.
Violates parameters and type parameters for which no param tags are present can be suppressed by defining property allowMissingParamTags. Violates methods which return non-void but for which no return tag is present can be suppressed by defining property allowMissingReturnTag. Violates exceptions which are declared to be thrown, but for which no throws tag is present by activation of property validateThrows.
Javadoc is not required on a method that is tagged with the @Override annotation. However under Java 5 it is not possible to mark a method required for an interface (this was corrected under Java 6). Hence Checkstyle supports using the convention of using a single {@inheritDoc} tag instead of all the other tags.
Note that only inheritable items will allow the {@inheritDoc} tag to be used in place of comments. Static methods at all visibilities, private non-static methods and constructors are not inheritable.
For example, if the following method is implementing a method required by an interface, then the Javadoc could be done as:
/** {@inheritDoc} */ public int checkReturnTag(final int aTagIndex, JavadocTag[] aTags, int aLineNo)
name | description | type | default value | since |
---|---|---|---|---|
allowedAnnotations | Specify the list of annotations that allow missed documentation. | String Set | Override | 6.0 |
validateThrows | Control whether to validate throws tags. | Boolean | false | 6.0 |
scope | Specify the visibility scope where Javadoc comments are checked. | Scope | private | 3.0 |
excludeScope | Specify the visibility scope where Javadoc comments are not checked. | Scope | null | 3.4 |
allowMissingParamTags | Control whether to ignore violations when a method has parameters but does not have matching param tags in the javadoc. | Boolean | false | 3.1 |
allowMissingReturnTag | Control whether to ignore violations when a method returns non-void type and does not have a return tag in the javadoc. | Boolean | false | 3.1 |
tokens | tokens to check | subset of tokens METHOD_DEF, CTOR_DEF, ANNOTATION_FIELD_DEF. | METHOD_DEF, CTOR_DEF, ANNOTATION_FIELD_DEF. | 3.0 |
To configure the default check:
<module name="JavadocMethod"/>
To configure the check for public scope, ignoring any missing param tags is:
<module name="JavadocMethod"> <property name="scope" value="public"/> <property name="allowMissingParamTags" value="true"/> </module>
To configure the check for methods which are in private, but not in protected scope:
<module name="JavadocMethod"> <property name="scope" value="private"/> <property name="excludeScope" value="protected"/> </module>
To configure the check to validate throws tags, you can use following config. ATTENTION: Checkstyle does not have information about hierarchy of exception types so usage of base class is considered as separate exception type. As workaround you need to specify both types in javadoc (parent and exact type).
<module name="JavadocMethod"> <property name="validateThrows" value="true"/> </module>
/** * Actual exception thrown is child class of class that is declared in throws. * It is limitation of checkstyle (as checkstyle does not know type hierarchy). * Javadoc is valid not declaring FileNotFoundException * BUT checkstyle can not distinguish relationship between exceptions. * @param file some file * @throws IOException if some problem */ public void doSomething8(File file) throws IOException { if (file == null) { throw new FileNotFoundException(); // violation } } /** * Exact throw type referencing in javadoc even first is parent of second type. * It is a limitation of checkstyle (as checkstyle does not know type hierarchy). * This javadoc is valid for checkstyle and for javadoc tool. * @param file some file * @throws IOException if some problem * @throws FileNotFoundException if file is not found */ public void doSomething9(File file) throws IOException { if (file == null) { throw new FileNotFoundException(); } }
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.javadoc
Since Checkstyle 5.0
Checks that each Java package has a Javadoc file used for commenting. By default it only allows a package-info.java file, but can be configured to allow a package.html file.
A violation will be reported if both files exist as this is not allowed by the Javadoc tool.
name | description | type | default value | since |
---|---|---|---|---|
allowLegacy | Allow legacy package.html file to be used. | Boolean | false | 5.0 |
fileExtensions | Specify the file type extension of files to process. | String Set | .java | 5.0 |
To configure the check:
<module name="JavadocPackage"/>
To configure the check to use legacy package.html file when package-info.java file is absent:
<module name="JavadocPackage"> <property name="allowLegacy" value="true"/> </module>
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.javadoc
Since Checkstyle 6.0
Checks the Javadoc paragraph.
Checks that:
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 | 8.3 |
allowNewlineParagraph | Control whether the <p> tag should be placed immediately before the first word. | Boolean | true | 6.9 |
To configure the default check:
<module name="JavadocParagraph"/>
By default, the check will report a violation if there is a new line or whitespace after the <p> tag:
/** * No tag (ok). * * <p>Tag immediately before the text (ok). * <p>No blank line before the tag (violation). * * <p> * New line after tag (violation). * * <p> Whitespace after tag (violation). * */ public class TestClass { }
To allow newlines and spaces immediately after the <p> tag:
<module name="JavadocParagraph"> <property name="allowNewlineParagraph" value="false"/> </module>
In case of allowNewlineParagraph set to false the following example will not have any violations:
/** * No tag (ok). * * <p>Tag immediately before the text (ok). * <p>No blank line before the tag (violation). * * <p> * New line after tag (ok). * * <p> Whitespace after tag (ok). * */ public class TestClass { }
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.javadoc
Since Checkstyle 3.2
Validates Javadoc comments to help ensure they are well formed.
The following checks are performed:
These checks were patterned after the checks made by the DocCheck doclet available from Sun. Note: Original Sun's DocCheck tool does not exist anymore.
name | description | type | default value | since |
---|---|---|---|---|
scope | Specify the visibility scope where Javadoc comments are checked. | Scope | private | 3.2 |
excludeScope | Specify the visibility scope where Javadoc comments are not checked. | Scope | null | 3.4 |
checkFirstSentence | Control whether to check the first sentence for proper end of sentence. | Boolean | true | 3.2 |
endOfSentenceFormat | Specify the format for matching the end of a sentence. | Regular Expression | "([.?!][ \t\n\r\f<])|([.?!]$)" | 5.0 |
checkEmptyJavadoc | Control whether to check if the Javadoc is missing a describing text. | Boolean | false | 3.4 |
checkHtml | Control whether to check for incomplete HTML tags. | Boolean | true | 3.2 |
tokens | tokens to check | subset of tokens ANNOTATION_DEF, ANNOTATION_FIELD_DEF, CLASS_DEF, CTOR_DEF, ENUM_CONSTANT_DEF, ENUM_DEF, INTERFACE_DEF, METHOD_DEF, PACKAGE_DEF, VARIABLE_DEF. | ANNOTATION_DEF, ANNOTATION_FIELD_DEF, CLASS_DEF, CTOR_DEF, ENUM_CONSTANT_DEF, ENUM_DEF, INTERFACE_DEF, METHOD_DEF, PACKAGE_DEF, VARIABLE_DEF. | 3.2 |
To configure the default check:
<module name="JavadocStyle"/>
To configure the check for public scope:
<module name="JavadocStyle"> <property name="scope" value="public"/> </module>
To configure the check for javadoc which is in private, but not in package scope:
<module name="JavadocStyle"> <property name="scope" value="private"/> <property name="excludeScope" value="package"/> </module>
To configure the check to turn off first sentence checking:
<module name="JavadocStyle"> <property name="checkFirstSentence" value="false"/> </module>
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.javadoc
Since Checkstyle 6.0
Checks the indentation of the continuation lines in at-clauses.
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 | 8.3 |
offset | Specify how many spaces to use for new indentation level. | Integer | 4 | 6.0 |
To configure the default check:
<module name="JavadocTagContinuationIndentation"/>
To configure the check with two spaces indentation:
<module name="JavadocTagContinuationIndentation"> <property name="offset" value="2"/> </module>
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.javadoc
Since Checkstyle 3.0
Checks the Javadoc comments for annotation/enum/class/interface definitions. By default, does not check for author or version tags. The scope to verify is specified using the Scope class and defaults to Scope.PRIVATE. To verify another scope, set property scope to one of the Scope constants. To define the format for an author tag or a version tag, set property authorFormat or versionFormat respectively to a regular expression.
Does not perform checks for author and version tags for inner classes, as they should be redundant because of outer class.
Error messages about type parameters for which no param tags are present can be suppressed by defining property allowMissingParamTags.
name | description | type | default value | since |
---|---|---|---|---|
scope | Specify the visibility scope where Javadoc comments are checked. | Scope | private | 3.0 |
excludeScope | Specify the visibility scope where Javadoc comments are not checked. | Scope | null | 3.4 |
authorFormat | Specify the pattern for @author tag. | Regular Expression | null | 3.0 |
versionFormat | Specify the pattern for @version tag. | Regular Expression | null | 3.0 |
allowMissingParamTags | Control whether to ignore violations when a class has type parameters but does not have matching param tags in the Javadoc. | Boolean | false | 4.0 |
allowUnknownTags | Control whether to ignore violations when a Javadoc tag is not recognised. | Boolean | false | 5.1 |
allowedAnnotations | Specify the list of annotations that allow missed documentation. Only short names are allowed, e.g. Generated. | String Set | Generated | 8.15 |
tokens | tokens to check | subset of tokens INTERFACE_DEF, CLASS_DEF, ENUM_DEF, ANNOTATION_DEF. | INTERFACE_DEF, CLASS_DEF, ENUM_DEF, ANNOTATION_DEF. | 3.0 |
To configure the default check:
<module name="JavadocType"/>
To configure the check for public scope:
<module name="JavadocType"> <property name="scope" value="public"/> </module>
To configure the check for an @author tag:
<module name="JavadocType"> <property name="authorFormat" value="\S"/> </module>
To configure the check for a CVS revision version tag:
<module name="JavadocType"> <property name="versionFormat" value="\$Revision.*\$"/> </module>
To configure the check for private classes only:
<module name="JavadocType"> <property name="scope" value="private"/> <property name="excludeScope" value="package"/> </module>
Example that allows missing comments for classes annotated with @SpringBootApplication and @Configuration:
@SpringBootApplication // no violations about missing comment on class public class Application {} @Configuration // no violations about missing comment on class class DatabaseConfiguration {}
Use following configuration:
<module name="JavadocType"> <property name="allowedAnnotations" value="SpringBootApplication,Configuration"/> </module>
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.javadoc
Since Checkstyle 3.0
Checks that a variable has a Javadoc comment. Ignores serialVersionUID fields.
name | description | type | default value | since |
---|---|---|---|---|
scope | Specify the visibility scope where Javadoc comments are checked. | Scope | private | 3.0 |
excludeScope | Specify the visibility scope where Javadoc comments are not checked. | Scope | null | 3.4 |
ignoreNamePattern | Specify the regexp to define variable names to ignore. | Regular Expression | null | 5.8 |
tokens | tokens to check | subset of tokens ENUM_CONSTANT_DEF. | ENUM_CONSTANT_DEF. | 3.0 |
To configure the default check:
<module name="JavadocVariable"/>
To configure the check for public scope:
<module name="JavadocVariable"> <property name="scope" value="public"/> </module>
To configure the check for members which are in private, but not in protected scope:
<module name="JavadocVariable"> <property name="scope" value="private"/> <property name="excludeScope" value="protected"/> </module>
To ignore absence of Javadoc comments for variables with names log or logger:
<module name="JavadocVariable"> <property name="ignoreNamePattern" value="log|logger"/> </module>
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.javadoc
Since Checkstyle 8.21
Checks for missing Javadoc comments for a method or constructor. The scope to verify is specified using the Scope class and defaults to Scope.PUBLIC. To verify another scope, set property scope to a different scope.
Javadoc is not required on a method that is tagged with the @Override annotation. However under Java 5 it is not possible to mark a method required for an interface (this was corrected under Java 6). Hence Checkstyle supports using the convention of using a single {@inheritDoc} tag instead of all the other tags.
For getters and setters for the property allowMissingPropertyJavadoc, the methods must match exactly the structures below.
public void setNumber(final int number) { mNumber = number; } public int getNumber() { return mNumber; } public boolean isSomething() { return false; }
name | description | type | default value | since |
---|---|---|---|---|
minLineCount | Control the minimal amount of lines in method to allow no documentation. | Integer | -1 | 8.21 |
allowedAnnotations | Configure the list of annotations that allow missed documentation. | String Set | Override | 8.21 |
scope | Specify the visibility scope where Javadoc comments are checked. | Scope | public | 8.21 |
excludeScope | Specify the visibility scope where Javadoc comments are not checked. | Scope | null | 8.21 |
allowMissingPropertyJavadoc | Control whether to allow missing Javadoc on accessor methods for properties (setters and getters). | Boolean | false | 8.21 |
ignoreMethodNamesRegex | ignore method whose names are matching specified regex. | Regular Expression | null | 8.21 |
tokens | tokens to check | subset of tokens METHOD_DEF, CTOR_DEF, ANNOTATION_FIELD_DEF. | METHOD_DEF, CTOR_DEF, ANNOTATION_FIELD_DEF. | 8.21 |
To configure the default check:
<module name="MissingJavadocMethod"/>
To configure the check for private scope:
<module name="MissingJavadocMethod"> <property name="scope" value="private"/> </module>
To configure the check for methods which are in private, but not in protected scope:
<module name="MissingJavadocMethod"> <property name="scope" value="private"/> <property name="excludeScope" value="protected"/> </module>
To configure the check for ignoring methods named foo(),foo1(),foo2(), etc.:
<module name="MissingJavadocMethod"> <property name="ignoreMethodNamesRegex" value="^foo.*$"/> </module>
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.javadoc
Since Checkstyle 8.22
Checks for missing Javadoc comments in package-info.java files.
Rationale: description and other related documentation for a package can be written up in the package-info.java file and it gets used in the production of the Javadocs. See link for more info.
To configure the check:
<module name="MissingJavadocPackage"/>
Example:
/** * Provides API classes */ package com.checkstyle.api; // no violation /* * Block comment is not a javadoc */ package com.checkstyle.api; // violation
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.javadoc
Since Checkstyle 8.20
Checks for missing Javadoc comments for class, enum, interface, and annotation interface definitions. The scope to verify is specified using the Scope class and defaults to Scope.PUBLIC. To verify another scope, set property scope to one of the Scope constants.
name | description | type | default value | since |
---|---|---|---|---|
scope | specify the visibility scope where Javadoc comments are checked. | Scope | public | 8.20 |
excludeScope | specify the visibility scope where Javadoc comments are not checked. | Scope | null | 8.20 |
skipAnnotations | specify the list of annotations that allow missed documentation. Only short names are allowed, e.g. Generated. | String Set | Generated | 8.20 |
tokens | tokens to check | subset of tokens INTERFACE_DEF, CLASS_DEF, ENUM_DEF, ANNOTATION_DEF. | INTERFACE_DEF, CLASS_DEF, ENUM_DEF, ANNOTATION_DEF. | 8.20 |
To configure the default check to make sure all public class, enum, interface, and annotation interface, definitions have javadocs:
<module name="MissingJavadocType"/>
Example:
public class PublicClass {} // violation private class PublicClass {} protected class PublicClass {} class PackagePrivateClass {}
To configure the check for private scope:
<module name="MissingJavadocType"> <property name="scope" value="private"/> </module>
Example:
public class PublicClass {} // violation private class PublicClass {} // violation protected class PublicClass {} // violation class PackagePrivateClass {} // violation
To configure the check for private classes only:
<module name="MissingJavadocType"> <property name="scope" value="private"/> <property name="excludeScope" value="package"/> </module>
Example:
public class PublicClass {} private class PublicClass {} // violation protected class PublicClass {} class PackagePrivateClass {}
Example that allows missing comments for classes annotated with @SpringBootApplication and @Configuration:
@SpringBootApplication // no violations about missing comment on class public class Application {} @Configuration // no violations about missing comment on class class DatabaseConfiguration {}
Use following configuration:
<module name="MissingJavadocType"> <property name="skipAnnotations" value="SpringBootApplication,Configuration"/> </module>
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.javadoc
Since Checkstyle 6.0
Checks that the at-clause tag is followed by description.
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 | 8.3 |
javadocTokens | javadoc tokens to check | subset of javadoc tokens PARAM_LITERAL, RETURN_LITERAL, THROWS_LITERAL, EXCEPTION_LITERAL, DEPRECATED_LITERAL. | PARAM_LITERAL, RETURN_LITERAL, THROWS_LITERAL, EXCEPTION_LITERAL, DEPRECATED_LITERAL. | 7.3 |
Default configuration that will check @param, @return, @throws, @deprecated:
<module name="NonEmptyAtclauseDescription"/>
To configure the check to validate only @param and @return tags:
<module name="NonEmptyAtclauseDescription"> <property name="javadocTokens" value="PARAM_LITERAL,RETURN_LITERAL"/> </module>
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.javadoc
Since Checkstyle 6.0
Checks that a Javadoc block can fit in a single line and doesn't contain at-clauses. Javadoc comment that contains at least one at-clause should be formatted in a few lines.
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 | 8.3 |
ignoredTags | Specify at-clauses which are ignored by the check. | String Set | {} | 6.8 |
ignoreInlineTags | Control whether inline tags must be ignored. | Boolean | true | 6.8 |
To configure the check:
<module name="SingleLineJavadoc"/>
To configure the check with a list of ignored at-clauses and make inline at-clauses not ignored:
<module name="SingleLineJavadoc"> <property name="ignoredTags" value="@inheritDoc, @see"/> <property name="ignoreInlineTags" value="false"/> </module>
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.javadoc
Since Checkstyle 6.0
Checks that Javadoc summary sentence does not contain phrases that are not recommended to use. Summaries that contain only the {@inheritDoc} tag are skipped. Check also violate Javadoc that does not contain first sentence.
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 | 8.3 |
forbiddenSummaryFragments | Specify the regexp for forbidden summary fragments. | Regular Expression | "^$" (empty) | 6.0 |
period | Specify the period symbol at the end of first javadoc sentence. | String | "." | 6.2 |
By default Check validate that first sentence is not empty and first sentence is not missing:
<module name="SummaryJavadocCheck"/>
Example of {@inheritDoc} without summary.
public class Test extends Exception { //Valid /** * {@inheritDoc} */ public String ValidFunction(){ return ""; } //Violation /** * */ public String InvalidFunction(){ return ""; } }
To ensure that summary do not contain phrase like "This method returns", use following config:
<module name="SummaryJavadocCheck"> <property name="forbiddenSummaryFragments" value="^This method returns.*"/> </module>
To specify period symbol at the end of first javadoc sentence:
<module name="SummaryJavadocCheck"> <property name="period" value="。"/> </module>
Example of period property.
public class TestClass { /** * This is invalid java doc. */ void invalidJavaDocMethod() { } /** * This is valid java doc。 */ void validJavaDocMethod() { } }
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.javadoc
Since Checkstyle 4.2
Requires user defined Javadoc tag to be present in Javadoc comment with defined format. To define the format for a tag, set property tagFormat to a regular expression. Property tagSeverity is used for severity of events when the tag exists.
name | description | type | default value | since |
---|---|---|---|---|
tag | Specify the name of tag. | String | null | 4.2 |
tagFormat | Specify the regexp to match tag content. | Regular Expression | null | 4.2 |
tagSeverity | Specify the severity level when tag is found and printed. | Severity | info | 4.2 |
tokens | tokens to check | subset of tokens INTERFACE_DEF, CLASS_DEF, ENUM_DEF, ANNOTATION_DEF, METHOD_DEF, CTOR_DEF, ENUM_CONSTANT_DEF, ANNOTATION_FIELD_DEF. | INTERFACE_DEF, CLASS_DEF, ENUM_DEF, ANNOTATION_DEF. | 4.2 |
To configure the check for printing author name:
<module name="WriteTag"> <property name="tag" value="@author"/> <property name="tagFormat" value="\S"/> </module>
To configure the check to print warnings if an "@incomplete" tag is found, and not print anything if it is not found:
<module name="WriteTag"> <property name="tag" value="@incomplete"/> <property name="tagFormat" value="\S"/> <property name="severity" value="ignore"/> <property name="tagSeverity" value="warning"/> </module>
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.javadoc