JavadocRegexp
Since Checkstyle 13.10.0
Description
The check can operate on raw Javadoc source or on the text visible to readers. Raw matching includes Javadoc tags, HTML tags, HTML attributes, and formatting characters. Visible-text matching ignores markup and matches only Javadoc text content.
Properties
| name | description | type | default value | since |
|---|---|---|---|---|
| format | Specify the regular expression to match forbidden Javadoc content. | Pattern | ^$ |
13.10.0 |
| ignoreCase | Control whether to ignore case when matching. | boolean | false |
13.10.0 |
| ignoreMarkup | Control whether to ignore Javadoc and HTML markup when matching. | boolean | false |
13.10.0 |
| 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 with default settings that do not perform any validation:
<module name="Checker">
<module name="TreeWalker">
<module name="JavadocRegexp"/>
</module>
</module>
Example:
class Example1 {
// ok, default settings do not perform any validation
/**
* <p>See <a href="https://example.com/aka">documentation</a>.</p>
*/
void first() {}
// ok, default settings do not perform any validation
/**
* Creates a user, AKA an account owner.
*/
void second() {}
// ok, default settings do not perform any validation
/**
* Creates a user, aka an account owner.
*/
void third() {}
}
To configure the check to find closing </p> tags in raw Javadoc source:
<module name="Checker">
<module name="TreeWalker">
<module name="JavadocRegexp">
<property name="format" value="</p>"/>
<property name="ignoreCase" value="false"/>
<property name="ignoreMarkup" value="false"/>
</module>
</module>
</module>
Example:
class Example2 {
// violation below 'Javadoc content matches the illegal pattern'
/**
* <p>See <a href="https://example.com/aka">documentation</a>.</p>
*/
void first() {}
// ok, raw source has no closing paragraph tag
/**
* Creates a user, AKA an account owner.
*/
void second() {}
// ok, raw source has no closing paragraph tag
/**
* Creates a user, aka an account owner.
*/
void third() {}
}
To configure the check to find uppercase abbreviation 'AKA' in text visible in generated Javadoc HTML pages:
<module name="Checker">
<module name="TreeWalker">
<module name="JavadocRegexp">
<property name="format" value="(^|\W)(AKA)(\W|$)"/>
<property name="ignoreCase" value="false"/>
<property name="ignoreMarkup" value="true"/>
</module>
</module>
</module>
Example:
class Example3 {
// ok, rendered text has no AKA
/**
* <p>See <a href="https://example.com/aka">documentation</a>.</p>
*/
void first() {}
// violation below 'Javadoc content matches the illegal pattern'
/**
* Creates a user, AKA an account owner.
*/
void second() {}
// ok, rendered text has no AKA
/**
* Creates a user, aka an account owner.
*/
void third() {}
}
To configure the check to find abbreviation 'aka' in text visible in generated Javadoc HTML pages regardless of case:
<module name="Checker">
<module name="TreeWalker">
<module name="JavadocRegexp">
<property name="format" value="aka"/>
<property name="ignoreCase" value="true"/>
<property name="ignoreMarkup" value="true"/>
</module>
</module>
</module>
Example:
class Example4 {
// ok, rendered text has no aka
/**
* <p>See <a href="https://example.com/aka">documentation</a>.</p>
*/
void first() {}
// violation below 'Javadoc content matches the illegal pattern'
/**
* Creates a user, AKA an account owner.
*/
void second() {}
// violation below 'Javadoc content matches the illegal pattern'
/**
* Creates a user, aka an account owner.
*/
void third() {}
}
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.JavadocRegexpCheck
Use this fully qualified class name in configuration when an exact class reference is required.






