]> source.dussan.org Git - sonarqube.git/commitdiff
Move hasCharacteristic() method from RuleDto to RulesProvider
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Thu, 3 Apr 2014 07:33:04 +0000 (09:33 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Thu, 3 Apr 2014 08:44:33 +0000 (10:44 +0200)
sonar-batch/src/main/java/org/sonar/batch/rule/RulesProvider.java
sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java

index 821cdbe4b3dc1d7d5eae183739e8d10c6c989a15..1cbf9b1aa5b53c5f20a734028d9310fb0dcdff93 100644 (file)
@@ -79,7 +79,7 @@ public class RulesProvider extends ProviderAdapter {
         .setStatus(RuleStatus.valueOf(ruleDto.getStatus()));
       // TODO should we set metadata ?
 
-      if (ruleDto.hasCharacteristic()) {
+      if (hasCharacteristic(ruleDto)) {
         newRule.setDebtCharacteristic(effectiveCharacteristic(ruleDto, ruleKey, debtModel).key());
         newRule.setDebtRemediationFunction(effectiveFunction(ruleDto, ruleKey, durations));
       }
@@ -121,4 +121,14 @@ public class RulesProvider extends ProviderAdapter {
       offset != null ? durations.decode(offset) : null);
   }
 
+  /**
+   * Return true is the characteristic has not been overridden and a default characteristic is existing or
+   * if the characteristic has been overridden but is not disabled
+   */
+  private boolean hasCharacteristic(RuleDto ruleDto){
+    Integer subCharacteristicId = ruleDto.getSubCharacteristicId();
+    return (subCharacteristicId == null && ruleDto.getDefaultSubCharacteristicId() != null) ||
+      (subCharacteristicId != null && !RuleDto.DISABLED_CHARACTERISTIC_ID.equals(subCharacteristicId));
+  }
+
 }
index 7ce8524143074f10a3cc483c7b1887a1c6e081a7..8bb8f4e38b51e76643340785d18a046228a8936c 100644 (file)
@@ -315,10 +315,6 @@ public final class RuleDto {
     return this;
   }
 
-  public boolean hasCharacteristic(){
-    return (subCharacteristicId != null && !RuleDto.DISABLED_CHARACTERISTIC_ID.equals(subCharacteristicId)) || (subCharacteristicId == null && defaultSubCharacteristicId != null);
-  }
-
   @Override
   public boolean equals(Object obj) {
     if (!(obj instanceof RuleDto)) {