Class SuppressionXpathSingleFilter
java.lang.Object
com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
com.puppycrawl.tools.checkstyle.filters.SuppressionXpathSingleFilter
- All Implemented Interfaces:
Configurable,Contextualizable,TreeWalkerFilter
Filter
SuppressionXpathSingleFilter suppresses audit events for Checks
violations in the specified file, class, checks, message, module id, and xpath.
Rationale: To allow users to use suppressions configured in the same config as other modules.
SuppressionFilter and SuppressionXpathFilter require a 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.
Notes:
SuppressionXpathSingleFilter can suppress Checks that have Treewalker as parent module.
- Since:
- 8.18
-
Nested Class Summary
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
AbstractAutomaticBean.OutputStreamOptions -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate PatternDefine a Regular Expression matched against the name of the check associated with an audit event.private PatternDefine a Regular Expression matched against the file name associated with an audit event.private StringDefine a string matched against the ID of the check associated with an audit event.private PatternDefine a Regular Expression matched against the message of the check associated with an audit event.private StringDefine a string xpath query.private XpathFilterElementXpathFilterElement instance. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaccept(TreeWalkerAuditEvent treeWalkerAuditEvent) Determines whether or not a filteredTreeWalkerAuditEventis accepted.protected voidProvides a hook to finish the part of this component's setup that was not handled by the bean introspection.voidSetter to define a Regular Expression matched against the name of the check associated with an audit event.voidSetter to define a Regular Expression matched against the file name associated with an audit event.voidSetter to define a string matched against the ID of the check associated with an audit event.voidsetMessage(String message) Setter to define a Regular Expression matched against the message of the check associated with an audit event.voidSetter to define a string xpath query.Methods inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
configure, contextualize, getConfiguration, setupChild
-
Field Details
-
xpathFilter
XpathFilterElement instance. -
files
Define a Regular Expression matched against the file name associated with an audit event. -
checks
Define a Regular Expression matched against the name of the check associated with an audit event. -
message
Define a Regular Expression matched against the message of the check associated with an audit event. -
id
Define a string matched against the ID of the check associated with an audit event. -
query
Define a string xpath query.
-
-
Constructor Details
-
SuppressionXpathSingleFilter
public SuppressionXpathSingleFilter()
-
-
Method Details
-
setFiles
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
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
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
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
Setter to define a string xpath query.- Parameters:
query- the xpath query- Since:
- 8.18
-
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
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.
-