// Path: src/main/java/org/sonar/plugins/stash/StashPluginUtils.java
// public static boolean isProjectWide(PostJobIssue issue) {
//   InputComponent ic = issue.inputComponent();
//   if (!(ic instanceof InputModule)) {
//     return false;
//   }
//   InputModule im = (InputModule) ic;
//   if (im.key() == null) {
//     return false;
//   }
//   return CharMatcher.is(':').countIn(im.key()) == 0;
// }
// 
// Path: src/main/java/org/sonar/plugins/stash/IssuePathResolver.java
// @FunctionalInterface
// public interface IssuePathResolver {
//   String getIssuePath(PostJobIssue issue);
// }


import java.util.Set;
import static org.sonar.plugins.stash.StashPluginUtils.isProjectWide;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import org.sonar.api.batch.postjob.issue.PostJobIssue;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.plugins.stash.IssuePathResolver;

      Iterable<PostJobIssue> issues, IssuePathResolver issuePathResolver,
      boolean includeExistingIssues, Set<RuleKey> excludedRules) {
    return StreamSupport.stream(
        issues.spliterator(), false)
                        .filter(issue -> shouldIncludeIssue(
                            issue, issuePathResolver,
                            includeExistingIssues, excludedRules
                        ))
                        .collect(Collectors.toList());
  }

  static boolean shouldIncludeIssue(
      PostJobIssue issue, IssuePathResolver issuePathResolver,
      boolean includeExistingIssues, Set<RuleKey> excludedRules
  ) {
    if (!includeExistingIssues && !issue.isNew()) {
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Issue {} is not a new issue and so, not added to the report", issue.key());
      }
      return false;
    }

    if (excludedRules.contains(issue.ruleKey())) {
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Issue {} is ignored, not added to the report", issue.key());
      }
      return false;
    }

    String path = issuePathResolver.getIssuePath(issue);

// Path: src/main/java/org/sonar/plugins/stash/StashPluginUtils.java
// public static boolean isProjectWide(PostJobIssue issue) {
//   InputComponent ic = issue.inputComponent();
//   if (!(ic instanceof InputModule)) {
//     return false;
//   }
//   InputModule im = (InputModule) ic;
//   if (im.key() == null) {
//     return false;
//   }
//   return CharMatcher.is(':').countIn(im.key()) == 0;
// }
// 
// Path: src/main/java/org/sonar/plugins/stash/IssuePathResolver.java
// @FunctionalInterface
// public interface IssuePathResolver {
//   String getIssuePath(PostJobIssue issue);
// }


// Path: src/main/java/org/sonar/plugins/stash/issue/collector/SonarQubeCollector.java
import java.util.Set;
import static org.sonar.plugins.stash.StashPluginUtils.isProjectWide;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import org.sonar.api.batch.postjob.issue.PostJobIssue;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.plugins.stash.IssuePathResolver;

      Iterable<PostJobIssue> issues, IssuePathResolver issuePathResolver,
      boolean includeExistingIssues, Set<RuleKey> excludedRules) {
    return StreamSupport.stream(
        issues.spliterator(), false)
                        .filter(issue -> shouldIncludeIssue(
                            issue, issuePathResolver,
                            includeExistingIssues, excludedRules
                        ))
                        .collect(Collectors.toList());
  }

  static boolean shouldIncludeIssue(
      PostJobIssue issue, IssuePathResolver issuePathResolver,
      boolean includeExistingIssues, Set<RuleKey> excludedRules
  ) {
    if (!includeExistingIssues && !issue.isNew()) {
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Issue {} is not a new issue and so, not added to the report", issue.key());
      }
      return false;
    }

    if (excludedRules.contains(issue.ruleKey())) {
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Issue {} is ignored, not added to the report", issue.key());
      }
      return false;
    }

    String path = issuePathResolver.getIssuePath(issue);

    if (!isProjectWide(issue) && path == null) {
