]> source.dussan.org Git - sonarqube.git/commitdiff
Fix some quality flaws
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 1 Jul 2014 20:55:24 +0000 (22:55 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 1 Jul 2014 21:18:38 +0000 (23:18 +0200)
sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleNormalizer.java
sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java

index f6f273a9e68f5b17b3ad69536f638fe656d86648..ce6f8dc6f1bddf942e5e1d8f95cc08e6c28c0c2d 100644 (file)
@@ -137,8 +137,9 @@ public class ActiveRuleNormalizer extends BaseNormalizer<ActiveRuleDto, ActiveRu
 
       // TODO this should be generated by RegisterRule and modified in DTO.
       String parentKey = null;
-      if (activeRuleDto.getParentId() != null) {
-        ActiveRuleDto parentDto = db.activeRuleDao().getById(session, activeRuleDto.getParentId());
+      Integer parentId = activeRuleDto.getParentId();
+      if (parentId != null) {
+        ActiveRuleDto parentDto = db.activeRuleDao().getById(session, parentId);
         parentKey = parentDto.getKey().toString();
       }
       newRule.put(ActiveRuleField.PARENT_KEY.field(), parentKey);
index e2141f765e119d53a1925b19a67ed3ecc03c79d4..df2756104bceab93efb59d9829eb4a91751d2bef 100644 (file)
@@ -58,7 +58,7 @@ import org.sonar.server.search.QueryOptions;
 import org.sonar.server.search.Result;
 
 import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
+
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -366,8 +366,8 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> {
   }
 
   @Override
-  protected Rule toDoc(@Nullable Map<String, Object> fields) {
-    Preconditions.checkArgument(fields != null, "Cannot construct Rule with null response!!!");
+  protected Rule toDoc(Map<String, Object> fields) {
+    Preconditions.checkNotNull(fields, "Cannot construct Rule with null response");
     return new RuleDoc(fields);
   }