Issue issue = new TrackedIssueAdapter(trackedIssue); assertThat(issue.key()).isEqualTo("XYZ123"); assertThat(issue.componentKey()).isEqualTo("foo"); assertThat(issue.ruleKey()).isEqualTo(RuleKey.of("repo", "rule")); assertThat(issue.severity()).isEqualTo("MAJOR");
private boolean validate(Issue issue, Rule rule, ResourceNode resource) { if (rule == null) { LOG.warn("Unknow rule for issue {}", issue); return false; } if (resource == null) { LOG.debug("Unknow resource with key {}", issue.componentKey()); return false; } return true; }
private boolean validate(Issue issue, Rule rule, BatchResource resource) { if (rule == null) { LOG.warn("Unknow rule for issue {}", issue); return false; } if (resource == null) { LOG.debug("Unknow resource with key {}", issue.componentKey()); return false; } return true; }
private Collection<String> getWarningsByLine(Issue issue) { Integer line = issue.line(); String componentKey = issue.componentKey(); if (line != null && suppressWarningsLinesByResource.containsKey(componentKey)) { return suppressWarningsLinesByResource.get(componentKey).get(line); } return Sets.newTreeSet(); }
private Collection<String> getWarningsByLine(Issue issue) { Integer line = issue.line(); String componentKey = issue.componentKey(); if (line != null && suppressWarningsLinesByResource.containsKey(componentKey)) { return suppressWarningsLinesByResource.get(componentKey).get(line); } return Sets.newTreeSet(); }
public IssuePattern getMatchingPattern(Issue issue) { IssuePattern matchingPattern = null; Iterator<IssuePattern> patternIterator = getPatternsForComponent(issue.componentKey()).iterator(); while(matchingPattern == null && patternIterator.hasNext()) { IssuePattern nextPattern = patternIterator.next(); if (nextPattern.match(issue)) { matchingPattern = nextPattern; } } return matchingPattern; }
@Override public boolean accept(Issue issue, IssueFilterChain chain) { boolean accepted = true; if (issue.line() != null) { Set<Integer> noSonarLines = noSonarLinesByResource.get(issue.componentKey()); accepted = noSonarLines == null || !noSonarLines.contains(issue.line()); if (!accepted && StringUtils.containsIgnoreCase(issue.ruleKey().rule(), "nosonar")) { accepted = true; } } if (accepted) { accepted = chain.accept(issue); } return accepted; } }
@Override public boolean accept(Issue issue, IssueFilterChain chain) { boolean accepted = true; if (issue.line() != null) { Set<Integer> noSonarLines = noSonarLinesByKey.get(issue.componentKey()); accepted = noSonarLines == null || !noSonarLines.contains(issue.line()); if (!accepted && StringUtils.containsIgnoreCase(issue.ruleKey().rule(), "nosonar")) { accepted = true; } } if (accepted) { accepted = chain.accept(issue); } return accepted; } }
public boolean match(Issue issue) { boolean match = matchResource(issue.componentKey()) && matchRule(issue.ruleKey()); if (checkLines) { Integer line = issue.line(); if (line == null) { match = false; } else { match = match && matchLine(line); } } return match; }
private void processIssues(IssuesReport issuesReport, Iterable<Issue> issues, boolean resolved) { for (Issue issue : issues) { Rule rule = findRule(issue); RulePriority severity = RulePriority.valueOf(issue.severity()); ResourceNode resource = resourceTree.getResource(issue.componentKey()); if (!validate(issue, rule, resource)) { continue; } if (resolved) { issuesReport.addResolvedIssueOnResource(resource, issue, rule, severity); } else { issuesReport.addIssueOnResource(resource, issue, rule, severity); } } }
private void processIssues(IssuesReport issuesReport, Iterable<DefaultIssue> issues) { for (Issue issue : issues) { Rule rule = findRule(issue); RulePriority severity = RulePriority.valueOf(issue.severity()); BatchResource resource = resourceCache.get(issue.componentKey()); if (!validate(issue, rule, resource)) { continue; } if (issue.resolution() != null) { issuesReport.addResolvedIssueOnResource(resource, issue, rule, severity); } else { issuesReport.addIssueOnResource(resource, issue, rule, severity); } } }
@Override public boolean accept(Issue issue, IssueFilterChain chain) { boolean atLeastOneRuleMatched = false; boolean atLeastOnePatternFullyMatched = false; IssuePattern matchingPattern = null; for (IssuePattern pattern : patternInitializer.getMulticriteriaPatterns()) { if (pattern.getRulePattern().match(issue.ruleKey().toString())) { atLeastOneRuleMatched = true; String pathForComponent = patternInitializer.getPathForComponent(issue.componentKey()); if (pathForComponent != null && pattern.getResourcePattern().match(pathForComponent)) { atLeastOnePatternFullyMatched = true; matchingPattern = pattern; } } } if (atLeastOneRuleMatched) { if (atLeastOnePatternFullyMatched) { LOG.debug("Issue {} enforced by pattern {}", issue, matchingPattern); } return atLeastOnePatternFullyMatched; } else { return chain.accept(issue); } } }