@Override
  public boolean accept(FilterableIssue issue, IssueFilterChain chain) {
    boolean atLeastOneRuleMatched = false;
    boolean atLeastOnePatternFullyMatched = false;
    IssuePattern matchingPattern = null;

    for (IssuePattern pattern : multicriteriaPatterns) {
      if (ruleMatches(pattern, issue.ruleKey())) {
        atLeastOneRuleMatched = true;
        InputComponent component = ((DefaultFilterableIssue) issue).getComponent();
        if (component.isFile()) {
          DefaultInputFile file = (DefaultInputFile) component;
          if (pattern.matchFile(file.getProjectRelativePath())) {
            atLeastOnePatternFullyMatched = true;
            matchingPattern = pattern;
          } else if (pattern.matchFile(file.getModuleRelativePath())) {
            warnOnceDeprecatedIssuePattern(
              "Specifying module-relative paths at project level in property '" + IssueInclusionPatternInitializer.CONFIG_KEY + "' is deprecated. " +
                "To continue matching files like '" + file.getProjectRelativePath() + "', update this property so that patterns refer to project-relative paths.");

            atLeastOnePatternFullyMatched = true;
            matchingPattern = pattern;
          }
        }
      }
    }

    if (atLeastOneRuleMatched) {
      if (atLeastOnePatternFullyMatched) {
        LOG.debug("Issue '{}' enforced by pattern '{}'", issue, matchingPattern);
      }
      return atLeastOnePatternFullyMatched;
    } else {
      return chain.accept(issue);
    }
  }
@Test
  public void shouldAcceptIssueIfMatchesDeprecatedRuleKey() {
    RuleKey ruleKey = RuleKey.of("repo", "rule");
    DefaultActiveRules activeRules = new DefaultActiveRules(ImmutableSet.of(new NewActiveRule.Builder()
      .setRuleKey(ruleKey)
      .setDeprecatedKeys(singleton(RuleKey.of("repo2", "deprecated")))
      .build()));
    String path = "org/sonar/api/Issue.java";
    when(issue.ruleKey()).thenReturn(ruleKey);

    IssuePattern matching = new IssuePattern("org/**", "repo2:deprecated");
    when(exclusionPatternInitializer.getMulticriteriaPatterns()).thenReturn(ImmutableList.of(matching));
    when(issue.getComponent()).thenReturn(createComponentWithPath(path));

    ignoreFilter = new EnforceIssuesFilter(exclusionPatternInitializer, analysisWarnings, activeRules);
    assertThat(ignoreFilter.accept(issue, chain)).isTrue();
    verify(analysisWarnings)
      .addUnique("A multicriteria issue enforce uses the rule key 'repo2:deprecated' that has been changed. The pattern should be updated to 'repo:rule'");
    verifyNoInteractions(chain);
  }