Overview | Package | Class | Use | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.puppycrawl.tools.checkstyle.filters
Class SuppressionCommentFilter

    java.lang.Object
      com.puppycrawl.tools.checkstyle.api.AutomaticBean
          com.puppycrawl.tools.checkstyle.filters.SuppressionCommentFilter

All Implemented Interfaces:
  Configurable, Contextualizable, Filter

    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.

Author:
  Mike McMahon, Rick Giles
See Also:
  `FileContentsHolder`

Nested Class Summary
`class` | `SuppressionCommentFilter.Tag` A Tag holds a suppression comment and its location, and determines whether the supression turns checkstyle reporting on or off.

Constructor Summary
`SuppressionCommentFilter()` Constructs a SuppressionCommentFilter.

Method Summary
`boolean` | `accept(AuditEvent aEvent)` Determines whether or not a filtered AuditEvent is accepted.
`FileContents` | `getFileContents()`
`void` | `setCheckC(boolean aCheckC)` Set whether to look in C comments.
`void` | `setCheckCPP(boolean aCheckCPP)` Set whether to look in C++ comments.
`void` | `setCheckFormat(String aFormat)` Set the format for a check.
`void` | `setFileContents(FileContents aFileContents)` Set the FileContents for this filter.
`void` | `setMessageFormat(String aFormat)` Set the format for a message.
`void` | `setOffCommentFormat(String aFormat)` Set the format for a comment that turns off reporting.
`void` | `setOnCommentFormat(String aFormat)` Set the format for a comment that turns on reporting.

Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
`configure, contextualize, finishLocalSetup, getConfiguration, setupChild`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SuppressionCommentFilter

    public SuppressionCommentFilter()

  Constructs a SuppressionCommentFilter. Initializes comment on, comment off, and check formats to defaults.

Method Detail

### setOffCommentFormat

    public void setOffCommentFormat(String aFormat)
                             throws org.apache.commons.beanutils.ConversionException

  Set the format for a comment that turns off reporting.

  Parameters:
    `aFormat` - a `String` value.
  Throws:
    `org.apache.commons.beanutils.ConversionException` - unable to parse aFormat.

### setOnCommentFormat

    public void setOnCommentFormat(String aFormat)
                            throws org.apache.commons.beanutils.ConversionException

  Set the format for a comment that turns on reporting.

  Parameters:
    `aFormat` - a `String` value
  Throws:
    `org.apache.commons.beanutils.ConversionException` - unable to parse aFormat

### getFileContents

    public FileContents getFileContents()

  Returns:
    the FileContents for this filter.

### setFileContents

    public void setFileContents(FileContents aFileContents)

  Set the FileContents for this filter.

  Parameters:
    `aFileContents` - the FileContents for this filter.

### setCheckFormat

    public void setCheckFormat(String aFormat)
                        throws org.apache.commons.beanutils.ConversionException

  Set the format for a check.

  Parameters:
    `aFormat` - a `String` value
  Throws:
    `org.apache.commons.beanutils.ConversionException` - unable to parse aFormat

### setMessageFormat

    public void setMessageFormat(String aFormat)
                          throws org.apache.commons.beanutils.ConversionException

  Set the format for a message.

  Parameters:
    `aFormat` - a `String` value
  Throws:
    `org.apache.commons.beanutils.ConversionException` - unable to parse aFormat

### setCheckCPP

    public void setCheckCPP(boolean aCheckCPP)

  Set whether to look in C++ comments.

  Parameters:
    `aCheckCPP` - `true` if C++ comments are checked.

### setCheckC

    public void setCheckC(boolean aCheckC)

  Set whether to look in C comments.

  Parameters:
    `aCheckC` - `true` if C comments are checked.

### accept

    public boolean accept(AuditEvent aEvent)

  Determines whether or not a filtered AuditEvent is accepted.

  Specified by:
    `accept` in interface `Filter`
  Parameters:
    `aEvent` - the AudtiEvent to filter.
  Returns:
    true if the aEvent is accepted.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help

Back to the Checkstyle Home Page
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD