Esempio n. 1
0
  private void saveMeasures(DecoratorContext context, List<Issue> issues) {
    // group issues by requirement
    ListMultimap<TechnicalDebtRequirement, Issue> issuesByRequirement = issuesByRequirement(issues);

    double total = 0.0;
    Map<TechnicalDebtCharacteristic, Double> characteristicCosts = newHashMap();
    Map<TechnicalDebtRequirement, Double> requirementCosts = newHashMap();

    for (TechnicalDebtRequirement requirement : technicalDebtModel.getAllRequirements()) {
      List<Issue> requirementIssues = issuesByRequirement.get(requirement);
      double value =
          computeTechnicalDebt(CoreMetrics.TECHNICAL_DEBT, context, requirement, requirementIssues);

      requirementCosts.put(requirement, value);
      total += value;
      propagateTechnicalDebtInParents(requirement.getParent(), value, characteristicCosts);
    }

    context.saveMeasure(new Measure(CoreMetrics.TECHNICAL_DEBT, total, DECIMALS_PRECISION));
    saveOnCharacteristic(context, characteristicCosts);
    saveOnRequirement(context, requirementCosts);
  }
Esempio n. 2
0
  private double computeTechnicalDebt(
      Metric metric,
      DecoratorContext context,
      TechnicalDebtRequirement requirement,
      Collection<Issue> issues) {
    double value = 0.0;
    if (issues != null) {
      for (Issue issue : issues) {
        value += converter.toDays(((DefaultIssue) issue).technicalDebt());
      }
    }

    for (Measure measure :
        context.getChildrenMeasures(
            MeasuresFilters.characteristic(metric, requirement.toCharacteristic()))) {
      if (measure.getCharacteristic() != null
          && measure.getCharacteristic().equals(requirement.toCharacteristic())
          && measure.getValue() != null) {
        value += measure.getValue();
      }
    }
    return value;
  }