From 93d72d7a45b3e4ffb7098254e7fc61fffeb2417b Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Wed, 2 Jul 2014 09:16:53 +0200 Subject: [PATCH] Fix quality flaws --- .../index/ActiveRuleNormalizer.java | 14 ++++++------- .../server/rule/index/RuleNormalizer.java | 20 ++++++++----------- 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 { @@ -133,6 +128,9 @@ public class ActiveRuleNormalizer extends BaseNormalizer { @@ -220,20 +215,21 @@ public class RuleNormalizer extends BaseNormalizer { 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 { -- 2.39.5