]> source.dussan.org Git - sonarqube.git/commitdiff
Fix quality flaws
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 28 Apr 2014 11:36:14 +0000 (13:36 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 28 Apr 2014 11:36:23 +0000 (13:36 +0200)
sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileActiveRuleOperations.java
sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileValidations.java

index b5b00e3b6196b7dbb65dd55152bb03db063ad575..f5d9beb7adc91636d44ce75552923fd25ba36bc0 100644 (file)
@@ -111,8 +111,7 @@ public class QProfileActiveRuleOperations implements ServerComponent {
 
   ActiveRuleDto createActiveRule(int profileId, RuleKey ruleKey, String severity, SqlSession session) {
     RuleDto rule = ruleDao.selectByKey(ruleKey, session);
-    QProfileValidations.checkRuleIsNotNull(rule);
-    return createActiveRule(profileId, rule.getId(), severity, session);
+    return createActiveRule(profileId, QProfileValidations.checkRuleIsNotNull(rule).getId(), severity, session);
   }
 
   private ActiveRuleDto createActiveRule(int profileId, int ruleId, String severity, SqlSession session) {
index 255ead1ddb8188da4c084d794e925c252742cdfa..8d76ca8e00029953ad47366d1a47a06446114875 100644 (file)
@@ -33,21 +33,24 @@ public class QProfileValidations {
     // Only static methods
   }
 
-  public static void checkProfileIsNotNull(@Nullable QualityProfileDto profile) {
+  public static QualityProfileDto checkProfileIsNotNull(@Nullable QualityProfileDto profile) {
     if (profile == null) {
       throw new NotFoundException("This quality profile does not exists.");
     }
+    return profile;
   }
 
-  public static void checkRuleIsNotNull(@Nullable RuleDto rule) {
+  public static RuleDto checkRuleIsNotNull(@Nullable RuleDto rule) {
     if (rule == null) {
       throw new NotFoundException("This rule does not exists.");
     }
+    return rule;
   }
 
-  public static void checkActiveRuleIsNotNull(@Nullable ActiveRuleDto activeRule) {
+  public static ActiveRuleDto checkActiveRuleIsNotNull(@Nullable ActiveRuleDto activeRule) {
     if (activeRule == null) {
       throw new NotFoundException("This active rule does not exists.");
     }
+    return activeRule;
   }
 }