aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-07-02 09:16:53 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-07-02 09:16:53 +0200
commit93d72d7a45b3e4ffb7098254e7fc61fffeb2417b (patch)
treebc64b2061a58121de091aad406996116b663f2d7 /sonar-server
parente1370aba02820826497f638efb5d0aed47a816ae (diff)
downloadsonarqube-93d72d7a45b3e4ffb7098254e7fc61fffeb2417b.tar.gz
sonarqube-93d72d7a45b3e4ffb7098254e7fc61fffeb2417b.zip
Fix quality flaws
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleNormalizer.java14
-rw-r--r--sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java20
2 files changed, 15 insertions, 19 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleNormalizer.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleNormalizer.java
index ce6f8dc6f1b..3160acf8854 100644
--- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleNormalizer.java
+++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleNormalizer.java
@@ -37,12 +37,7 @@ import org.sonar.server.search.Indexable;
import org.sonar.server.search.es.ListUpdate;
import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
public class ActiveRuleNormalizer extends BaseNormalizer<ActiveRuleDto, ActiveRuleKey> {
@@ -133,6 +128,9 @@ public class ActiveRuleNormalizer extends BaseNormalizer<ActiveRuleDto, ActiveRu
try {
// TODO because DTO uses legacy ID pattern
QualityProfileDto profile = db.qualityProfileDao().getById(activeRuleDto.getProfileId(), session);
+ if (profile == null) {
+ throw new IllegalStateException("Profile is null : " + activeRuleDto.getProfileId());
+ }
newRule.put(ActiveRuleField.PROFILE_KEY.field(), profile.getKey());
// TODO this should be generated by RegisterRule and modified in DTO.
@@ -140,7 +138,9 @@ public class ActiveRuleNormalizer extends BaseNormalizer<ActiveRuleDto, ActiveRu
Integer parentId = activeRuleDto.getParentId();
if (parentId != null) {
ActiveRuleDto parentDto = db.activeRuleDao().getById(session, parentId);
- parentKey = parentDto.getKey().toString();
+ if (parentDto != null) {
+ parentKey = parentDto.getKey().toString();
+ }
}
newRule.put(ActiveRuleField.PARENT_KEY.field(), parentKey);
} finally {
diff --git a/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java b/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java
index b96b5c8a16f..fa5e522f43c 100644
--- a/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java
+++ b/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java
@@ -39,12 +39,7 @@ import org.sonar.server.search.Indexable;
import org.sonar.server.search.es.ListUpdate;
import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> {
@@ -220,20 +215,21 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> {
if (defaultSubCharacteristicId != null) {
CharacteristicDto characteristic, subCharacteristic = null;
subCharacteristic = db.debtCharacteristicDao().selectById(defaultSubCharacteristicId, session);
-
if (subCharacteristic != null) {
Integer characteristicId = subCharacteristic.getParentId();
- characteristic = db.debtCharacteristicDao().selectById(characteristicId);
- if (characteristic != null) {
- update.put(RuleField.DEFAULT_CHARACTERISTIC.field(), characteristic.getKey());
- update.put(RuleField.DEFAULT_SUB_CHARACTERISTIC.field(), subCharacteristic.getKey());
+ if (characteristicId != null) {
+ characteristic = db.debtCharacteristicDao().selectById(characteristicId);
+ if (characteristic != null) {
+ update.put(RuleField.DEFAULT_CHARACTERISTIC.field(), characteristic.getKey());
+ update.put(RuleField.DEFAULT_SUB_CHARACTERISTIC.field(), subCharacteristic.getKey());
+ }
}
}
}
Integer subCharacteristicId = rule.getSubCharacteristicId();
if (subCharacteristicId != null) {
- if (subCharacteristicId == -1) {
+ if (subCharacteristicId.equals(-1)) {
update.put(RuleField.CHARACTERISTIC.field(), DebtCharacteristic.NONE);
update.put(RuleField.SUB_CHARACTERISTIC.field(), DebtCharacteristic.NONE);
} else {