Class 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
    • Method Detail

      • setOffCommentFormat

        public final void setOffCommentFormat​(Pattern pattern)
        Set the format for a comment that turns off reporting.
        Parameters:
        pattern - a pattern.
      • setOnCommentFormat

        public final void setOnCommentFormat​(Pattern pattern)
        Set the format for a comment that turns on reporting.
        Parameters:
        pattern - a pattern.
      • getFileContents

        public FileContents getFileContents()
        Returns FileContents for this filter.
        Returns:
        the FileContents for this filter.
      • setFileContents

        public void setFileContents​(FileContents fileContents)
        Set the FileContents for this filter.
        Parameters:
        fileContents - the FileContents for this filter.
      • setCheckFormat

        public final void setCheckFormat​(String format)
        Set the format for a check.
        Parameters:
        format - a String value
      • setMessageFormat

        public void setMessageFormat​(String format)
        Set the format for a message.
        Parameters:
        format - a String value
      • setCheckCPP

        public void setCheckCPP​(boolean checkCpp)
        Set whether to look in C++ comments.
        Parameters:
        checkCpp - true if C++ comments are checked.
      • setCheckC

        public void setCheckC​(boolean checkC)
        Set whether to look in C comments.
        Parameters:
        checkC - true if C comments are checked.
      • 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.