From 3ebddae1b928b69793717d4e207b660b31fefdb5 Mon Sep 17 00:00:00 2001
From: Andrei Selkin
+ You can find information about property types on + Property Types page. +
+
- Filter SeverityMatchFilter decides
- audit events according to the severity
- level of the event.
-
| name | -description | -type | -default value | -
|---|---|---|---|
| severity | -the severity level of this filter | -severity | -error |
-
| acceptOnMatch | -
- If acceptOnMatch is true, then
- the filter accepts an audit event if and only if there is
- a match between the event's severity level and property
- severity. If acceptOnMatch
- is false, then the filter
- accepts an audit event if and only if there is not a match
- between the event's severity level and property severity.
- |
- boolean | -true |
-
- For example, the following configuration fragment directs the
- Checker to not report audit events with severity
- level info:
-
- Filter SuppressionFilter rejects
- audit events for Check errors according to
- a suppressions XML
- document in a file. If there is no configured
- suppressions file, the Filter accepts all audit events.
-
| name | -description | -type | -default value | -
|---|---|---|---|
| file | -
- the location of the suppressions XML document file.
- The order the location is checked is:
-
|
- string | -none |
-
- For example, the following configuration fragment directs the
- Checker to use a SuppressionFilter
- with suppressions
- file docs/suppressions.xml:
-
- A suppressions XML
- document contains a set
- of suppress elements, where
- each suppress element can have the
- following attributes:
-
files -
- a regular expression
- matched against the file name associated with an audit
- event. It is mandatory.
- checks -
- a regular expression
- matched against the name of the check associated with an audit
- event. Optional if id is specified.
- id -
- a string
- matched against the ID of the check associated with an audit
- event. Optional if checks is specified.
- lines - a comma-separated list of
- values, where each value is
- an integer or a
- range of integers denoted by integer-integer. It is optional.
- columns - a comma-separated list of
- values, where each value is
- an integer or a
- range of integers denoted by integer-integer. It is optional.
-
- Each audit event is checked against
- each suppress element. It is
- suppressed if all specified attributes match against the audit
- event.
-
You can download template of empty suppression filter here.
- -
- The following suppressions XML document directs
- a SuppressionFilter to
- reject JavadocStyleCheck errors for
- lines 82 and 108 to 122 of
- file AbstractComplexityCheck.java,
- and MagicNumberCheck errors for line
- 221 of file JavadocStyleCheck.java:
-
- As another example to suppress Check by module id: -
- -
- Then the following can be used to suppress only the first
- check and not the second by using
- the id attribute:
-
- Suppress checks for hidden files and folders: -
- -- Suppress checks for Maven-generated code: -
- -- Suppress checks for archives, classes and other binary files: -
- -- Suppress checks for image files: -
- -- Suppress checks for non-java files: -
- -- Suppress all checks in generated sources: -
- -- Suppress FileLength check on integration tests in certain folder: -
- -
- Filter SuppressionCommentFilter uses
- pairs of comments to suppress audit events.
-
- Rationale: Sometimes there are legitimate reasons for violating - a check. When this is a matter of the code in question and not - personal preference, the best place to override the policy is in - the code itself. Semi-structured comments can be associated - with the check. This is sometimes superior to a separate - suppressions file, which must be kept up-to-date as the source - file is edited. -
- -
- Usage: This filter only works in conjunction with a FileContentsHolder, since that check makes
- the suppression comments in the Java files available. A configuration that includes this filter must
- configure FileContentsHolder as a
- child module of TreeWalker.
-
| name | -description | -type | -default value | -
|---|---|---|---|
| offCommentFormat | -comment pattern to trigger filter to begin suppression | -regular expression | -CHECKSTYLE\:OFF |
-
| onCommentFormat | -comment pattern to trigger filter to end suppression | -regular expression | -CHECKSTYLE\:ON |
-
| checkFormat | -check pattern to suppress | -regular expression | -.* (all checks) |
-
| messageFormat | -message pattern to suppress | -regular expression | -none | -
| checkCPP | -whether to check C++ style comments (//) |
- boolean | -true |
-
| checkC | -whether to check C style comments (/* ... */) |
- boolean | -true |
-
- offCommentFormat and onCommentFormat must have equal paren counts. -
- -- Make sure that comments are available to the filter by enabling FileContentsHolder: -
- -
- To configure a filter to suppress audit events between a comment
- containing CHECKSTYLE:OFF and a comment containing
- CHECKSTYLE:ON:
-
- To configure a filter to suppress audit events between a comment
- containing line BEGIN GENERATED CODE and a comment
- containing line END GENERATED CODE:
-
- To configure a filter so that // stop constant
- check and // resume constant check marks
- legitimate constant names:
-
- To configure a filter so that UNUSED OFF:
- var and UNUSED ON: var marks a
- variable or parameter known not to be used by the code by
- matching the variable name in the message:
-
- To configure a filter so that name of suppressed check mentioned
- in comment CSOFF: regexp
- and CSN: regexp mark a matching check:
-
- To configure a filter to suppress all audit events between a comment
- containing CHECKSTYLE_OFF: ALMOST_ALL and a comment containing
- CHECKSTYLE_OFF: ALMOST_ALL except for the EqualsHashCode check:
-
- To configure a filter to suppress Check's violation message which matches
- specified message in messageFormat (so suppression will be not only by
- Check's name, but by message text additionally, as the same Check could report
- different by message format violations) between a comment
- containing stop and comment containing resume:
-
- Code before filter above is applied with Check's audit events: -
- -- Code after filter is applied: -
- -
- Filter SuppressWithNearbyCommentFilter uses
- individual comments to suppress audit events.
-
- Rationale: Same as SuppressionCommentFilter.
- Whereas the SuppressionCommentFilter uses matched pairs of
- filters to turn on/off comment matching,
- SuppressWithNearbyCommentFilter uses
- single comments. This requires fewer lines to mark a region, and
- may be aesthetically preferable in some contexts.
-
- Usage: This filter only works in conjunction with a FileContentsHolder, since that check makes
- the suppression comments in the Java files available. A configuration that includes this filter must
- configure FileContentsHolder as a
- child module of TreeWalker.
-
| name | -description | -type | -default value | -
|---|---|---|---|
| commentFormat | -comment pattern to trigger filter to begin suppression | -regular expression | -SUPPRESS CHECKSTYLE (\w+) |
-
| checkFormat | -check pattern to suppress | -regular expression | -.* |
-
| messageFormat | -message pattern to suppress | -regular expression | -none | -
| influenceFormat | -a negative/zero/positive value that defines the number of - lines preceding/at/following the suppression comment | -regular expression | -0 (the line containing the comment) |
-
| checkCPP | -whether to check C++ style comments (//) |
- boolean | -true |
-
| checkC | -whether to check C style comments (/* ... */) |
- boolean | -true |
-
- To configure the check that makes comments available to the filter: -
- -
- To configure a filter to suppress audit events for check
- on any line with a comment SUPPRESS CHECKSTYLE check:
-
- To configure a filter to suppress all audit events on any line
- containing the comment CHECKSTYLE IGNORE THIS LINE:
-
- To configure a filter so that
- // OK to catch (Throwable|Exception|RuntimeException) here
- permits the current and previous line to avoid generating an IllegalCatch
- audit event:
-
- To configure a filter so that CHECKSTYLE IGNORE check FOR NEXT var LINES
- avoids triggering any audits for the given check for the current line and the next var lines
- (for a total of var+1 lines):
-
- To configure a filter to avoid any audits on code like: -
- -- To configure a filter to allow suppress one or more Checks(separated by "|") - and demand comment no less than 14 symbols: -
- -
- Filter SuppressWarningsFilter uses annotations to
- suppress audit events.
-
- Rationale: Same as for
- SuppressionCommentFilter. In the contrary to it
- here, comments are not used comments but the builtin syntax of
- @SuppressWarnings. This can be perceived as a
- more elegant solution than using comments. Also this approach
- maybe supported by various IDE.
-
- Usage: This filter only works in conjunction with a
- SuppressWarningsHolder, since that check finds
- the annotations in the Java files and makes them available for
- the filter. Because of that, a configuration that includes
- this filter must also include
- SuppressWarningsHolder as a child module of the
- TreeWalker. Name of check in annotation should
- be written in lower case with any dotted prefix or "Check" suffix removed.
-
This filter does not expose any properties
- -- To configure the check that makes tha annotations available to - the filter. -
-To configure filter to suppress audit events for annotations add:
-
diff --git a/src/xdocs/config_filters.xml b/src/xdocs/config_filters.xml
new file mode 100644
index 000000000..fab53b7d4
--- /dev/null
+++ b/src/xdocs/config_filters.xml
@@ -0,0 +1,756 @@
+
+
+
+ Filter
+ For example, the following configuration fragment directs the
+ Checker to not report audit events with severity
+ level com.puppycrawl.tools.checkstyle.checks.filters
+ Filter
+ For example, the following configuration fragment directs the
+ Checker to use a
+ A suppressions XML
+ document contains a set
+ of
+ Each audit event is checked against
+ each
+ You can download template of empty suppression filter
+ here.
+
+ The following suppressions XML document directs
+ a
+ As another example to suppress Check by module id:
+
+ Then the following can be used to suppress only the first
+ check and not the second by using
+ the
+ Suppress checks for hidden files and folders:
+
+ Suppress checks for Maven-generated code:
+
+ Suppress checks for archives, classes and other binary files:
+
+ Suppress checks for image files:
+
+ Suppress checks for non-java files:
+
+ Suppress all checks in generated sources:
+
+ Suppress FileLength check on integration tests in certain folder:
+ com.puppycrawl.tools.checkstyle.checks.filters
+ Filter
+ Rationale: Sometimes there are legitimate reasons for violating
+ a check. When this is a matter of the code in question and not
+ personal preference, the best place to override the policy is in
+ the code itself. Semi-structured comments can be associated
+ with the check. This is sometimes superior to a separate
+ suppressions file, which must be kept up-to-date as the source
+ file is edited.
+
+ Usage: This filter only works in conjunction with a
+ offCommentFormat and onCommentFormat must have equal paren counts.
+
+ Make sure that comments are available to the filter by enabling FileContentsHolder:
+
+ To configure a filter to suppress audit events between a comment
+ containing
+ To configure a filter to suppress audit events between a comment
+ containing line
+ To configure a filter so that
+ To configure a filter so that
+ To configure a filter so that name of suppressed check mentioned
+ in comment
+ To configure a filter to suppress all audit events between a comment
+ containing
+ To configure a filter to suppress Check's violation message which matches
+ specified message in messageFormat (so suppression will be not only by
+ Check's name, but by message text additionally, as the same Check could report
+ different by message format violations) between a comment
+ containing
+ Code before filter above is applied with Check's audit events:
+
+ Code after filter is applied:
+ com.puppycrawl.tools.checkstyle.checks.filters
+ Filter
+ Rationale: Same as
+ Usage: This filter only works in conjunction with a
+ To configure the check that makes comments available to the filter:
+
+ To configure a filter to suppress audit events for check
+ on any line with a comment
+ To configure a filter to suppress all audit events on any line
+ containing the comment
+ To configure a filter so that
+
+ To configure a filter so that
+ To configure a filter to avoid any audits on code like:
+
+ To configure a filter to allow suppress one or more Checks(separated by "|")
+ and demand comment no less than 14 symbols:
+ com.puppycrawl.tools.checkstyle.checks.filters
+ Filter
+ Rationale: Same as for
+
+ Usage: This filter only works in conjunction with a
+ SuppressWarningsHolder, since that check finds
+ the annotations in the Java files and makes them available for
+ the filter. Because of that, a configuration that includes
+ this filter must also include
+ This filter does not expose any properties
+ To configure the check that makes tha annotations available to
+ the filter.
+ To configure filter to suppress audit events for annotations add: com.puppycrawl.tools.checkstyle.checks.filters SeverityMatchFilter decides
+ audit events according to the severity
+ level of the event.
+
+
+
+
+ name
+ description
+ type
+ default value
+
+
+ severity
+ the severity level of this filter
+ severity
+
+ error
+
+ acceptOnMatch
+
+ If acceptOnMatch is
+ true, then
+ the filter accepts an audit event if and only if there is
+ a match between the event's severity level and property
+ severity. If acceptOnMatch
+ is false, then the filter
+ accepts an audit event if and only if there is not a match
+ between the event's severity level and property severity.
+ boolean
+
+ trueinfo:
+ SuppressionFilter rejects
+ audit events for Check errors according to
+ a suppressions XML
+ document in a file. If there is no configured
+ suppressions file, the Filter accepts all audit events.
+
+
+
+
+ name
+ description
+ type
+ default value
+
+
+ file
+
+ the location of the suppressions XML document file.
+ The order the location is checked is:
+
+
+
+ http:// or https://, then it
+ is interpreted as a URL
+ ClassLoader.getResource() method.
+ string
+
+ noneSuppressionFilter
+ with suppressions
+ file docs/suppressions.xml:
+ suppress elements, where
+ each suppress element can have the
+ following attributes:
+
+
+ files -
+ a regular expression
+ matched against the file name associated with an audit
+ event. It is mandatory.
+ checks -
+ a regular expression
+ matched against the name of the check associated with an audit
+ event. Optional if id is specified.
+ id -
+ a string
+ matched against the ID of the check associated with an audit
+ event. Optional if checks is specified.
+ lines - a comma-separated list of
+ values, where each value is
+ an integer or a
+ range of integers denoted by integer-integer. It is optional.
+ columns - a comma-separated list of
+ values, where each value is
+ an integer or a
+ range of integers denoted by integer-integer. It is optional.
+ suppress element. It is
+ suppressed if all specified attributes match against the audit
+ event.
+ SuppressionFilter to
+ reject JavadocStyleCheck errors for
+ lines 82 and 108 to 122 of
+ file AbstractComplexityCheck.java,
+ and MagicNumberCheck errors for line
+ 221 of file JavadocStyleCheck.java:
+ id attribute:
+ SuppressionCommentFilter uses
+ pairs of comments to suppress audit events.
+ FileContentsHolder, since that check makes
+ the suppression comments in the Java files available. A configuration that includes this filter must
+ configure FileContentsHolder as a
+ child module of TreeWalker.
+
+
+
+
+ name
+ description
+ type
+ default value
+
+
+ offCommentFormat
+ comment pattern to trigger filter to begin suppression
+ regular expression
+
+ CHECKSTYLE\:OFF
+
+ onCommentFormat
+ comment pattern to trigger filter to end suppression
+ regular expression
+
+ CHECKSTYLE\:ON
+
+ checkFormat
+ check pattern to suppress
+ regular expression
+
+ .* (all checks)
+
+ messageFormat
+ message pattern to suppress
+ regular expression
+ none
+
+
+ checkCPP
+ whether to check C++ style comments (
+ //)boolean
+
+ true
+
+ checkC
+ whether to check C style comments (
+ /* ... */)boolean
+
+ trueCHECKSTYLE:OFF and a comment containing
+ CHECKSTYLE:ON:
+ BEGIN GENERATED CODE and a comment
+ containing line END GENERATED CODE:
+ // stop constant
+ check and // resume constant check marks
+ legitimate constant names:
+ UNUSED OFF:
+ var and UNUSED ON: var marks a
+ variable or parameter known not to be used by the code by
+ matching the variable name in the message:
+ CSOFF: regexp
+ and CSN: regexp mark a matching check:
+ CHECKSTYLE_OFF: ALMOST_ALL and a comment containing
+ CHECKSTYLE_OFF: ALMOST_ALL except for the EqualsHashCode check:
+ stop and comment containing resume:
+ SuppressWithNearbyCommentFilter uses
+ individual comments to suppress audit events.
+ SuppressionCommentFilter.
+ Whereas the SuppressionCommentFilter uses matched pairs of
+ filters to turn on/off comment matching,
+ SuppressWithNearbyCommentFilter uses
+ single comments. This requires fewer lines to mark a region, and
+ may be aesthetically preferable in some contexts.
+ FileContentsHolder, since that check makes
+ the suppression comments in the Java files available. A configuration that includes this filter must
+ configure FileContentsHolder as a
+ child module of TreeWalker.
+
+
+
+
+ name
+ description
+ type
+ default value
+
+
+ commentFormat
+ comment pattern to trigger filter to begin suppression
+ regular expression
+
+ SUPPRESS CHECKSTYLE (\w+)
+
+ checkFormat
+ check pattern to suppress
+ regular expression
+
+ .*
+
+ messageFormat
+ message pattern to suppress
+ regular expression
+ none
+
+
+ influenceFormat
+ a negative/zero/positive value that defines the number of
+ lines preceding/at/following the suppression comment
+ regular expression
+
+ 0 (the line containing the comment)
+
+ checkCPP
+ whether to check C++ style comments (
+ //)boolean
+
+ true
+
+ checkC
+ whether to check C style comments (
+ /* ... */)boolean
+
+ trueSUPPRESS CHECKSTYLE check:
+ CHECKSTYLE IGNORE THIS LINE:
+ // OK to catch (Throwable|Exception|RuntimeException) here
+ permits the current and previous line to avoid generating an IllegalCatch
+ audit event:
+ CHECKSTYLE IGNORE check FOR NEXT var LINES
+ avoids triggering any audits for the given check for the current line and the next var lines
+ (for a total of var+1 lines):
+ SuppressWarningsFilter uses annotations to
+ suppress audit events.
+ SuppressionCommentFilter. In the contrary to it
+ here, comments are not used comments but the builtin syntax of
+ @SuppressWarnings. This can be perceived as a
+ more elegant solution than using comments. Also this approach
+ maybe supported by various IDE.
+ SuppressWarningsHolder as a child module of the
+ TreeWalker. Name of check in annotation should
+ be written in lower case with any dotted prefix or "Check" suffix removed.
+
Checkstyle is configured using properties, which are string representations. This document describes how these string representations are mapped to typed properties.
+
This property represents an integer. The string representation is
parsed using the java.lang.Integer class.
This property represents a string. The literal string representation is used.
-
This property represents a boolean. The default value is false. The following string representations will
map to true:
@@ -55,9 +56,9 @@
Anything else will map to false.
This property represents a set of strings. The string representation is parsed as a set of comma (',') separated strings. @@ -75,9 +76,9 @@ <property name="tokens" value="DIV_ASSIGN"/> <property name="tokens" value="PLUS_ASSIGN"/> -
This property represents a set of integers. The string representation is parsed as a set of comma (',') separated integers that are parsed @@ -96,18 +97,18 @@ <property name="tokens" value="42"/> <property name="tokens" value="666"/> -
This property represents a regular expression. The string representation is parsed using java.util.regex package.
-This property represents the policy for padding with white space. The following table describes the valid options: @@ -132,9 +133,9 @@ -
This property represents the policy for wrapping lines. The following table describes the valid options: @@ -166,9 +167,9 @@ -
This property represents the policy for checking block statements. The following table describes the valid options: @@ -202,9 +203,9 @@ -
This property represents the policy for checking the placement of a
left curly brace ('{'). The following table
@@ -263,9 +264,9 @@
-
This property represents the policy for checking the placement of a
right curly brace ('}'). The following table
@@ -375,9 +376,9 @@
-
This property represents a Java scope. The scope is treated inclusively (as javadoc does): 'package' means all 'package', 'protected' and 'public' methods/fields/classes. The valid options are:
@@ -390,9 +391,9 @@privateanoninnerThis property represents the severity level of a check violation. The valid options are: @@ -404,9 +405,9 @@
warningerrorThis property represents the policy for checking imports order. The following table describes the valid options: @@ -479,9 +480,9 @@ -
This property represents the policy for the styles for defining elements in an annotation. The following table @@ -535,9 +536,9 @@ -
This property represents the policy for the styles for the ending parenthesis. The following table describes the valid options: @@ -572,9 +573,9 @@ -
This property represents the policy for the styles for the trailing array comma. The following table describes the valid options: @@ -609,7 +610,6 @@ -