diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2014-07-21 17:36:30 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2014-07-21 17:42:08 +0200 |
commit | b43267d5415759f54a1fba7bfd502fd5587ef0d9 (patch) | |
tree | fde51904d7a77b4757ea8b68e867b9c6ef319c7a /sonar-batch | |
parent | 2b2c1f3bcfae1af11de717d395b0cdf702782a39 (diff) | |
download | sonarqube-b43267d5415759f54a1fba7bfd502fd5587ef0d9.tar.gz sonarqube-b43267d5415759f54a1fba7bfd502fd5587ef0d9.zip |
SONAR-5389 Rename Analyzer -> Sensor
Diffstat (limited to 'sonar-batch')
10 files changed, 52 insertions, 45 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/AnalyzerMediumTester.java b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java index 9a96da2b2aa..70a509bb22f 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/AnalyzerMediumTester.java +++ b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java @@ -19,14 +19,13 @@ */ package org.sonar.batch.mediumtest; -import org.sonar.api.batch.sensor.issue.Issue; -import org.sonar.api.batch.sensor.measure.Measure; - import org.apache.commons.io.IOUtils; import org.sonar.api.SonarPlugin; import org.sonar.api.batch.bootstrap.ProjectReactor; import org.sonar.api.batch.debt.internal.DefaultDebtModel; import org.sonar.api.batch.fs.InputFile; +import org.sonar.api.batch.sensor.issue.Issue; +import org.sonar.api.batch.sensor.measure.Measure; import org.sonar.api.config.Settings; import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.Metric; @@ -57,63 +56,63 @@ import java.util.List; import java.util.Map; import java.util.Properties; -public class AnalyzerMediumTester { +public class BatchMediumTester { private Batch batch; - public static AnalyzerMediumTesterBuilder builder() { - return new AnalyzerMediumTesterBuilder().registerCoreMetrics(); + public static BatchMediumTesterBuilder builder() { + return new BatchMediumTesterBuilder().registerCoreMetrics(); } - public static class AnalyzerMediumTesterBuilder { + public static class BatchMediumTesterBuilder { private final FakeProjectReferentialsLoader refProvider = new FakeProjectReferentialsLoader(); private final FakeSettingsReferential settingsReferential = new FakeSettingsReferential(); private final FackPluginsReferential pluginsReferential = new FackPluginsReferential(); private final Map<String, String> bootstrapProperties = new HashMap<String, String>(); - public AnalyzerMediumTester build() { - return new AnalyzerMediumTester(this); + public BatchMediumTester build() { + return new BatchMediumTester(this); } - public AnalyzerMediumTesterBuilder registerPlugin(String pluginKey, File location) { + public BatchMediumTesterBuilder registerPlugin(String pluginKey, File location) { pluginsReferential.addPlugin(pluginKey, location); return this; } - public AnalyzerMediumTesterBuilder registerPlugin(String pluginKey, SonarPlugin instance) { + public BatchMediumTesterBuilder registerPlugin(String pluginKey, SonarPlugin instance) { pluginsReferential.addPlugin(pluginKey, instance); return this; } - public AnalyzerMediumTesterBuilder registerCoreMetrics() { + public BatchMediumTesterBuilder registerCoreMetrics() { for (Metric<?> m : CoreMetrics.getMetrics()) { registerMetric(m); } return this; } - public AnalyzerMediumTesterBuilder registerMetric(Metric<?> metric) { + public BatchMediumTesterBuilder registerMetric(Metric<?> metric) { refProvider.add(metric); return this; } - public AnalyzerMediumTesterBuilder addQProfile(String language, String name) { + public BatchMediumTesterBuilder addQProfile(String language, String name) { refProvider.addQProfile(language, name); return this; } - public AnalyzerMediumTesterBuilder addDefaultQProfile(String language, String name) { + public BatchMediumTesterBuilder addDefaultQProfile(String language, String name) { addQProfile(language, name); settingsReferential.globalSettings().put("sonar.profile." + language, name); return this; } - public AnalyzerMediumTesterBuilder bootstrapProperties(Map<String, String> props) { + public BatchMediumTesterBuilder bootstrapProperties(Map<String, String> props) { bootstrapProperties.putAll(props); return this; } - public AnalyzerMediumTesterBuilder activateRule(ActiveRule activeRule) { + public BatchMediumTesterBuilder activateRule(ActiveRule activeRule) { refProvider.addActiveRule(activeRule); return this; } @@ -128,7 +127,7 @@ public class AnalyzerMediumTester { batch.stop(); } - private AnalyzerMediumTester(AnalyzerMediumTesterBuilder builder) { + private BatchMediumTester(BatchMediumTesterBuilder builder) { batch = Batch.builder() .setEnableLoggingConfiguration(true) .addComponents( @@ -169,9 +168,9 @@ public class AnalyzerMediumTester { public static class TaskBuilder { private final Map<String, String> taskProperties = new HashMap<String, String>(); - private AnalyzerMediumTester tester; + private BatchMediumTester tester; - public TaskBuilder(AnalyzerMediumTester tester) { + public TaskBuilder(BatchMediumTester tester) { this.tester = tester; } @@ -246,7 +245,17 @@ public class AnalyzerMediumTester { } public FakeProjectReferentialsLoader add(Metric metric) { - ref.metrics().add(new org.sonar.batch.protocol.input.Metric(metricId, metric.key(), metric.getType().name(), metric.getBestValue(), metric.isOptimizedBestValue())); + ref.metrics().add(new org.sonar.batch.protocol.input.Metric(metricId, + metric.key(), + metric.getType().name(), + metric.getDescription(), + metric.getDirection(), + metric.getName(), + metric.getQualitative(), + metric.getUserManaged(), + metric.getWorstValue(), + metric.getBestValue(), + metric.isOptimizedBestValue())); metricId++; return this; } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/SensorWrapper.java b/sonar-batch/src/main/java/org/sonar/batch/scan/SensorWrapper.java index 617ade05f3f..4deeaa0cf97 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/SensorWrapper.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/SensorWrapper.java @@ -63,6 +63,6 @@ public class SensorWrapper implements org.sonar.api.batch.Sensor { @Override public void analyse(Project module, org.sonar.api.batch.SensorContext context) { - analyzer.analyse(adaptor); + analyzer.execute(adaptor); } } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/AnalyzersExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/AnalyzersExecutor.java index f8b8aef6c70..54e6b1397ac 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan2/AnalyzersExecutor.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/AnalyzersExecutor.java @@ -63,7 +63,7 @@ public class AnalyzersExecutor implements BatchComponent { } private void executeSensor(SensorContext context, Sensor analyzer) { - analyzer.analyse(context); + analyzer.execute(context); } } diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java index d572ef1b383..e2cbc4909de 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java @@ -29,8 +29,8 @@ import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.utils.MessageException; -import org.sonar.batch.mediumtest.AnalyzerMediumTester; -import org.sonar.batch.mediumtest.AnalyzerMediumTester.TaskResult; +import org.sonar.batch.mediumtest.BatchMediumTester; +import org.sonar.batch.mediumtest.BatchMediumTester.TaskResult; import org.sonar.batch.mediumtest.xoo.plugin.XooPlugin; import org.sonar.batch.protocol.input.ActiveRule; @@ -47,7 +47,7 @@ public class FileSystemMediumTest { @Rule public ExpectedException thrown = ExpectedException.none(); - public AnalyzerMediumTester tester = AnalyzerMediumTester.builder() + public BatchMediumTester tester = BatchMediumTester.builder() .registerPlugin("xoo", new XooPlugin()) .addDefaultQProfile("xoo", "Sonar Way") .activateRule(new ActiveRule("xoo", "OneIssuePerLine", "MAJOR", "xoo", "xoo")) diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/IssuesMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/IssuesMediumTest.java index 90ff20508fe..21705209b92 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/IssuesMediumTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/IssuesMediumTest.java @@ -28,8 +28,8 @@ import org.junit.Before; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.api.batch.fs.internal.DefaultInputFile; -import org.sonar.batch.mediumtest.AnalyzerMediumTester; -import org.sonar.batch.mediumtest.AnalyzerMediumTester.TaskResult; +import org.sonar.batch.mediumtest.BatchMediumTester; +import org.sonar.batch.mediumtest.BatchMediumTester.TaskResult; import org.sonar.batch.mediumtest.xoo.plugin.XooPlugin; import org.sonar.batch.protocol.input.ActiveRule; @@ -43,7 +43,7 @@ public class IssuesMediumTest { @org.junit.Rule public TemporaryFolder temp = new TemporaryFolder(); - public AnalyzerMediumTester tester = AnalyzerMediumTester.builder() + public BatchMediumTester tester = BatchMediumTester.builder() .registerPlugin("xoo", new XooPlugin()) .addDefaultQProfile("xoo", "Sonar Way") .activateRule(new ActiveRule("xoo", "OneIssuePerLine", "MAJOR", "xoo", "xoo")) diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java index 975999bd352..bb93ae4b7ba 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java @@ -19,8 +19,6 @@ */ package org.sonar.batch.mediumtest.measures; -import org.sonar.api.batch.sensor.measure.internal.DefaultMeasureBuilder; - import com.google.common.collect.ImmutableMap; import org.apache.commons.io.FileUtils; import org.junit.After; @@ -28,9 +26,10 @@ import org.junit.Before; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.api.batch.fs.internal.DefaultInputFile; +import org.sonar.api.batch.sensor.measure.internal.DefaultMeasureBuilder; import org.sonar.api.measures.CoreMetrics; -import org.sonar.batch.mediumtest.AnalyzerMediumTester; -import org.sonar.batch.mediumtest.AnalyzerMediumTester.TaskResult; +import org.sonar.batch.mediumtest.BatchMediumTester; +import org.sonar.batch.mediumtest.BatchMediumTester.TaskResult; import org.sonar.batch.mediumtest.xoo.plugin.XooPlugin; import java.io.File; @@ -43,7 +42,7 @@ public class MeasuresMediumTest { @org.junit.Rule public TemporaryFolder temp = new TemporaryFolder(); - public AnalyzerMediumTester tester = AnalyzerMediumTester.builder() + public BatchMediumTester tester = BatchMediumTester.builder() .registerPlugin("xoo", new XooPlugin()) .addDefaultQProfile("xoo", "Sonar Way") .bootstrapProperties(ImmutableMap.of("sonar.analysis.mode", "sensor")) diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/xoo/plugin/XooPlugin.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/xoo/plugin/XooPlugin.java index 00bfc6b5a41..70e31407d60 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/xoo/plugin/XooPlugin.java +++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/xoo/plugin/XooPlugin.java @@ -23,7 +23,7 @@ import org.sonar.api.SonarPlugin; import org.sonar.batch.mediumtest.xoo.plugin.base.Xoo; import org.sonar.batch.mediumtest.xoo.plugin.lang.MeasureSensor; import org.sonar.batch.mediumtest.xoo.plugin.lang.ScmActivitySensor; -import org.sonar.batch.mediumtest.xoo.plugin.rule.OneIssuePerLineAnalyzer; +import org.sonar.batch.mediumtest.xoo.plugin.rule.OneIssuePerLineSensor; import java.util.Arrays; import java.util.List; @@ -39,7 +39,7 @@ public final class XooPlugin extends SonarPlugin { Xoo.class, // rules - OneIssuePerLineAnalyzer.class + OneIssuePerLineSensor.class ); } } diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/xoo/plugin/lang/MeasureSensor.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/xoo/plugin/lang/MeasureSensor.java index 2f56da1b7a8..9a4b46afd1a 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/xoo/plugin/lang/MeasureSensor.java +++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/xoo/plugin/lang/MeasureSensor.java @@ -19,16 +19,15 @@ */ package org.sonar.batch.mediumtest.xoo.plugin.lang; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; +import org.sonar.api.batch.fs.InputFile; +import org.sonar.api.batch.measure.MetricFinder; import org.sonar.api.batch.sensor.Sensor; import org.sonar.api.batch.sensor.SensorContext; import org.sonar.api.batch.sensor.SensorDescriptor; import org.sonar.api.batch.sensor.measure.Measure; import org.sonar.api.batch.sensor.measure.MeasureBuilder; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; -import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.measure.MetricFinder; import org.sonar.api.measures.CoreMetrics; import org.sonar.batch.mediumtest.xoo.plugin.base.Xoo; import org.sonar.batch.mediumtest.xoo.plugin.base.XooConstants; @@ -112,7 +111,7 @@ public class MeasureSensor implements Sensor { } @Override - public void analyse(SensorContext context) { + public void execute(SensorContext context) { for (InputFile file : context.fileSystem().inputFiles(context.fileSystem().predicates().hasLanguages(Xoo.KEY))) { processFileMeasures(file, context); } diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/xoo/plugin/lang/ScmActivitySensor.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/xoo/plugin/lang/ScmActivitySensor.java index ecf05f862a2..b3352dba62a 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/xoo/plugin/lang/ScmActivitySensor.java +++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/xoo/plugin/lang/ScmActivitySensor.java @@ -67,7 +67,7 @@ public class ScmActivitySensor implements Sensor { } @Override - public void analyse(SensorContext context) { + public void execute(SensorContext context) { for (InputFile inputFile : fs.inputFiles(fs.predicates().hasLanguage(Xoo.KEY))) { processFile(inputFile); } diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/xoo/plugin/rule/OneIssuePerLineAnalyzer.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/xoo/plugin/rule/OneIssuePerLineSensor.java index f55e7b7bb40..65557983534 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/xoo/plugin/rule/OneIssuePerLineAnalyzer.java +++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/xoo/plugin/rule/OneIssuePerLineSensor.java @@ -31,7 +31,7 @@ import org.sonar.api.rule.RuleKey; import org.sonar.batch.mediumtest.xoo.plugin.base.Xoo; import org.sonar.batch.mediumtest.xoo.plugin.base.XooConstants; -public class OneIssuePerLineAnalyzer implements Sensor { +public class OneIssuePerLineSensor implements Sensor { public static final String RULE_KEY = "OneIssuePerLine"; private static final String EFFORT_TO_FIX_PROPERTY = "sonar.oneIssuePerLine.effortToFix"; @@ -46,7 +46,7 @@ public class OneIssuePerLineAnalyzer implements Sensor { } @Override - public void analyse(SensorContext context) { + public void execute(SensorContext context) { for (InputFile file : context.fileSystem().inputFiles(context.fileSystem().predicates().hasLanguages(Xoo.KEY))) { createIssues(file, context); } |