Example #1
0
 private void saveOnRequirement(
     DecoratorContext context, Map<TechnicalDebtRequirement, Double> requirementCosts) {
   for (Map.Entry<TechnicalDebtRequirement, Double> entry : requirementCosts.entrySet()) {
     saveCost(
         context,
         entry.getKey().toCharacteristic(),
         entry.getValue(),
         ResourceUtils.isEntity(context.getResource()));
   }
 }
Example #2
0
 @VisibleForTesting
 void saveCost(
     DecoratorContext context,
     org.sonar.api.qualitymodel.Characteristic characteristic,
     Double value,
     boolean inMemory) {
   // we need the value on projects (root or module) even if value==0 in order to display correctly
   // the SQALE history chart (see SQALE-122)
   // BUT we don't want to save zero-values for non top-characteristics (see SQALE-147)
   if (value > 0.0
       || (ResourceUtils.isProject(context.getResource())
           && characteristic.getDepth() == org.sonar.api.qualitymodel.Characteristic.ROOT_DEPTH)) {
     Measure measure = new Measure(CoreMetrics.TECHNICAL_DEBT);
     measure.setCharacteristic(characteristic);
     measure.setValue(value, DECIMALS_PRECISION);
     if (inMemory) {
       measure.setPersistenceMode(PersistenceMode.MEMORY);
     }
     context.saveMeasure(measure);
   }
 }