private void computeTotalViolations(DecoratorContext context) {
   if (context.getMeasure(CoreMetrics.VIOLATIONS) == null) {
     Collection<Measure> childrenViolations = context.getChildrenMeasures(CoreMetrics.VIOLATIONS);
     Double sum = MeasureUtils.sum(true, childrenViolations);
     context.saveMeasure(CoreMetrics.VIOLATIONS, sum + context.getViolations().size());
   }
 }
示例#2
0
 private int saveValue(DecoratorContext context, Metric metric, String ruleKey) {
   int result;
   result = MeasureUtils.sum(true, context.getChildrenMeasures(metric)).intValue();
   for (Violation violation : context.getViolations()) {
     if (violation.getRule().getKey().equals(ruleKey)) {
       result++;
     }
   }
   context.saveMeasure(metric, (double) result);
   return result;
 }
  private void computeViolationsPerSeverities(DecoratorContext context) {
    Multiset<RulePriority> severitiesBag = HashMultiset.create();
    for (Violation violation : context.getViolations()) {
      severitiesBag.add(violation.getSeverity());
    }

    for (RulePriority severity : RulePriority.values()) {
      Metric metric = SeverityUtils.severityToViolationMetric(severity);
      if (context.getMeasure(metric) == null) {
        Collection<Measure> children = context.getChildrenMeasures(MeasuresFilters.metric(metric));
        int sum = MeasureUtils.sum(true, children).intValue() + severitiesBag.count(severity);
        context.saveMeasure(metric, (double) sum);
      }
    }
  }
 private int sumChildren(DecoratorContext context, Metric metric) {
   return MeasureUtils.sum(true, context.getChildrenMeasures(metric)).intValue();
 }