Class SuppressionCommentFilter
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.api.AutomaticBean
-
- com.puppycrawl.tools.checkstyle.filters.SuppressionCommentFilter
-
- All Implemented Interfaces:
Configurable
,Contextualizable
,TreeWalkerFilter
public class SuppressionCommentFilter extends AutomaticBean implements TreeWalkerFilter
A filter that uses 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SuppressionCommentFilter.Tag
A Tag holds a suppression comment and its location, and determines whether the suppression turns checkstyle reporting on or off.static class
SuppressionCommentFilter.TagType
Enum to be used for switching checkstyle reporting for tags.-
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
AutomaticBean.OutputStreamOptions
-
-
Constructor Summary
Constructors Constructor Description SuppressionCommentFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accept(TreeWalkerAuditEvent event)
Determines whether or not a filteredTreeWalkerAuditEvent
is accepted.protected void
finishLocalSetup()
Provides a hook to finish the part of this component's setup that was not handled by the bean introspection.void
setCheckC(boolean checkC)
Set whether to look in C comments.void
setCheckCPP(boolean checkCpp)
Set whether to look in C++ comments.void
setCheckFormat(java.lang.String format)
Set the format for a check.void
setFileContents(FileContents fileContents)
Set the FileContents for this filter.void
setMessageFormat(java.lang.String format)
Set the format for a message.void
setOffCommentFormat(java.util.regex.Pattern pattern)
Set the format for a comment that turns off reporting.void
setOnCommentFormat(java.util.regex.Pattern pattern)
Set the format for a comment that turns on reporting.-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
configure, contextualize, getConfiguration, setupChild
-
-
-
-
Method Detail
-
setOffCommentFormat
public final void setOffCommentFormat(java.util.regex.Pattern pattern)
Set the format for a comment that turns off reporting.- Parameters:
pattern
- a pattern.
-
setOnCommentFormat
public final void setOnCommentFormat(java.util.regex.Pattern pattern)
Set the format for a comment that turns on reporting.- Parameters:
pattern
- a pattern.
-
setFileContents
public void setFileContents(FileContents fileContents)
Set the FileContents for this filter.- Parameters:
fileContents
- the FileContents for this filter.
-
setCheckFormat
public final void setCheckFormat(java.lang.String format)
Set the format for a check.- Parameters:
format
- aString
value
-
setMessageFormat
public void setMessageFormat(java.lang.String format)
Set the format for a message.- Parameters:
format
- aString
value
-
setCheckCPP
public void setCheckCPP(boolean checkCpp)
Set whether to look in C++ comments.- Parameters:
checkCpp
-true
if C++ comments are checked.
-
setCheckC
public void setCheckC(boolean checkC)
Set whether to look in C comments.- Parameters:
checkC
-true
if C comments are checked.
-
finishLocalSetup
protected void finishLocalSetup()
Description copied from class:AutomaticBean
Provides 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:
finishLocalSetup
in classAutomaticBean
-
accept
public boolean accept(TreeWalkerAuditEvent event)
Description copied from interface:TreeWalkerFilter
Determines whether or not a filteredTreeWalkerAuditEvent
is accepted.- Specified by:
accept
in interfaceTreeWalkerFilter
- Parameters:
event
- the TreeWalkerAuditEvent to filter.- Returns:
- true if the event is accepted.
-
-