Class SuppressWithPlainTextCommentFilter

  • All Implemented Interfaces:
    Configurable, Contextualizable, Filter

    public class SuppressWithPlainTextCommentFilter
    extends AutomaticBean
    implements Filter

    A filter that uses comments to suppress audit events. The filter can be used only to suppress audit events received from FileSetCheck checks. SuppressWithPlainTextCommentFilter knows nothing about AST, it treats only plain text comments and extracts the information required for suppression from the plain text comments. Currently the filter supports only single line comments.

    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.

    • Constructor Detail

      • SuppressWithPlainTextCommentFilter

        public SuppressWithPlainTextCommentFilter()
    • Method Detail

      • setOffCommentFormat

        public final void setOffCommentFormat​(java.util.regex.Pattern pattern)
        Sets an off comment format pattern.
        Parameters:
        pattern - off comment format pattern.
      • setOnCommentFormat

        public final void setOnCommentFormat​(java.util.regex.Pattern pattern)
        Sets an on comment format pattern.
        Parameters:
        pattern - on comment format pattern.
      • setCheckFormat

        public final void setCheckFormat​(java.lang.String format)
        Sets a pattern for check format.
        Parameters:
        format - pattern for check format.
      • setMessageFormat

        public final void setMessageFormat​(java.lang.String format)
        Sets a pattern for message format.
        Parameters:
        format - pattern for message format.
      • 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.
      • finishLocalSetup

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