public class SuppressWithPlainTextCommentFilter extends AutomaticBean implements Filter
A filter that uses comments to suppress audit events.
The filter can be used only to suppress audit events received from
FileSetCheck
checks.
SuppressWithPlainTextCommentFilter knows nothing about AST,
it treats only plain text comments and extracts the information required for suppression from
the plain text comments. Currently the filter supports only single line comments.
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 |
SuppressWithPlainTextCommentFilter.Suppression
The class which represents the suppression.
|
AutomaticBean.OutputStreamOptions
Constructor and Description |
---|
SuppressWithPlainTextCommentFilter() |
Modifier and Type | Method and Description |
---|---|
boolean |
accept(AuditEvent event)
Determines whether or not a filtered AuditEvent 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 |
setCheckFormat(String format)
Sets a pattern for check format.
|
void |
setMessageFormat(String format)
Sets a pattern for message format.
|
void |
setOffCommentFormat(Pattern pattern)
Sets an off comment format pattern.
|
void |
setOnCommentFormat(Pattern pattern)
Sets an on comment format pattern.
|
configure, contextualize, getConfiguration, setupChild
public SuppressWithPlainTextCommentFilter()
public final void setOffCommentFormat(Pattern pattern)
pattern
- off comment format pattern.public final void setOnCommentFormat(Pattern pattern)
pattern
- on comment format pattern.public final void setCheckFormat(String format)
format
- pattern for check format.public final void setMessageFormat(String format)
format
- pattern for message format.public boolean accept(AuditEvent event)
Filter
protected void finishLocalSetup() throws CheckstyleException
AutomaticBean
The default implementation does nothing.
finishLocalSetup
in class AutomaticBean
CheckstyleException
- if there is a configuration error.Copyright © 2001–2018. All rights reserved.