diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2014-06-20 14:13:01 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2014-06-20 14:13:33 +0200 |
commit | 904b462c56317b1fb5a616534bd58aa9c9097d0b (patch) | |
tree | c0751ebf83b9e8d1f11a82ac5da0af9ff1f19287 /plugins | |
parent | 845c4a64b09a2f5455e50862f757ed6b3eb32fff (diff) | |
download | sonarqube-904b462c56317b1fb5a616534bd58aa9c9097d0b.tar.gz sonarqube-904b462c56317b1fb5a616534bd58aa9c9097d0b.zip |
Fix some quality flaws
Diffstat (limited to 'plugins')
2 files changed, 13 insertions, 6 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecorator.java index d82a34e6c99..b80221a2a1a 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecorator.java @@ -46,7 +46,6 @@ import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; import org.sonar.api.resources.ResourceUtils; import org.sonar.api.rule.RuleKey; -import org.sonar.api.rules.Rule; import org.sonar.api.rules.RuleFinder; import org.sonar.api.rules.RulePriority; import org.sonar.batch.components.Period; @@ -228,12 +227,11 @@ public class CountUnresolvedIssuesDecorator implements Decorator { } for (RuleKey ruleKey : ruleKeys) { - Rule rule = rulefinder.findByKey(ruleKey); - RuleMeasure measure = RuleMeasure.createForRule(metric, rule, null); + RuleMeasure measure = RuleMeasure.createForRule(metric, ruleKey, null); measure.setSeverity(severity); for (Period period : timeMachineConfiguration.periods()) { int variationIndex = period.getIndex(); - double sum = MeasureUtils.sumOnVariation(true, variationIndex, childMeasuresPerRuleKeys.get(rule.ruleKey())) + countIssues(issuesPerRuleKeys.get(rule.ruleKey()), period); + double sum = MeasureUtils.sumOnVariation(true, variationIndex, childMeasuresPerRuleKeys.get(ruleKey)) + countIssues(issuesPerRuleKeys.get(ruleKey), period); measure.setVariation(variationIndex, sum); } context.saveMeasure(measure); diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java index 46f8f9d93e8..8c8a6b622bf 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java @@ -35,12 +35,15 @@ import org.sonar.api.resources.Project; import org.sonar.api.resources.Qualifiers; import org.sonar.api.resources.Resource; import org.sonar.api.resources.Scopes; +import org.sonar.api.rules.Rule; import org.sonar.api.rules.RuleFinder; import org.sonar.api.technicaldebt.batch.Characteristic; import org.sonar.batch.components.PastMeasuresLoader; import org.sonar.batch.components.PastSnapshot; import org.sonar.batch.components.TimeMachineConfiguration; +import javax.annotation.Nullable; + import java.util.Collection; import java.util.List; import java.util.Map; @@ -108,7 +111,13 @@ public class VariationDecorator implements Decorator { Characteristic characteristic = measure.getCharacteristic(); Integer characteristicId = characteristic != null ? characteristic.id() : null; Integer personId = measure.getPersonId(); - Integer ruleId = measure instanceof RuleMeasure ? ruleFinder.findByKey(((RuleMeasure) measure).ruleKey()).getId() : null; + Integer ruleId = null; + if (measure instanceof RuleMeasure) { + Rule rule = ruleFinder.findByKey(((RuleMeasure) measure).ruleKey()); + if (rule != null) { + ruleId = rule.getId(); + } + } Object[] pastMeasure = pastMeasuresByKey.get(new MeasureKey(metricId, characteristicId, personId, ruleId)); if (updateVariation(measure, pastMeasure, index)) { @@ -144,7 +153,7 @@ public class VariationDecorator implements Decorator { ruleId = PastMeasuresLoader.getRuleId(pastFields); } - MeasureKey(int metricId, Integer characteristicId, Integer personId, Integer ruleId) { + MeasureKey(int metricId, Integer characteristicId, Integer personId, @Nullable Integer ruleId) { this.metricId = metricId; this.characteristicId = characteristicId; this.personId = personId; |