use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class NewMaintainabilityMeasuresVisitor method initNewDebtRatioCounter.
private void initNewDebtRatioCounter(Component file, Path<Counter> path) {
// first analysis, no period, no differential value to compute, save processing time and return now
if (!periodHolder.hasPeriod()) {
return;
}
Optional<Measure> nclocDataMeasure = measureRepository.getRawMeasure(file, this.nclocDataMetric);
if (!nclocDataMeasure.isPresent()) {
return;
}
Optional<ScmInfo> scmInfoOptional = scmInfoRepository.getScmInfo(file);
if (!scmInfoOptional.isPresent()) {
LOG.trace(String.format("No changeset for file %s. Dev cost will be zero.", file.getKey()));
return;
}
ScmInfo scmInfo = scmInfoOptional.get();
initNewDebtRatioCounter(path.current(), file, nclocDataMeasure.get(), scmInfo);
}
use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class FormulaExecutorComponentVisitor method addNewMeasure.
private void addNewMeasure(Component component, String metricKey, Formula formula, Counter counter) {
// no new measure can be created by formulas for PROJECT_VIEW components, their measures are the copy
if (component.getType() == Component.Type.PROJECT_VIEW) {
return;
}
Metric metric = metricRepository.getByKey(metricKey);
Optional<Measure> measure = formula.createMeasure(counter, new CreateMeasureContextImpl(component, metric));
if (measure.isPresent()) {
measureRepository.add(component, metric, measure.get());
}
}
use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class CustomMeasuresCopyStep method copy.
private void copy(Component component) {
for (CustomMeasureDto dto : loadCustomMeasures(component)) {
Metric metric = metricRepository.getById(dto.getMetricId());
// else metric is not found and an exception is raised
Measure measure = dtoToMeasure(dto, metric);
measureRepository.add(component, metric, measure);
}
}
use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class QualityGateEventsStep method executeForProject.
private void executeForProject(Component project) {
Metric metric = metricRepository.getByKey(CoreMetrics.ALERT_STATUS_KEY);
Optional<Measure> rawStatus = measureRepository.getRawMeasure(project, metric);
if (!rawStatus.isPresent() || !rawStatus.get().hasQualityGateStatus()) {
return;
}
checkQualityGateStatusChange(project, metric, rawStatus.get().getQualityGateStatus());
}
use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class QualityGateMeasuresStep method addProjectMeasure.
private void addProjectMeasure(Component project, QualityGateDetailsDataBuilder builder) {
Measure globalMeasure = Measure.newMeasureBuilder().setQualityGateStatus(new QualityGateStatus(builder.getGlobalLevel(), StringUtils.join(builder.getLabels(), ", "))).create(builder.getGlobalLevel());
Metric metric = metricRepository.getByKey(CoreMetrics.ALERT_STATUS_KEY);
measureRepository.add(project, metric, globalMeasure);
String detailMeasureValue = new QualityGateDetailsData(builder.getGlobalLevel(), builder.getEvaluatedConditions()).toJson();
Measure detailsMeasure = Measure.newMeasureBuilder().create(detailMeasureValue);
Metric qgDetailsMetric = metricRepository.getByKey(CoreMetrics.QUALITY_GATE_DETAILS_KEY);
measureRepository.add(project, qgDetailsMetric, detailsMeasure);
}
Aggregations