From: Julien Lancelot Date: Thu, 3 Apr 2014 07:33:04 +0000 (+0200) Subject: Move hasCharacteristic() method from RuleDto to RulesProvider X-Git-Tag: 4.3~171 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3fc57d40a6f3b3e896b7417c714ac028f3e38710;p=sonarqube.git Move hasCharacteristic() method from RuleDto to RulesProvider --- diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProvider.java b/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProvider.java index 821cdbe4b3d..1cbf9b1aa5b 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProvider.java +++ b/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProvider.java @@ -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)); + } + } diff --git a/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java b/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java index 7ce85241430..8bb8f4e38b5 100644 --- a/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java +++ b/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java @@ -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)) {