SeverityMatchFilter
Since Checkstyle 3.2
On This Page
- Description
- Properties
-
- For example, the following configuration fragment directs the Checker to not report audit events with severity level
info: Default configuration (only accepts severity 'error') - For example, the following configuration fragment directs the Checker to not report audit events with severity level
info - The following configuration fragment directs the Checker to not report audit events whose severity matches the default
errorlevel
- For example, the following configuration fragment directs the Checker to not report audit events with severity level
- Example of Usage
- Fully Qualified Name
- Parent Module
Description
Notes
SeverityMatchFilter can suppress Checks that have Treewalker or Checker as parent module.
In Checkstyle, when a filter accepts a violation (i.e. accept() returns true), the violation is kept in the final report; to make a violation disappear from the report, the filter must reject it by returning false. For SeverityMatchFilter, set severity to the level you want to control and acceptOnMatch to true to keep matching violations in the final report, or to false to remove them from it.
Properties
| name | description | type | default value | since |
|---|---|---|---|---|
| acceptOnMatch | Control whether 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 |
3.2 |
| severity | Specify the severity level of this filter. | SeverityLevel | error |
3.2 |
Examples
For example, the following configuration fragment directs the Checker to not report audit events with severity level info: Default configuration (only accepts severity 'error')
<module name="Checker">
<module name="TreeWalker">
<module name="ParameterName">
<property name="severity" value="info"/>
</module>
<module name="MethodName"/>
<module
name="com.puppycrawl.tools.checkstyle.checks.design.VisibilityModifierCheck">
<property name="severity" value="warning"/>
</module>
</module>
<module name="SeverityMatchFilter"/>
</module>
Example code:
public class Example1 {
// filtered violation below 'must be private'
int field1;
// filtered violation below 'must match pattern'
public void method1(int V1){}
// violation below 'must match pattern'
public void Method2(){}
}
For example, the following configuration fragment directs the Checker to not report audit events with severity level info:
<module name="Checker">
<module name="TreeWalker">
<module name="ParameterName">
<property name="severity" value="info"/>
</module>
<module name="MethodName"/>
<module
name="com.puppycrawl.tools.checkstyle.checks.design.VisibilityModifierCheck">
<property name="severity" value="warning"/>
</module>
</module>
<module name="SeverityMatchFilter">
<property name="severity" value="info"/>
</module>
</module>
Example code:
public class Example2 {
// filtered violation below 'must be private'
int field1;
// violation below 'must match pattern'
public void method1(int V1){}
// filtered violation below 'must match pattern'
public void Method2(){}
}
The following configuration fragment directs the Checker to not report audit events whose severity matches the default error level:
<module name="Checker">
<module name="TreeWalker">
<module name="ParameterName">
<property name="severity" value="info"/>
</module>
<module name="MethodName"/>
<module
name="com.puppycrawl.tools.checkstyle.checks.design.VisibilityModifierCheck">
<property name="severity" value="warning"/>
</module>
</module>
<module name="SeverityMatchFilter">
<property name="severity" value="warning"/>
<property name="acceptOnMatch" value="false"/>
</module>
</module>
Example code:
public class Example3 {
// filtered violation below 'must be private'
int field1;
// violation below 'must match pattern'
public void method1(int V1){}
// violation below 'must match pattern'
public void Method2(){}
}
Example of Usage
Fully Qualified Name
com.puppycrawl.tools.checkstyle.filters.SeverityMatchFilter
This is the fully qualified class name of the module. Use this name in configuration when an exact class reference is required. This is the fully qualified class name of the module. Use this name in configuration when an exact class reference is required.






