use of org.sonar.server.computation.task.projectanalysis.metric.Metric in project sonarqube by SonarSource.
the class MeasureComputerContextImpl method addMeasure.
@Override
public void addMeasure(String metricKey, double value) {
Metric metric = metricRepository.getByKey(metricKey);
validateAddMeasure(metric);
measureRepository.add(internalComponent, metric, newMeasureBuilder().create(value, metric.getDecimalScale()));
}
use of org.sonar.server.computation.task.projectanalysis.metric.Metric in project sonarqube by SonarSource.
the class MeasureComputerContextImpl method addMeasure.
@Override
public void addMeasure(String metricKey, long value) {
Metric metric = metricRepository.getByKey(metricKey);
validateAddMeasure(metric);
measureRepository.add(internalComponent, metric, newMeasureBuilder().create(value));
}
use of org.sonar.server.computation.task.projectanalysis.metric.Metric in project sonarqube by SonarSource.
the class IssueCounter method addMeasuresByPeriod.
private void addMeasuresByPeriod(Component component) {
if (!periodHolder.hasPeriod()) {
return;
}
Double unresolvedVariations = (double) currentCounters.counterForPeriod().unresolved;
measureRepository.add(component, metricRepository.getByKey(NEW_VIOLATIONS_KEY), Measure.newMeasureBuilder().setVariation(unresolvedVariations).createNoValue());
for (Map.Entry<String, String> entry : SEVERITY_TO_NEW_METRIC_KEY.entrySet()) {
String severity = entry.getKey();
String metricKey = entry.getValue();
Multiset<String> bag = currentCounters.counterForPeriod().severityBag;
Metric metric = metricRepository.getByKey(metricKey);
measureRepository.add(component, metric, Measure.newMeasureBuilder().setVariation((double) bag.count(severity)).createNoValue());
}
// (see call currentCounters.counterForPeriod(period.getIndex()).xxx with xxx as severityBag or typeBag)
for (Map.Entry<RuleType, String> entry : TYPE_TO_NEW_METRIC_KEY.entrySet()) {
RuleType type = entry.getKey();
String metricKey = entry.getValue();
Multiset<RuleType> bag = currentCounters.counterForPeriod().typeBag;
Metric metric = metricRepository.getByKey(metricKey);
measureRepository.add(component, metric, Measure.newMeasureBuilder().setVariation((double) bag.count(type)).createNoValue());
}
}
use of org.sonar.server.computation.task.projectanalysis.metric.Metric 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.metric.Metric in project sonarqube by SonarSource.
the class ComputeMeasureVariationsStep method execute.
@Override
public void execute() {
try (DbSession dbSession = dbClient.openSession(false)) {
List<Metric> metrics = StreamSupport.stream(metricRepository.getAll().spliterator(), false).filter(isNumeric()).collect(Collectors.toList());
new DepthTraversalTypeAwareCrawler(new VariationMeasuresVisitor(dbSession, metrics)).visit(treeRootHolder.getRoot());
}
}
Aggregations