diff options
Diffstat (limited to 'sonar-batch')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java index 9f05d4e5fa0..eeb1c7fd777 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java @@ -19,7 +19,6 @@ */ package org.sonar.batch.rule; -import com.google.common.collect.Maps; import org.sonar.api.batch.Decorator; import org.sonar.api.batch.DecoratorContext; import org.sonar.api.batch.DependsUpon; @@ -66,16 +65,17 @@ public class QProfileEventsDecorator implements Decorator { return; } - // Load current profiles - Measure currentMeasure = context.getMeasure(CoreMetrics.QUALITY_PROFILES); - Map<String, QProfile> currentProfiles = UsedQProfiles.fromJson(currentMeasure.getData()).profilesByKey(); - // Load previous profiles - Map<String, QProfile> previousProfiles = Maps.newHashMap(); Measure previousMeasure = getPreviousMeasure(resource, CoreMetrics.QUALITY_PROFILES); - if (previousMeasure != null && previousMeasure.getData() != null) { - previousProfiles = UsedQProfiles.fromJson(previousMeasure.getData()).profilesByKey(); + if (previousMeasure == null || previousMeasure.getData() == null) { + // first analysis -> do not generate events + return; } + Map<String, QProfile> previousProfiles = UsedQProfiles.fromJson(previousMeasure.getData()).profilesByKey(); + + // Load current profiles + Measure currentMeasure = context.getMeasure(CoreMetrics.QUALITY_PROFILES); + Map<String, QProfile> currentProfiles = UsedQProfiles.fromJson(currentMeasure.getData()).profilesByKey(); // Detect new profiles or updated profiles for (QProfile profile : currentProfiles.values()) { |