code: public boolean matchRule(AuditEvent event, String ruleName, String expectedMessage, String expectedSeverity) {
          if (!ruleName.equals(RuleUtil.getName(event))) {
              return false;
          }
  
          // check message too, for those that have a specific one.
          // like GenericIllegalRegexp and Regexp
          if (expectedMessage != null) {
              // event.getMessage() uses java.text.MessageFormat in its implementation.
              // Read MessageFormat Javadoc about single quote:
              // http://java.sun.com/j2se/1.4.2/docs/api/java/text/MessageFormat.html
              String msgWithoutSingleQuote = StringUtils.replace(expectedMessage, "'", "");
  
              return expectedMessage.equals(event.getMessage()) || msgWithoutSingleQuote.equals(event.getMessage());
          }
          // Check the severity. This helps to distinguish between
          // different configurations for the same rule, where each
          // configuration has a different severity, like JavadocMetod.
          // See also http://jira.codehaus.org/browse/MCHECKSTYLE-41
          if (expectedSeverity != null) {
              return expectedSeverity.equals(event.getSeverityLevel().getName());
          }
  
          return true;
      }
docs: Check if a violation matches a rule.
  
  @param event            the violation to check
  @param ruleName         The name of the rule
  @param expectedMessage  A message that, if it's not null, will be matched to the message from the violation
  @param expectedSeverity A severity that, if it's not null, will be matched to the severity from the violation
  @return The number of rule violations