summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-03-29 11:19:57 +0200
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-03-29 13:06:51 +0200
commit95cbb670e89d36cd423e00147ca842112a7b7b09 (patch)
tree2a35164b4fb0862d7ef13c09e711a7749f5892fc
parent1c623f97a76734a13224832da38cfa1721d03abe (diff)
downloadsonarqube-95cbb670e89d36cd423e00147ca842112a7b7b09.tar.gz
sonarqube-95cbb670e89d36cd423e00147ca842112a7b7b09.zip
renamed BatchMetrics to ScannerMetrics
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/metric/MetricModule.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/metric/ReportMetricValidatorImpl.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/metric/ReportMetricValidatorImplTest.java16
-rw-r--r--sonar-core/src/main/java/org/sonar/core/metric/ScannerMetrics.java (renamed from sonar-core/src/main/java/org/sonar/core/metric/BatchMetrics.java)10
-rw-r--r--sonar-core/src/test/java/org/sonar/core/metric/ScannerMetricsTest.java (renamed from sonar-core/src/test/java/org/sonar/core/metric/BatchMetricsTest.java)6
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/report/MeasuresPublisher.java10
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java4
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/batch/report/MeasuresPublisherTest.java4
8 files changed, 30 insertions, 30 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/metric/MetricModule.java b/server/sonar-server/src/main/java/org/sonar/server/computation/metric/MetricModule.java
index 29ff696761e..b93bebbce54 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/metric/MetricModule.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/metric/MetricModule.java
@@ -19,14 +19,14 @@
*/
package org.sonar.server.computation.metric;
-import org.sonar.core.metric.BatchMetrics;
+import org.sonar.core.metric.ScannerMetrics;
import org.sonar.core.platform.Module;
public class MetricModule extends Module {
@Override
protected void configureModule() {
add(
- BatchMetrics.class,
+ ScannerMetrics.class,
ReportMetricValidatorImpl.class,
MetricRepositoryImpl.class);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/metric/ReportMetricValidatorImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/metric/ReportMetricValidatorImpl.java
index 1bf87664387..8d94d329fd2 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/metric/ReportMetricValidatorImpl.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/metric/ReportMetricValidatorImpl.java
@@ -28,7 +28,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.core.metric.BatchMetrics;
+import org.sonar.core.metric.ScannerMetrics;
public class ReportMetricValidatorImpl implements ReportMetricValidator {
@@ -37,8 +37,8 @@ public class ReportMetricValidatorImpl implements ReportMetricValidator {
private Map<String, org.sonar.api.measures.Metric> metricByKey;
private Set<String> alreadyLoggedMetricKeys = new HashSet<>();
- public ReportMetricValidatorImpl(BatchMetrics batchMetrics) {
- this.metricByKey = FluentIterable.from(batchMetrics.getMetrics()).uniqueIndex(MetricToKey.INSTANCE);
+ public ReportMetricValidatorImpl(ScannerMetrics scannerMetrics) {
+ this.metricByKey = FluentIterable.from(scannerMetrics.getMetrics()).uniqueIndex(MetricToKey.INSTANCE);
}
@Override
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/metric/ReportMetricValidatorImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/metric/ReportMetricValidatorImplTest.java
index b4fce0e1643..5c6bcf72f3f 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/metric/ReportMetricValidatorImplTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/metric/ReportMetricValidatorImplTest.java
@@ -26,7 +26,7 @@ import org.junit.Test;
import org.sonar.api.measures.Metric;
import org.sonar.api.utils.log.LogTester;
import org.sonar.api.utils.log.LoggerLevel;
-import org.sonar.core.metric.BatchMetrics;
+import org.sonar.core.metric.ScannerMetrics;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
@@ -41,12 +41,12 @@ public class ReportMetricValidatorImplTest {
static final String METRIC_KEY = "metric_key";
- BatchMetrics batchMetrics = mock(BatchMetrics.class);
+ ScannerMetrics scannerMetrics = mock(ScannerMetrics.class);
@Test
public void validate_metric() throws Exception {
- when(batchMetrics.getMetrics()).thenReturn(ImmutableSet.<Metric>of(new Builder(METRIC_KEY, "name", ValueType.INT).create()));
- ReportMetricValidator validator = new ReportMetricValidatorImpl(batchMetrics);
+ when(scannerMetrics.getMetrics()).thenReturn(ImmutableSet.<Metric>of(new Builder(METRIC_KEY, "name", ValueType.INT).create()));
+ ReportMetricValidator validator = new ReportMetricValidatorImpl(scannerMetrics);
assertThat(validator.validate(METRIC_KEY)).isTrue();
assertThat(logTester.logs()).isEmpty();
@@ -54,8 +54,8 @@ public class ReportMetricValidatorImplTest {
@Test
public void not_validate_metric() throws Exception {
- when(batchMetrics.getMetrics()).thenReturn(Collections.<Metric>emptySet());
- ReportMetricValidator validator = new ReportMetricValidatorImpl(batchMetrics);
+ when(scannerMetrics.getMetrics()).thenReturn(Collections.<Metric>emptySet());
+ ReportMetricValidator validator = new ReportMetricValidatorImpl(scannerMetrics);
assertThat(validator.validate(METRIC_KEY)).isFalse();
assertThat(logTester.logs()).containsOnly("The metric 'metric_key' is ignored and should not be send in the batch report");
@@ -63,8 +63,8 @@ public class ReportMetricValidatorImplTest {
@Test
public void not_generate_new_log_when_validating_twice_the_same_metric() throws Exception {
- when(batchMetrics.getMetrics()).thenReturn(Collections.<Metric>emptySet());
- ReportMetricValidator validator = new ReportMetricValidatorImpl(batchMetrics);
+ when(scannerMetrics.getMetrics()).thenReturn(Collections.<Metric>emptySet());
+ ReportMetricValidator validator = new ReportMetricValidatorImpl(scannerMetrics);
assertThat(validator.validate(METRIC_KEY)).isFalse();
assertThat(logTester.logs()).hasSize(1);
diff --git a/sonar-core/src/main/java/org/sonar/core/metric/BatchMetrics.java b/sonar-core/src/main/java/org/sonar/core/metric/ScannerMetrics.java
index fbe8fb11b2e..05bcb7a5ac1 100644
--- a/sonar-core/src/main/java/org/sonar/core/metric/BatchMetrics.java
+++ b/sonar-core/src/main/java/org/sonar/core/metric/ScannerMetrics.java
@@ -82,13 +82,13 @@ import static org.sonar.api.measures.CoreMetrics.UNCOVERED_CONDITIONS;
import static org.sonar.api.measures.CoreMetrics.UNCOVERED_LINES;
/**
- * This class is used to know the list of metrics that can be sent in the batch report.
+ * This class is used to know the list of metrics that can be sent in the analysis report.
* <p/>
- * The batch should not send other metrics, and the Compute Engine should not allow other metrics.
+ * Scanners should not send other metrics, and the Compute Engine should not allow other metrics.
*/
@ComputeEngineSide
@BatchSide
-public class BatchMetrics {
+public class ScannerMetrics {
private static final Set<Metric> ALLOWED_CORE_METRICS = ImmutableSet.<Metric>of(
LINES,
@@ -149,11 +149,11 @@ public class BatchMetrics {
private final Set<Metric> metrics;
- public BatchMetrics() {
+ public ScannerMetrics() {
this.metrics = ALLOWED_CORE_METRICS;
}
- public BatchMetrics(Metrics[] metricsRepositories) {
+ public ScannerMetrics(Metrics[] metricsRepositories) {
this.metrics = ImmutableSet.copyOf(Iterables.concat(getPluginMetrics(metricsRepositories), ALLOWED_CORE_METRICS));
}
diff --git a/sonar-core/src/test/java/org/sonar/core/metric/BatchMetricsTest.java b/sonar-core/src/test/java/org/sonar/core/metric/ScannerMetricsTest.java
index d1f0081c922..5196fb7178d 100644
--- a/sonar-core/src/test/java/org/sonar/core/metric/BatchMetricsTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/metric/ScannerMetricsTest.java
@@ -29,10 +29,10 @@ import org.sonar.api.measures.Metrics;
import static com.google.common.collect.Lists.newArrayList;
import static org.assertj.core.api.Assertions.assertThat;
-public class BatchMetricsTest {
+public class ScannerMetricsTest {
- static final BatchMetrics SENSOR_METRICS_WITHOUT_METRIC_PLUGIN = new BatchMetrics(new Metrics[] {});
- static final BatchMetrics SENSOR_METRICS_WITH_PLUGIN = new BatchMetrics(new Metrics[] {new FakeMetrics()});
+ static final ScannerMetrics SENSOR_METRICS_WITHOUT_METRIC_PLUGIN = new ScannerMetrics(new Metrics[] {});
+ static final ScannerMetrics SENSOR_METRICS_WITH_PLUGIN = new ScannerMetrics(new Metrics[] {new FakeMetrics()});
@Test
public void check_number_of_allowed_core_metrics() throws Exception {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/report/MeasuresPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/report/MeasuresPublisher.java
index b743a841c98..c0b03533d6f 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/report/MeasuresPublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/report/MeasuresPublisher.java
@@ -29,7 +29,7 @@ import org.sonar.api.measures.Measure;
import org.sonar.batch.index.BatchComponent;
import org.sonar.batch.index.BatchComponentCache;
import org.sonar.batch.scan.measure.MeasureCache;
-import org.sonar.core.metric.BatchMetrics;
+import org.sonar.core.metric.ScannerMetrics;
import org.sonar.scanner.protocol.output.ScannerReport;
import org.sonar.scanner.protocol.output.ScannerReport.Measure.BoolValue;
import org.sonar.scanner.protocol.output.ScannerReport.Measure.DoubleValue;
@@ -125,17 +125,17 @@ public class MeasuresPublisher implements ReportPublisherStep {
private final BatchComponentCache resourceCache;
private final MeasureCache measureCache;
- private final BatchMetrics batchMetrics;
+ private final ScannerMetrics scannerMetrics;
- public MeasuresPublisher(BatchComponentCache resourceCache, MeasureCache measureCache, BatchMetrics batchMetrics) {
+ public MeasuresPublisher(BatchComponentCache resourceCache, MeasureCache measureCache, ScannerMetrics scannerMetrics) {
this.resourceCache = resourceCache;
this.measureCache = measureCache;
- this.batchMetrics = batchMetrics;
+ this.scannerMetrics = scannerMetrics;
}
@Override
public void publish(ScannerReportWriter writer) {
- final Set<String> allowedMetricKeys = newHashSet(transform(batchMetrics.getMetrics(), new MetricToKey()));
+ final Set<String> allowedMetricKeys = newHashSet(transform(scannerMetrics.getMetrics(), new MetricToKey()));
for (final BatchComponent resource : resourceCache.all()) {
Iterable<Measure> batchMeasures = measureCache.byResource(resource.resource());
Iterable<org.sonar.scanner.protocol.output.ScannerReport.Measure> reportMeasures = transform(
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
index 867547e0bdd..314761fabb4 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
@@ -91,7 +91,7 @@ import org.sonar.batch.scan.measure.MeasureCache;
import org.sonar.batch.source.CodeColorizers;
import org.sonar.batch.test.TestPlanBuilder;
import org.sonar.batch.test.TestableBuilder;
-import org.sonar.core.metric.BatchMetrics;
+import org.sonar.core.metric.ScannerMetrics;
import org.sonar.core.platform.ComponentContainer;
public class ProjectScanContainer extends ComponentContainer {
@@ -197,7 +197,7 @@ public class ProjectScanContainer extends ComponentContainer {
ProjectSettings.class,
// Report
- BatchMetrics.class,
+ ScannerMetrics.class,
ReportPublisher.class,
AnalysisContextReportPublisher.class,
MetadataPublisher.class,
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/report/MeasuresPublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/report/MeasuresPublisherTest.java
index 0c7a29dd377..268538acff8 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/batch/report/MeasuresPublisherTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/report/MeasuresPublisherTest.java
@@ -34,7 +34,7 @@ import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
import org.sonar.batch.index.BatchComponentCache;
import org.sonar.batch.scan.measure.MeasureCache;
-import org.sonar.core.metric.BatchMetrics;
+import org.sonar.core.metric.ScannerMetrics;
import org.sonar.core.util.CloseableIterator;
import org.sonar.scanner.protocol.output.ScannerReport;
import org.sonar.scanner.protocol.output.ScannerReportReader;
@@ -69,7 +69,7 @@ public class MeasuresPublisherTest {
resourceCache.add(sampleFile, null);
measureCache = mock(MeasureCache.class);
when(measureCache.byResource(any(Resource.class))).thenReturn(Collections.<Measure>emptyList());
- publisher = new MeasuresPublisher(resourceCache, measureCache, new BatchMetrics());
+ publisher = new MeasuresPublisher(resourceCache, measureCache, new ScannerMetrics());
}
@Test