Class SuppressionXpathSingleFilter
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
-
- com.puppycrawl.tools.checkstyle.filters.SuppressionXpathSingleFilter
-
- All Implemented Interfaces:
Configurable,Contextualizable,TreeWalkerFilter
public class SuppressionXpathSingleFilter extends AbstractAutomaticBean implements TreeWalkerFilter
Filter
SuppressionXpathSingleFiltersuppresses audit events for Checks violations in the specified file, class, checks, message, module id, and xpath.Rationale: To allow users use suppressions configured in the same config with other modules. SuppressionFilter and SuppressionXpathFilter are require separate file.
Advice: If checkstyle configuration is used for several projects, single suppressions on common files/folders is better to put in checkstyle configuration as common rule. All suppression that are for specific file names is better to keep in project specific config file.
Attention: This filter only supports single suppression, and will need multiple instances if users wants to suppress multiple violations.
SuppressionXpathSingleFilter can suppress Checks that have Treewalker as parent module.
-
Property
checks- Define a Regular Expression matched against the name of the check associated with an audit event. Type isjava.util.regex.Pattern. Default value isnull. -
Property
files- Define a Regular Expression matched against the file name associated with an audit event. Type isjava.util.regex.Pattern. Default value isnull. -
Property
id- Define a string matched against the ID of the check associated with an audit event. Type isjava.lang.String. Default value isnull. -
Property
message- Define a Regular Expression matched against the message of the check associated with an audit event. Type isjava.util.regex.Pattern. Default value isnull. -
Property
query- Define a string xpath query. Type isjava.lang.String. Default value isnull.
Parent is
com.puppycrawl.tools.checkstyle.TreeWalker- Since:
- 8.18
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
AbstractAutomaticBean.OutputStreamOptions
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.regex.PatternchecksDefine a Regular Expression matched against the name of the check associated with an audit event.private java.util.regex.PatternfilesDefine a Regular Expression matched against the file name associated with an audit event.private java.lang.StringidDefine a string matched against the ID of the check associated with an audit event.private java.util.regex.PatternmessageDefine a Regular Expression matched against the message of the check associated with an audit event.private java.lang.StringqueryDefine a string xpath query.private XpathFilterElementxpathFilterXpathFilterElement instance.
-
Constructor Summary
Constructors Constructor Description SuppressionXpathSingleFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccept(TreeWalkerAuditEvent treeWalkerAuditEvent)Determines whether or not a filteredTreeWalkerAuditEventis accepted.protected voidfinishLocalSetup()Provides a hook to finish the part of this component's setup that was not handled by the bean introspection.voidsetChecks(java.lang.String checks)Setter to define a Regular Expression matched against the name of the check associated with an audit event.voidsetFiles(java.lang.String files)Setter to define a Regular Expression matched against the file name associated with an audit event.voidsetId(java.lang.String id)Setter to define a string matched against the ID of the check associated with an audit event.voidsetMessage(java.lang.String message)Setter to define a Regular Expression matched against the message of the check associated with an audit event.voidsetQuery(java.lang.String query)Setter to define a string xpath query.-
Methods inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
configure, contextualize, getConfiguration, setupChild
-
-
-
-
Field Detail
-
xpathFilter
private XpathFilterElement xpathFilter
XpathFilterElement instance.
-
files
private java.util.regex.Pattern files
Define a Regular Expression matched against the file name associated with an audit event.
-
checks
private java.util.regex.Pattern checks
Define a Regular Expression matched against the name of the check associated with an audit event.
-
message
private java.util.regex.Pattern message
Define a Regular Expression matched against the message of the check associated with an audit event.
-
id
private java.lang.String id
Define a string matched against the ID of the check associated with an audit event.
-
query
private java.lang.String query
Define a string xpath query.
-
-
Constructor Detail
-
SuppressionXpathSingleFilter
public SuppressionXpathSingleFilter()
-
-
Method Detail
-
setFiles
public void setFiles(java.lang.String files)
Setter to define a Regular Expression matched against the file name associated with an audit event.- Parameters:
files- the name of the file- Since:
- 8.18
-
setChecks
public void setChecks(java.lang.String checks)
Setter to define a Regular Expression matched against the name of the check associated with an audit event.- Parameters:
checks- the name of the check- Since:
- 8.18
-
setMessage
public void setMessage(java.lang.String message)
Setter to define a Regular Expression matched against the message of the check associated with an audit event.- Parameters:
message- the message of the check- Since:
- 8.18
-
setId
public void setId(java.lang.String id)
Setter to define a string matched against the ID of the check associated with an audit event.- Parameters:
id- the ID of the check- Since:
- 8.18
-
setQuery
public void setQuery(java.lang.String query)
Setter to define a string xpath query.- Parameters:
query- the xpath query- Since:
- 8.18
-
finishLocalSetup
protected void finishLocalSetup()
Description copied from class:AbstractAutomaticBeanProvides a hook to finish the part of this component's setup that was not handled by the bean introspection.The default implementation does nothing.
- Specified by:
finishLocalSetupin classAbstractAutomaticBean
-
accept
public boolean accept(TreeWalkerAuditEvent treeWalkerAuditEvent)
Description copied from interface:TreeWalkerFilterDetermines whether or not a filteredTreeWalkerAuditEventis accepted.- Specified by:
acceptin interfaceTreeWalkerFilter- Parameters:
treeWalkerAuditEvent- the TreeWalkerAuditEvent to filter.- Returns:
- true if the event is accepted.
-
-