Class SuppressWithPlainTextCommentFilter
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.api.AutomaticBean
-
- com.puppycrawl.tools.checkstyle.filters.SuppressWithPlainTextCommentFilter
-
- All Implemented Interfaces:
Configurable
,Contextualizable
,Filter
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SuppressWithPlainTextCommentFilter.Suppression
The class which represents the suppression.-
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
AutomaticBean.OutputStreamOptions
-
-
Constructor Summary
Constructors Constructor Description SuppressWithPlainTextCommentFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
configure, contextualize, getConfiguration, setupChild
-
-
-
-
Method Detail
-
setOffCommentFormat
public final void setOffCommentFormat(Pattern pattern)
Sets an off comment format pattern.- Parameters:
pattern
- off comment format pattern.
-
setOnCommentFormat
public final void setOnCommentFormat(Pattern pattern)
Sets an on comment format pattern.- Parameters:
pattern
- on comment format pattern.
-
setCheckFormat
public final void setCheckFormat(String format)
Sets a pattern for check format.- Parameters:
format
- pattern for check format.
-
setMessageFormat
public final void setMessageFormat(String format)
Sets a pattern for message format.- Parameters:
format
- pattern for message format.
-
accept
public boolean accept(AuditEvent event)
Description copied from interface:Filter
Determines whether or not a filtered AuditEvent is accepted.
-
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
-
-