public void executeOn(Project project, SensorContext context) {
sendNotifications(project);
}
private void sendNotifications(Project project) {
IssuesBySeverity newIssues = new IssuesBySeverity();
IssueChangeContext context = IssueChangeContext.createScan(project.getAnalysisDate());
Map<DefaultIssue, Rule> shouldSentNotification = new LinkedHashMap<DefaultIssue, Rule>();
for (DefaultIssue issue : issueCache.all()) {
if (issue.isNew() && issue.resolution() == null) {
newIssues.add(issue);
}
if (!issue.isNew() && issue.isChanged() && issue.mustSendNotifications()) {
Rule rule = ruleFinder.findByKey(issue.ruleKey());
// TODO warning - rules with status REMOVED are currently ignored, but should not
if (rule != null) {
shouldSentNotification.put(issue, rule);
}
}
}
if (!shouldSentNotification.isEmpty()) {
notifications.sendChanges(shouldSentNotification, context, project, null, null);
}
if (!newIssues.isEmpty()) {
notifications.sendNewIssues(project, newIssues);
}
}