Search in sources :

Example 1 with MeasureComputer

use of org.sonar.api.ce.measure.MeasureComputer in project sonarqube by SonarSource.

the class MeasureComputersVisitor method visitAny.

@Override
public void visitAny(org.sonar.server.computation.task.projectanalysis.component.Component component) {
    MeasureComputerContextImpl context = new MeasureComputerContextImpl(component, settings, measureRepository, metricRepository, componentIssuesRepository);
    for (MeasureComputerWrapper measureComputerWrapper : measureComputersHolder.getMeasureComputers()) {
        context.setDefinition(measureComputerWrapper.getDefinition());
        MeasureComputer measureComputer = measureComputerWrapper.getComputer();
        LOGGER.trace("Measure computer '{}' is computing component {}", measureComputer, component);
        measureComputer.compute(context);
    }
}
Also used : MeasureComputerWrapper(org.sonar.server.computation.task.projectanalysis.api.measurecomputer.MeasureComputerWrapper) MeasureComputerContextImpl(org.sonar.server.computation.task.projectanalysis.api.measurecomputer.MeasureComputerContextImpl) MeasureComputer(org.sonar.api.ce.measure.MeasureComputer)

Example 2 with MeasureComputer

use of org.sonar.api.ce.measure.MeasureComputer in project sonarqube by SonarSource.

the class MeasureComputersHolderRule method addMeasureComputer.

public void addMeasureComputer(MeasureComputer measureComputer) {
    requireNonNull(measureComputer, "Measure computer cannot be null");
    MeasureComputer.MeasureComputerDefinition definition = measureComputer.define(context);
    this.measureComputers.add(new MeasureComputerWrapper(measureComputer, definition));
}
Also used : MeasureComputerWrapper(org.sonar.server.computation.task.projectanalysis.api.measurecomputer.MeasureComputerWrapper) MeasureComputer(org.sonar.api.ce.measure.MeasureComputer)

Example 3 with MeasureComputer

use of org.sonar.api.ce.measure.MeasureComputer in project sonarqube by SonarSource.

the class LoadMeasureComputersStepTest method not_fail_if_input_metrics_are_same_as_output_metrics.

@Test
public void not_fail_if_input_metrics_are_same_as_output_metrics() throws Exception {
    MeasureComputer[] computers = new MeasureComputer[] { newMeasureComputer(array(NEW_METRIC_1), array(NEW_METRIC_1)) };
    ComputationStep underTest = new LoadMeasureComputersStep(holder, array(new TestMetrics()), computers);
    underTest.execute();
    assertThat(holder.getMeasureComputers()).hasSize(1);
}
Also used : MeasureComputer(org.sonar.api.ce.measure.MeasureComputer) ComputationStep(org.sonar.server.computation.task.step.ComputationStep) Test(org.junit.Test)

Example 4 with MeasureComputer

use of org.sonar.api.ce.measure.MeasureComputer in project sonarqube by SonarSource.

the class LoadMeasureComputersStepTest method support_core_metrics_as_input_metrics.

@Test
public void support_core_metrics_as_input_metrics() throws Exception {
    MeasureComputer[] computers = new MeasureComputer[] { newMeasureComputer(array(NCLOC_KEY), array(NEW_METRIC_1)) };
    ComputationStep underTest = new LoadMeasureComputersStep(holder, array(new TestMetrics()), computers);
    underTest.execute();
    assertThat(holder.getMeasureComputers()).hasSize(1);
}
Also used : MeasureComputer(org.sonar.api.ce.measure.MeasureComputer) ComputationStep(org.sonar.server.computation.task.step.ComputationStep) Test(org.junit.Test)

Example 5 with MeasureComputer

use of org.sonar.api.ce.measure.MeasureComputer in project sonarqube by SonarSource.

the class LoadMeasureComputersStepTest method support_plugin_metrics_as_input_metrics.

@Test
public void support_plugin_metrics_as_input_metrics() throws Exception {
    MeasureComputer[] computers = new MeasureComputer[] { newMeasureComputer(array(NEW_METRIC_1), array(NEW_METRIC_2)) };
    ComputationStep underTest = new LoadMeasureComputersStep(holder, array(new TestMetrics()), computers);
    underTest.execute();
    assertThat(holder.getMeasureComputers()).hasSize(1);
}
Also used : MeasureComputer(org.sonar.api.ce.measure.MeasureComputer) ComputationStep(org.sonar.server.computation.task.step.ComputationStep) Test(org.junit.Test)

Aggregations

MeasureComputer (org.sonar.api.ce.measure.MeasureComputer)28 Test (org.junit.Test)24 ComputationStep (org.sonar.ce.task.step.ComputationStep)11 TestComputationStepContext (org.sonar.ce.task.step.TestComputationStepContext)11 ComputationStep (org.sonar.server.computation.task.step.ComputationStep)11 MeasureComputerWrapper (org.sonar.ce.task.projectanalysis.api.measurecomputer.MeasureComputerWrapper)5 MeasureComputerWrapper (org.sonar.server.computation.task.projectanalysis.api.measurecomputer.MeasureComputerWrapper)5 MeasureComputerContextImpl (org.sonar.ce.task.projectanalysis.api.measurecomputer.MeasureComputerContextImpl)1 MeasureComputerDefinitionImpl (org.sonar.ce.task.projectanalysis.api.measurecomputer.MeasureComputerDefinitionImpl)1 VisitorsCrawler (org.sonar.ce.task.projectanalysis.component.VisitorsCrawler)1 MeasureComputerContextImpl (org.sonar.server.computation.task.projectanalysis.api.measurecomputer.MeasureComputerContextImpl)1 MeasureComputerDefinitionImpl (org.sonar.server.computation.task.projectanalysis.api.measurecomputer.MeasureComputerDefinitionImpl)1 VisitorsCrawler (org.sonar.server.computation.task.projectanalysis.component.VisitorsCrawler)1