diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-04-03 09:33:04 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-04-03 10:44:33 +0200 |
commit | 3fc57d40a6f3b3e896b7417c714ac028f3e38710 (patch) | |
tree | 06531d8c96283911fa979d683484f856e32f9a00 | |
parent | d2cd57b629123d02f9334f0642502f5d5a800d60 (diff) | |
download | sonarqube-3fc57d40a6f3b3e896b7417c714ac028f3e38710.tar.gz sonarqube-3fc57d40a6f3b3e896b7417c714ac028f3e38710.zip |
Move hasCharacteristic() method from RuleDto to RulesProvider
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/rule/RulesProvider.java | 12 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java | 4 |
2 files changed, 11 insertions, 5 deletions
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)) { |