summaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2013-12-03 17:57:54 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2013-12-03 17:57:54 +0100
commit1ff7b7c9b2302379519e18a32309f002a3f66415 (patch)
tree229484d4d2f7d5fb31ac4bdbabf2ba6b7522397c /sonar-batch
parentbd532fb46ebe51e65e0b5d169a39066665749e51 (diff)
downloadsonarqube-1ff7b7c9b2302379519e18a32309f002a3f66415.tar.gz
sonarqube-1ff7b7c9b2302379519e18a32309f002a3f66415.zip
Fix quality flaws
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java22
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/technicaldebt/TechnicalDebtModelLoader.java4
2 files changed, 16 insertions, 10 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java
index fe17bf369e5..c0590c7f8e3 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java
@@ -34,6 +34,8 @@ import org.sonar.api.resources.Resource;
import org.sonar.api.resources.ResourceUtils;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RuleFinder;
+import org.sonar.api.technicaldebt.batch.Characteristic;
+import org.sonar.api.technicaldebt.batch.Requirement;
import org.sonar.api.utils.SonarException;
import org.sonar.core.persistence.MyBatis;
@@ -152,22 +154,26 @@ public final class MeasurePersister {
model.setVariationValue4(measure.getVariation4());
model.setVariationValue5(measure.getVariation5());
model.setUrl(measure.getUrl());
- if (measure.getCharacteristic() != null) {
- model.setCharacteristicId(measure.getCharacteristic().id());
- } else if (measure.getRequirement() != null) {
- model.setCharacteristicId(measure.getRequirement().id());
+ Characteristic characteristic = measure.getCharacteristic();
+ Requirement requirement = measure.getRequirement();
+ if (characteristic != null) {
+ model.setCharacteristicId(characteristic.id());
+ } else if (requirement != null) {
+ model.setCharacteristicId(requirement.id());
}
model.setPersonId(measure.getPersonId());
- if (measure.getValue() != null) {
- model.setValue(measure.getValue().doubleValue());
+ Double value = measure.getValue();
+ if (value != null) {
+ model.setValue(value.doubleValue());
} else {
model.setValue(null);
}
if (measure instanceof RuleMeasure) {
RuleMeasure ruleMeasure = (RuleMeasure) measure;
model.setRulePriority(ruleMeasure.getSeverity());
- if (ruleMeasure.getRule() != null) {
- Rule ruleWithId = ruleFinder.findByKey(ruleMeasure.getRule().getRepositoryKey(), ruleMeasure.getRule().getKey());
+ Rule rule = ruleMeasure.getRule();
+ if (rule != null) {
+ Rule ruleWithId = ruleFinder.findByKey(rule.getRepositoryKey(), rule.getKey());
if (ruleWithId == null) {
throw new SonarException("Can not save a measure with unknown rule " + ruleMeasure);
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/technicaldebt/TechnicalDebtModelLoader.java b/sonar-batch/src/main/java/org/sonar/batch/technicaldebt/TechnicalDebtModelLoader.java
index ba46f1805af..cf11256bac9 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/technicaldebt/TechnicalDebtModelLoader.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/technicaldebt/TechnicalDebtModelLoader.java
@@ -54,7 +54,7 @@ public class TechnicalDebtModelLoader implements BatchComponent {
addRootCharacteristics(model, dtos, characteristicsById);
addCharacteristics(dtos, characteristicsById);
- addRequirements(model, dtos, characteristicsById);
+ addRequirements(dtos, characteristicsById);
return model;
}
@@ -78,7 +78,7 @@ public class TechnicalDebtModelLoader implements BatchComponent {
}
}
- private void addRequirements(DefaultTechnicalDebtModel model, List<CharacteristicDto> dtos, Map<Integer, DefaultCharacteristic> characteristicsById) {
+ private void addRequirements(List<CharacteristicDto> dtos, Map<Integer, DefaultCharacteristic> characteristicsById) {
Map<Integer, Rule> rulesById = rulesById(ruleFinder.findAll(RuleQuery.create()));
for (CharacteristicDto dto : dtos) {
Integer ruleId = dto.getRuleId();