public class SuppressionCommentFilter extends AutomaticBean implements Filter
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.
Usage: This check only works in conjunction with the FileContentsHolder module since that module makes the suppression comments in the .java files available sub rosa.
FileContentsHolder
Modifier and Type | Class and Description |
---|---|
class |
SuppressionCommentFilter.Tag
A Tag holds a suppression comment and its location, and determines
whether the supression turns checkstyle reporting on or off.
|
Constructor and Description |
---|
SuppressionCommentFilter()
Constructs a SuppressionCoontFilter.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(AuditEvent event)
Determines whether or not a filtered AuditEvent is accepted.
|
FileContents |
getFileContents() |
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(String format)
Set the format for a comment that turns off reporting.
|
void |
setOnCommentFormat(String format)
Set the format for a comment that turns on reporting.
|
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
public SuppressionCommentFilter()
public void setOffCommentFormat(String format) throws org.apache.commons.beanutils.ConversionException
format
- a String
value.org.apache.commons.beanutils.ConversionException
- unable to parse format.public void setOnCommentFormat(String format) throws org.apache.commons.beanutils.ConversionException
format
- a String
valueorg.apache.commons.beanutils.ConversionException
- unable to parse formatpublic FileContents getFileContents()
public void setFileContents(FileContents fileContents)
fileContents
- the FileContents for this filter.public void setCheckFormat(String format) throws org.apache.commons.beanutils.ConversionException
format
- a String
valueorg.apache.commons.beanutils.ConversionException
- unable to parse formatpublic void setMessageFormat(String format) throws org.apache.commons.beanutils.ConversionException
format
- a String
valueorg.apache.commons.beanutils.ConversionException
- unable to parse formatpublic void setCheckCPP(boolean checkCPP)
checkCPP
- true
if C++ comments are checked.public void setCheckC(boolean checkC)
checkC
- true
if C comments are checked.public boolean accept(AuditEvent event)
Copyright © 2001–2015. All rights reserved.