diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2014-06-23 13:54:02 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2014-06-23 15:39:19 +0200 |
commit | 985c7517da8aa61375d03e799caac12e72bd82e5 (patch) | |
tree | a49f8ef22aabe2dc22ac22202ea43662b9ef81af /sonar-batch | |
parent | 7037e987857ce9321ff43c272beb72bb7a5df757 (diff) | |
download | sonarqube-985c7517da8aa61375d03e799caac12e72bd82e5.tar.gz sonarqube-985c7517da8aa61375d03e799caac12e72bd82e5.zip |
SONAR-5389 Fix some issues with analyzer -> sensor compatibility mode
Diffstat (limited to 'sonar-batch')
3 files changed, 21 insertions, 1 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java index 8d0d2692656..a9224cbbf3e 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java @@ -67,6 +67,15 @@ public class BatchExtensionDictionnary extends org.sonar.api.batch.BatchExtensio result.add((T) extension); } } + if (type == Sensor.class) { + // Retrieve Analyzer and wrap then in SensorWrapper + for (Object extension : getExtensions(Analyzer.class)) { + extension = new SensorWrapper((Analyzer) extension, context, analyzerOptimizer); + if (shouldKeep(type, extension, project, matcher)) { + result.add((T) extension); + } + } + } return result; } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/AnalyzerContextAdaptor.java b/sonar-batch/src/main/java/org/sonar/batch/scan/AnalyzerContextAdaptor.java index 4cddc459f4c..bac550fd878 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/AnalyzerContextAdaptor.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/AnalyzerContextAdaptor.java @@ -35,11 +35,15 @@ import org.sonar.api.component.ResourcePerspectives; import org.sonar.api.config.Settings; import org.sonar.api.issue.Issuable; import org.sonar.api.issue.internal.DefaultIssue; +import org.sonar.api.measures.Formula; import org.sonar.api.measures.Measure; import org.sonar.api.measures.MetricFinder; +import org.sonar.api.measures.PersistenceMode; +import org.sonar.api.measures.SumChildDistributionFormula; import org.sonar.api.resources.File; import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; +import org.sonar.api.resources.Scopes; import org.sonar.api.rule.RuleKey; import org.sonar.core.issue.DefaultIssueBuilder; @@ -176,6 +180,13 @@ public class AnalyzerContextAdaptor implements AnalyzerContext { } } if (measure.inputFile() != null) { + Formula formula = measure.metric() instanceof org.sonar.api.measures.Metric ? + ((org.sonar.api.measures.Metric) measure.metric()).getFormula() : null; + if (formula instanceof SumChildDistributionFormula) { + if (!Scopes.isHigherThanOrEquals(Scopes.FILE, ((SumChildDistributionFormula) formula).getMinimumScopeToPersist())) { + measureToSave.setPersistenceMode(PersistenceMode.MEMORY); + } + } sensorContext.saveMeasure(measure.inputFile(), measureToSave); } else { sensorContext.saveMeasure(measureToSave); diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultAnalyzerContext.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultAnalyzerContext.java index 19188321bf0..fe9c898755d 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultAnalyzerContext.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultAnalyzerContext.java @@ -50,7 +50,7 @@ public class DefaultAnalyzerContext implements AnalyzerContext { private final FileSystem fs; private final ActiveRules activeRules; private final IssueFilters issueFilters; - private Rules rules; + private final Rules rules; public DefaultAnalyzerContext(ProjectDefinition def, AnalyzerMeasureCache measureCache, AnalyzerIssueCache issueCache, Settings settings, FileSystem fs, ActiveRules activeRules, IssueFilters issueFilters, Rules rules) { |