From 33a64a5c88d4ed19175112effe4fa53e3e385e27 Mon Sep 17 00:00:00 2001 From: Stephane Gamard Date: Tue, 1 Jul 2014 18:17:51 +0200 Subject: [PATCH] fix quality flaws --- .../org/sonar/server/rule/index/RuleDoc.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/sonar-server/src/main/java/org/sonar/server/rule/index/RuleDoc.java b/sonar-server/src/main/java/org/sonar/server/rule/index/RuleDoc.java index b90b835440a..08e5f919ddd 100644 --- a/sonar-server/src/main/java/org/sonar/server/rule/index/RuleDoc.java +++ b/sonar-server/src/main/java/org/sonar/server/rule/index/RuleDoc.java @@ -34,7 +34,6 @@ import org.sonar.server.search.IndexUtils; import javax.annotation.CheckForNull; import javax.annotation.Nullable; - import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -198,11 +197,13 @@ public class RuleDoc extends BaseDoc implements Rule { @Override @CheckForNull public String debtCharacteristicKey() { - if (getNullableField(RuleNormalizer.RuleField.CHARACTERISTIC.field()) != null) { - if (((String) getNullableField(RuleNormalizer.RuleField.CHARACTERISTIC.field())).isEmpty()) { + String field = RuleNormalizer.RuleField.CHARACTERISTIC.field(); + String value = (String) getNullableField(field); + if (value != null) { + if (value.isEmpty()) { return null; } else { - return (String) getNullableField(RuleNormalizer.RuleField.CHARACTERISTIC.field()); + return value; } } else { return defaultDebtCharacteristicKey(); @@ -212,11 +213,13 @@ public class RuleDoc extends BaseDoc implements Rule { @Override @CheckForNull public String debtSubCharacteristicKey() { - if (getNullableField(RuleNormalizer.RuleField.SUB_CHARACTERISTIC.field()) != null) { - if (((String) getNullableField(RuleNormalizer.RuleField.SUB_CHARACTERISTIC.field())).isEmpty()) { + String field = RuleNormalizer.RuleField.SUB_CHARACTERISTIC.field(); + String value = (String) getNullableField(field); + if (value != null) { + if (value.isEmpty()) { return null; } else { - return (String) getNullableField(RuleNormalizer.RuleField.SUB_CHARACTERISTIC.field()); + return value; } } else { return defaultDebtSubCharacteristicKey(); -- 2.39.5