public class SuppressWithNearbyCommentFilter extends AutomaticBean implements TreeWalkerFilter
A filter that uses nearby comments to suppress audit events.
This check is philosophically similar to SuppressionCommentFilter
.
Unlike SuppressionCommentFilter
, 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 SuppressionCommentFilter
for usage notes.
Modifier and Type | Class and Description |
---|---|
static class |
SuppressWithNearbyCommentFilter.Tag
A Tag holds a suppression comment and its location.
|
AutomaticBean.OutputStreamOptions
Constructor and Description |
---|
SuppressWithNearbyCommentFilter() |
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 |
setCommentFormat(Pattern pattern)
Set the format for a comment that turns off reporting.
|
void |
setFileContents(FileContents fileContents)
Set the FileContents for this filter.
|
void |
setInfluenceFormat(String format)
Set the format for the influence of this check.
|
void |
setMessageFormat(String format)
Set the format for a message.
|
configure, contextualize, getConfiguration, setupChild
public SuppressWithNearbyCommentFilter()
public final void setCommentFormat(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 final void setInfluenceFormat(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.