Class SuppressionSingleFilter

java.lang.Object
com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
com.puppycrawl.tools.checkstyle.filters.SuppressionSingleFilter
All Implemented Interfaces:
Configurable, Contextualizable, Filter

public class SuppressionSingleFilter extends AbstractAutomaticBean implements Filter
Filter SuppressionSingleFilter suppresses audit events for Checks violations in the specified file, class, checks, message, module id, lines, and columns.

Rationale: To allow users to use suppressions configured in the same config as other modules. SuppressionFilter and SuppressionXpathFilter require a separate file.

Advice: If checkstyle configuration is used for several projects, single suppressions on common files/folders is better to put in checkstyle configuration as common rule. All suppression that are for specific file names is better to keep in project specific config file.

Attention: This filter only supports single suppression, and will need multiple instances if users wants to suppress multiple violations.

SuppressionSingleFilter can suppress Checks that have Treewalker or Checker as parent module.

  • Property checks - Define the RegExp for matching against the name of the check associated with an audit event. Type is java.util.regex.Pattern. Default value is null.
  • Property columns - Specify a comma-separated list of values, where each value is an integer or a range of integers denoted by integer-integer. Type is java.lang.String. Default value is null.
  • Property files - Define the RegExp for matching against the file name associated with an audit event. Type is java.util.regex.Pattern. Default value is null.
  • Property id - Specify a string matched against the ID of the check associated with an audit event. Type is java.lang.String. Default value is null.
  • Property lines - Specify a comma-separated list of values, where each value is an integer or a range of integers denoted by integer-integer. Type is java.lang.String. Default value is null.
  • Property message - Define the RegExp for matching against the message of the check associated with an audit event. Type is java.util.regex.Pattern. Default value is null.

Parent is com.puppycrawl.tools.checkstyle.Checker

Since:
8.23
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean

    AbstractAutomaticBean.OutputStreamOptions
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private Pattern
    Define the RegExp for matching against the name of the check associated with an audit event.
    private String
    Specify a comma-separated list of values, where each value is an integer or a range of integers denoted by integer-integer.
    private Pattern
    Define the RegExp for matching against the file name associated with an audit event.
    SuppressFilterElement instance.
    private String
    Specify a string matched against the ID of the check associated with an audit event.
    private String
    Specify a comma-separated list of values, where each value is an integer or a range of integers denoted by integer-integer.
    private Pattern
    Define the RegExp for matching against the message of the check associated with an audit event.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Determines whether or not a filtered AuditEvent is accepted.
    protected void
    Provides a hook to finish the part of this component's setup that was not handled by the bean introspection.
    void
    setChecks(String checks)
    Setter to define the RegExp for matching against the name of the check associated with an audit event.
    void
    setColumns(String columns)
    Setter to specify a comma-separated list of values, where each value is an integer or a range of integers denoted by integer-integer.
    void
    Setter to define the RegExp for matching against the file name associated with an audit event.
    void
    Setter to specify a string matched against the ID of the check associated with an audit event.
    void
    Setter to specify a comma-separated list of values, where each value is an integer or a range of integers denoted by integer-integer.
    void
    Setter to define the RegExp for matching against the message of the check associated with an audit event.

    Methods inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean

    configure, contextualize, getConfiguration, setupChild

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • filter

      SuppressFilterElement instance.
    • files

      private Pattern files
      Define the RegExp for matching against the file name associated with an audit event.
    • checks

      private Pattern checks
      Define the RegExp for matching against the name of the check associated with an audit event.
    • message

      private Pattern message
      Define the RegExp for matching against the message of the check associated with an audit event.
    • id

      private String id
      Specify a string matched against the ID of the check associated with an audit event.
    • lines

      private String lines
      Specify a comma-separated list of values, where each value is an integer or a range of integers denoted by integer-integer.
    • columns

      private String columns
      Specify a comma-separated list of values, where each value is an integer or a range of integers denoted by integer-integer.
  • Constructor Details

  • Method Details

    • setFiles

      public void setFiles(Pattern files)
      Setter to define the RegExp for matching against the file name associated with an audit event.
      Parameters:
      files - regular expression for filtered file names
      Since:
      8.23
    • setChecks

      public void setChecks(String checks)
      Setter to define the RegExp for matching against the name of the check associated with an audit event.
      Parameters:
      checks - the name of the check
      Since:
      8.23
    • setMessage

      public void setMessage(Pattern message)
      Setter to define the RegExp for matching against the message of the check associated with an audit event.
      Parameters:
      message - the message of the check
      Since:
      8.23
    • setId

      public void setId(String id)
      Setter to specify a string matched against the ID of the check associated with an audit event.
      Parameters:
      id - the ID of the check
      Since:
      8.23
    • setLines

      public void setLines(String lines)
      Setter to specify a comma-separated list of values, where each value is an integer or a range of integers denoted by integer-integer.
      Parameters:
      lines - the lines of the check
      Since:
      8.23
    • setColumns

      public void setColumns(String columns)
      Setter to specify a comma-separated list of values, where each value is an integer or a range of integers denoted by integer-integer.
      Parameters:
      columns - the columns of the check
      Since:
      8.23
    • finishLocalSetup

      protected void finishLocalSetup()
      Description copied from class: AbstractAutomaticBean
      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 class AbstractAutomaticBean
    • accept

      public boolean accept(AuditEvent event)
      Description copied from interface: Filter
      Determines whether or not a filtered AuditEvent is accepted.
      Specified by:
      accept in interface Filter
      Parameters:
      event - the AuditEvent to filter.
      Returns:
      true if the event is accepted.