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.
Modifier and Type | Class and 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.
|
AutomaticBean.OutputStreamOptions
Constructor and Description |
---|
SuppressionCommentFilter() |
Modifier and Type | Method and Description |
---|---|
boolean |
accept(TreeWalkerAuditEvent event)
Determines whether or not a filtered
TreeWalkerAuditEvent 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(String format)
Set the format for a check.
|
void |
setFileContents(FileContents fileContents)
Set the FileContents for this filter.
|
void |
setMessageFormat(String format)
Set the format for a message.
|
void |
setOffCommentFormat(Pattern pattern)
Set the format for a comment that turns off reporting.
|
void |
setOnCommentFormat(Pattern pattern)
Set the format for a comment that turns on reporting.
|
configure, contextualize, getConfiguration, setupChild
public SuppressionCommentFilter()
public final void setOffCommentFormat(Pattern pattern)
pattern
- a pattern.public final void setOnCommentFormat(Pattern pattern)
pattern
- a pattern.public void setFileContents(FileContents fileContents)
fileContents
- the FileContents for this filter.public final void setCheckFormat(String format)
format
- a String
valuepublic void setMessageFormat(String format)
format
- a String
valuepublic void setCheckCPP(boolean checkCpp)
checkCpp
- true
if C++ comments are checked.public void setCheckC(boolean checkC)
checkC
- true
if C comments are checked.protected void finishLocalSetup() throws CheckstyleException
AutomaticBean
The default implementation does nothing.
finishLocalSetup
in class AutomaticBean
CheckstyleException
- if there is a configuration error.public boolean accept(TreeWalkerAuditEvent event)
TreeWalkerFilter
TreeWalkerAuditEvent
is accepted.accept
in interface TreeWalkerFilter
event
- the TreeWalkerAuditEvent to filter.Copyright © 2001–2018. All rights reserved.