aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2016-05-19 20:01:49 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2016-05-19 20:01:49 +0200
commitd0eacea06f8262e1baf00bf938152a07112b5f8e (patch)
tree081588e264b929bf88ad1280a9ad882a4d4c3755 /sonar-scanner-engine/src
parentb7e5a2a4dd947d856c4fdca0048a29d966dede07 (diff)
downloadsonarqube-d0eacea06f8262e1baf00bf938152a07112b5f8e.tar.gz
sonarqube-d0eacea06f8262e1baf00bf938152a07112b5f8e.zip
Fix quality flaws
Diffstat (limited to 'sonar-scanner-engine/src')
-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
2 files changed, 10 insertions, 19 deletions
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));