public boolean hasIssuesOnLeak() { return getDistributedMetricStats(RULE_TYPE).getOnLeak() > 0; }
public boolean hasIssues() { return getDistributedMetricStats(RULE_TYPE).getTotal() > 0; }
public IssueChangeNotification setComponent(String componentKey, String componentName) { setFieldValue("componentName", componentName); setFieldValue("componentKey", componentKey); return this; }
public NewIssuesNotification setStatistics(String projectName, NewIssuesStatistics.Stats stats) { setDefaultMessage(stats.getDistributedMetricStats(RULE_TYPE).getOnLeak() + " new issues on " + projectName + ".\n"); try (DbSession dbSession = dbClient.openSession(false)) { setRuleTypeStatistics(stats); setAssigneesStatistics(dbSession, stats); setTagsStatistics(stats); setComponentsStatistics(dbSession, stats); setRuleStatistics(dbSession, stats); } return this; }
private void setTagsStatistics(NewIssuesStatistics.Stats stats) { Metric metric = Metric.TAG; int i = 1; for (Map.Entry<String, MetricStatsInt> tagStats : fiveBiggest(stats.getDistributedMetricStats(metric), MetricStatsInt::getOnLeak)) { setFieldValue(metric + DOT + i + COUNT, String.valueOf(tagStats.getValue().getOnLeak())); setFieldValue(metric + DOT + i + LABEL, tagStats.getKey()); i++; } }
@CheckForNull private Integer countDistributionTotal(Metric metric, String label) { return underTest.globalStatistics() .getDistributedMetricStats(metric) .getForLabel(label) .map(MetricStatsInt::getTotal) .orElse(null); }
public Stats(Predicate<DefaultIssue> onLeakPredicate) { this.onLeakPredicate = onLeakPredicate; for (Metric metric : Metric.values()) { if (metric.isComputedByDistribution()) { distributions.put(metric, new DistributedMetricStatsInt()); } } }
public NewIssuesStatistics(Predicate<DefaultIssue> onLeakPredicate) { this.onLeakPredicate = onLeakPredicate; this.globalStatistics = new Stats(onLeakPredicate); }
public int getTotal() { return globalStats.getTotal(); }
public int getOnLeak() { return globalStats.getOnLeak(); }
public boolean hasIssues() { return globalStatistics.hasIssues(); }
public boolean hasIssuesOnLeak() { return globalStatistics.hasIssuesOnLeak(); }
protected void appendAssignees(StringBuilder message, Notification notification) { genericAppendOfMetric(Metric.ASSIGNEE, "Assignees", message, notification); }
@Override public int hashCode() { return super.hashCode(); } }
public NewIssuesNotification newNewIssuesNotification() { return new NewIssuesNotification(dbClient, durations); } }
@Override public boolean equals(Object obj) { return super.equals(obj); }
public MyNewIssuesNotification newMyNewIssuesNotification() { return new MyNewIssuesNotification(dbClient, durations); }
protected void appendTags(StringBuilder message, Notification notification) { genericAppendOfMetric(Metric.TAG, "Tags", message, notification); }
protected void appendRules(StringBuilder message, Notification notification) { genericAppendOfMetric(Metric.RULE, "Rules", message, notification); }
protected void appendComponents(StringBuilder message, Notification notification) { genericAppendOfMetric(Metric.COMPONENT, "Most impacted files", message, notification); }