aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/DefaultStorable.java11
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java6
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/batch/sensor/DefaultSensorStorageTest.java23
3 files changed, 12 insertions, 28 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/DefaultStorable.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/DefaultStorable.java
index 9a87a98663e..0c39e2d891b 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/DefaultStorable.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/DefaultStorable.java
@@ -20,15 +20,13 @@
package org.sonar.api.batch.sensor.internal;
import com.google.common.base.Preconditions;
+import javax.annotation.Nullable;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
-import org.sonar.api.batch.fs.InputFile;
-
-import javax.annotation.Nullable;
public abstract class DefaultStorable {
- protected transient final SensorStorage storage;
+ protected final transient SensorStorage storage;
private transient boolean saved = false;
public DefaultStorable() {
@@ -53,9 +51,4 @@ public abstract class DefaultStorable {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}
- protected void validateLineArgument(InputFile inputFile, int line, String label) {
- Preconditions.checkArgument(line > 0 && line <= inputFile.lines(), "Invalid " + label + ": " + line + ". File " + inputFile + " has " + inputFile.lines()
- + " lines.");
- }
-
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java
index e80a5627c41..32932a71cd1 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java
@@ -29,13 +29,11 @@ import java.util.Set;
import javax.annotation.Nonnull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputComponent;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.TextRange;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.measure.MetricFinder;
-import org.sonar.api.batch.rule.ActiveRules;
import org.sonar.api.batch.sensor.coverage.CoverageType;
import org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage;
import org.sonar.api.batch.sensor.cpd.internal.DefaultCpdTokens;
@@ -75,7 +73,7 @@ public class DefaultSensorStorage implements SensorStorage {
// Computed by LinesSensor
CoreMetrics.LINES);
- private static final List<String> DEPRECATED_METRICS_KEYS = Arrays.<String>asList(
+ private static final List<String> DEPRECATED_METRICS_KEYS = Arrays.asList(
CoreMetrics.DEPENDENCY_MATRIX_KEY,
CoreMetrics.DIRECTORY_CYCLES_KEY,
CoreMetrics.DIRECTORY_EDGES_WEIGHT_KEY,
@@ -99,7 +97,7 @@ public class DefaultSensorStorage implements SensorStorage {
private final Settings settings;
public DefaultSensorStorage(MetricFinder metricFinder, ModuleIssues moduleIssues,
- Settings settings, FileSystem fs, ActiveRules activeRules,
+ Settings settings,
CoverageExclusions coverageExclusions, BatchComponentCache componentCache, ReportPublisher reportPublisher, MeasureCache measureCache, SonarCpdBlockIndex index) {
this.metricFinder = metricFinder;
this.moduleIssues = moduleIssues;
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/sensor/DefaultSensorStorageTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/sensor/DefaultSensorStorageTest.java
index a1c406e2adc..76afdb23661 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/batch/sensor/DefaultSensorStorageTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/sensor/DefaultSensorStorageTest.java
@@ -26,12 +26,9 @@ import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.mockito.ArgumentCaptor;
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DefaultFileSystem;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.fs.internal.DefaultInputModule;
import org.sonar.api.batch.measure.MetricFinder;
-import org.sonar.api.batch.rule.ActiveRules;
-import org.sonar.api.batch.rule.internal.ActiveRulesBuilder;
import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure;
import org.sonar.api.config.Settings;
import org.sonar.api.measures.CoreMetrics;
@@ -60,9 +57,7 @@ public class DefaultSensorStorageTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
- private ActiveRules activeRules;
- private DefaultFileSystem fs;
- private DefaultSensorStorage sensorStorage;
+ private DefaultSensorStorage underTest;
private Settings settings;
private ModuleIssues moduleIssues;
private Project project;
@@ -71,9 +66,7 @@ public class DefaultSensorStorageTest {
private BatchComponentCache resourceCache;
@Before
- public void prepare() throws Exception {
- activeRules = new ActiveRulesBuilder().build();
- fs = new DefaultFileSystem(temp.newFolder().toPath());
+ public void prepare() {
MetricFinder metricFinder = mock(MetricFinder.class);
when(metricFinder.<Integer>findByKey(CoreMetrics.NCLOC_KEY)).thenReturn(CoreMetrics.NCLOC);
when(metricFinder.<String>findByKey(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION_KEY)).thenReturn(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION);
@@ -84,18 +77,18 @@ public class DefaultSensorStorageTest {
CoverageExclusions coverageExclusions = mock(CoverageExclusions.class);
when(coverageExclusions.accept(any(Resource.class), any(Measure.class))).thenReturn(true);
resourceCache = new BatchComponentCache();
- sensorStorage = new DefaultSensorStorage(metricFinder,
- moduleIssues, settings, fs, activeRules, coverageExclusions, resourceCache, mock(ReportPublisher.class), measureCache, mock(SonarCpdBlockIndex.class));
+ underTest = new DefaultSensorStorage(metricFinder,
+ moduleIssues, settings, coverageExclusions, resourceCache, mock(ReportPublisher.class), measureCache, mock(SonarCpdBlockIndex.class));
}
@Test
- public void shouldFailIfUnknowMetric() {
+ public void shouldFailIfUnknownMetric() {
InputFile file = new DefaultInputFile("foo", "src/Foo.php");
thrown.expect(IllegalStateException.class);
thrown.expectMessage("Unknow metric with key: lines");
- sensorStorage.store(new DefaultMeasure()
+ underTest.store(new DefaultMeasure()
.on(file)
.forMetric(CoreMetrics.LINES)
.withValue(10));
@@ -109,7 +102,7 @@ public class DefaultSensorStorageTest {
Resource sonarFile = File.create("src/Foo.php").setEffectiveKey("foo:src/Foo.php");
resourceCache.add(sonarFile, null).setInputComponent(file);
when(measureCache.put(eq(sonarFile), argumentCaptor.capture())).thenReturn(null);
- sensorStorage.store(new DefaultMeasure()
+ underTest.store(new DefaultMeasure()
.on(file)
.forMetric(CoreMetrics.NCLOC)
.withValue(10));
@@ -127,7 +120,7 @@ public class DefaultSensorStorageTest {
ArgumentCaptor<org.sonar.api.measures.Measure> argumentCaptor = ArgumentCaptor.forClass(org.sonar.api.measures.Measure.class);
when(measureCache.put(eq(project), argumentCaptor.capture())).thenReturn(null);
- sensorStorage.store(new DefaultMeasure()
+ underTest.store(new DefaultMeasure()
.on(module)
.forMetric(CoreMetrics.NCLOC)
.withValue(10));