.setCreationDate(creationDate); 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"); assertThat(issue.message()).isEqualTo("msg"); assertThat(issue.line()).isEqualTo(1); assertThat(issue.gap()).isEqualTo(2.0); assertThat(issue.status()).isEqualTo("RESOLVED"); assertThat(issue.resolution()).isEqualTo("FIXED"); assertThat(issue.assignee()).isEqualTo("tata"); assertThat(issue.isNew()).isTrue(); assertThat(issue.attribute("foo")).isNull(); assertThat(issue.creationDate()).isEqualTo(creationDate); assertThat(issue.language()).isNull(); assertThat(issue.updateDate()).isNull(); assertThat(issue.closeDate()).isNull(); assertThat(issue.authorLogin()).isNull(); assertThat(issue.comments()).isEmpty(); assertThat(issue.effort()).isNull(); assertThat(issue.projectKey()).isNull(); assertThat(issue.projectUuid()).isNull(); assertThat(issue.componentUuid()).isNull(); assertThat(issue.tags()).isEmpty();
@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; } }
@CheckForNull protected Integer getRuleId(Issue issue) { Rule rule = ruleFinder.findByKey(issue.ruleKey()); return rule != null ? rule.getId() : null; } }
severityBag.add(RulePriority.valueOf(issue.severity())); Multiset<RuleKey> rulesBag = initRules(rulesPerSeverity, RulePriority.valueOf(issue.severity())); rulesBag.add(issue.ruleKey()); issuesPerSeverity.put(RulePriority.valueOf(issue.severity()), issue); if (Issue.STATUS_OPEN.equals(issue.status())) { countOpen++; } else if (Issue.STATUS_REOPENED.equals(issue.status())) { countReopened++; } else if (Issue.STATUS_CONFIRMED.equals(issue.status())) { countConfirmed++;
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 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); } } }
@Override public boolean matches(Issue issue) { return issue.resolution() == null; } }
public void addIssue(Issue issue, Rule rule, RulePriority severity) { ReportRuleKey reportRuleKey = new ReportRuleKey(rule, severity); initMaps(reportRuleKey); issues.add(issue); Integer line = issue.line(); line = line != null ? line : 0; if (!issuesPerLine.containsKey(line)) { issuesPerLine.put(line, new ArrayList<Issue>()); } issuesPerLine.get(line).add(issue); if (!issuesByRule.containsKey(rule)) { issuesByRule.put(rule, new AtomicInteger()); } issuesByRule.get(rule).incrementAndGet(); if (!issuesBySeverity.containsKey(severity)) { issuesBySeverity.put(severity, new AtomicInteger()); } issuesBySeverity.get(severity).incrementAndGet(); ruleReportByRuleKey.get(reportRuleKey).getTotal().incrementCountInCurrentAnalysis(); total.incrementCountInCurrentAnalysis(); if (issue.isNew()) { if (!newIssuesPerLine.containsKey(line)) { newIssuesPerLine.put(line, new ArrayList<Issue>()); } newIssuesPerLine.get(line).add(issue); total.incrementNewIssuesCount(); ruleReportByRuleKey.get(reportRuleKey).getTotal().incrementNewIssuesCount(); } }
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 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); } } }
@Override public void executeOn(Project project, SensorContext context) { for (Issue issue : projectIssues.issues()) { if (Severity.ALL.indexOf(issue.severity()) >= issuesSeveritySettingValue) { // only mark failure and fail on PostJobsPhaseHandler.onPostJobsPhase() to ensure other // plugins can finish their work, most notably the stash issue reporter plugin failed = true; return; } } }
public List<Transition> outTransitions(Issue issue) { String status = issue.status(); State state = machine.state(status); checkArgument(state != null, "Unknown status: %s", status); return state.outManualTransitions(issue); }
private boolean isAfter(Issue issue, @Nullable Date date) { return date == null || (issue.creationDate() != null && DateUtils.truncatedCompareTo(issue.creationDate(), date, Calendar.SECOND) > 0); }
@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; } }
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(); }
@Override public boolean matches(Issue issue) { return issue.resolution() != null && resolutions.contains(issue.resolution()); } }