use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class QualityGateMeasuresStep method updateMeasures.
private void updateMeasures(Component project, Set<Condition> conditions, QualityGateDetailsDataBuilder builder) {
Multimap<Metric, Condition> conditionsPerMetric = conditions.stream().collect(Collectors.index(Condition::getMetric, java.util.function.Function.identity()));
for (Map.Entry<Metric, Collection<Condition>> entry : conditionsPerMetric.asMap().entrySet()) {
Metric metric = entry.getKey();
Optional<Measure> measure = measureRepository.getRawMeasure(project, metric);
if (!measure.isPresent()) {
continue;
}
MetricEvaluationResult metricEvaluationResult = evaluateQualityGate(measure.get(), entry.getValue());
String text = evaluationResultTextConverter.asText(metricEvaluationResult.condition, metricEvaluationResult.evaluationResult);
builder.addLabel(text);
Measure updatedMeasure = Measure.updatedMeasureBuilder(measure.get()).setQualityGateStatus(new QualityGateStatus(metricEvaluationResult.evaluationResult.getLevel(), text)).create();
measureRepository.update(project, metric, updatedMeasure);
builder.addEvaluatedCondition(metricEvaluationResult);
}
}
Aggregations