Class SuppressWithNearbyCommentFilter
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.api.AutomaticBean
-
- com.puppycrawl.tools.checkstyle.filters.SuppressWithNearbyCommentFilter
-
- All Implemented Interfaces:
Configurable,Contextualizable,TreeWalkerFilter
public class SuppressWithNearbyCommentFilter extends AutomaticBean implements TreeWalkerFilter
A filter that uses nearby comments to suppress audit events.
This check is philosophically similar to
SuppressionCommentFilter. UnlikeSuppressionCommentFilter, this filter does not require pairs of comments. This check may be used to suppress warnings in the current line:offendingLine(for, whatever, reason); // SUPPRESS ParameterNumberCheckor it may be configured to span multiple lines, either forward:// PERMIT MultipleVariableDeclarations NEXT 3 LINES double x1 = 1.0, y1 = 0.0, z1 = 0.0; double x2 = 0.0, y2 = 1.0, z2 = 0.0; double x3 = 0.0, y3 = 0.0, z3 = 1.0;or reverse:try { thirdPartyLibrary.method(); } catch (RuntimeException ex) { // ALLOW ILLEGAL CATCH BECAUSE third party API wraps everything // in RuntimeExceptions. ... }See
SuppressionCommentFilterfor usage notes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSuppressWithNearbyCommentFilter.TagA Tag holds a suppression comment and its location.-
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
AutomaticBean.OutputStreamOptions
-
-
Constructor Summary
Constructors Constructor Description SuppressWithNearbyCommentFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccept(TreeWalkerAuditEvent event)Determines whether or not a filteredTreeWalkerAuditEventis accepted.protected voidfinishLocalSetup()Provides a hook to finish the part of this component's setup that was not handled by the bean introspection.voidsetCheckC(boolean checkC)Set whether to look in C comments.voidsetCheckCPP(boolean checkCpp)Set whether to look in C++ comments.voidsetCheckFormat(java.lang.String format)Set the format for a check.voidsetCommentFormat(java.util.regex.Pattern pattern)Set the format for a comment that turns off reporting.voidsetFileContents(FileContents fileContents)Set the FileContents for this filter.voidsetInfluenceFormat(java.lang.String format)Set the format for the influence of this check.voidsetMessageFormat(java.lang.String format)Set the format for a message.-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
configure, contextualize, getConfiguration, setupChild
-
-
-
-
Method Detail
-
setCommentFormat
public final void setCommentFormat(java.util.regex.Pattern pattern)
Set the format for a comment that turns off 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- aStringvalue
-
setMessageFormat
public void setMessageFormat(java.lang.String format)
Set the format for a message.- Parameters:
format- aStringvalue
-
setInfluenceFormat
public final void setInfluenceFormat(java.lang.String format)
Set the format for the influence of this check.- Parameters:
format- aStringvalue
-
setCheckCPP
public void setCheckCPP(boolean checkCpp)
Set whether to look in C++ comments.- Parameters:
checkCpp-trueif C++ comments are checked.
-
setCheckC
public void setCheckC(boolean checkC)
Set whether to look in C comments.- Parameters:
checkC-trueif C comments are checked.
-
finishLocalSetup
protected void finishLocalSetup()
Description copied from class:AutomaticBeanProvides 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 classAutomaticBean
-
accept
public boolean accept(TreeWalkerAuditEvent event)
Description copied from interface:TreeWalkerFilterDetermines whether or not a filteredTreeWalkerAuditEventis accepted.- Specified by:
acceptin interfaceTreeWalkerFilter- Parameters:
event- the TreeWalkerAuditEvent to filter.- Returns:
- true if the event is accepted.
-
-