diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-03-27 08:18:39 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-03-27 08:18:39 +0100 |
commit | 2278719ddc1e4ec5cec66e627d10c4cb1e3012fc (patch) | |
tree | 0cee5c2266631b16c5a1316e42cac8e50926133e | |
parent | fd1fc5ea0d851015dae0f3fe3baf7cbe555b998c (diff) | |
download | sonarqube-2278719ddc1e4ec5cec66e627d10c4cb1e3012fc.tar.gz sonarqube-2278719ddc1e4ec5cec66e627d10c4cb1e3012fc.zip |
Fix quality flaws
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtCharacteristic.java | 3 | ||||
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java | 19 |
2 files changed, 11 insertions, 11 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtCharacteristic.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtCharacteristic.java index 89cadc39aab..d9df13d4d76 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtCharacteristic.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtCharacteristic.java @@ -73,11 +73,12 @@ public class DefaultDebtCharacteristic implements DebtCharacteristic { } @Override + @CheckForNull public Integer order() { return order; } - public DefaultDebtCharacteristic setOrder(Integer order) { + public DefaultDebtCharacteristic setOrder(@Nullable Integer order) { this.order = order; return this; } diff --git a/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java b/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java index 9568feb3a02..4ded6f7098d 100644 --- a/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java +++ b/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java @@ -112,10 +112,11 @@ public class DebtModelBackup implements ServerComponent { List<RuleDebt> rules = newArrayList(); for (RuleDto rule : ruleDao.selectEnablesAndNonManual(session)) { - if ((languageKey == null || languageKey.equals(rule.getLanguage()))) { + if (languageKey == null || languageKey.equals(rule.getLanguage())) { Integer effectiveCharacteristicId = rule.getCharacteristicId() != null ? rule.getCharacteristicId() : rule.getDefaultCharacteristicId(); - if (effectiveCharacteristicId != null && !RuleDto.DISABLED_CHARACTERISTIC_ID.equals(effectiveCharacteristicId)) { - rules.add(toRuleDebt(rule, debtModel.characteristicById(effectiveCharacteristicId).key())); + String effectiveFunction = rule.getRemediationFunction() != null ? rule.getRemediationFunction() : rule.getDefaultRemediationFunction(); + if (!RuleDto.DISABLED_CHARACTERISTIC_ID.equals(effectiveCharacteristicId) && effectiveCharacteristicId != null && effectiveFunction != null) { + rules.add(toRuleDebt(rule, debtModel.characteristicById(effectiveCharacteristicId).key(), effectiveFunction)); } } } @@ -336,17 +337,15 @@ public class DebtModelBackup implements ServerComponent { })); } - private static RuleDebt toRuleDebt(RuleDto rule, String characteristicKey) { - RuleDebt ruleDebt = new RuleDebt().setRuleKey(RuleKey.of(rule.getRepositoryKey(), rule.getRuleKey())); - String function = rule.getRemediationFunction(); + private static RuleDebt toRuleDebt(RuleDto rule, String characteristicKey, String function) { + RuleDebt ruleDebt = new RuleDebt().setRuleKey(RuleKey.of(rule.getRepositoryKey(), rule.getRuleKey())).setCharacteristicKey(characteristicKey); + String coefficient = rule.getRemediationCoefficient(); String offset = rule.getRemediationOffset(); - - String effectiveFunction = function != null ? function : rule.getDefaultRemediationFunction(); String effectiveCoefficient = coefficient != null ? coefficient : rule.getDefaultRemediationCoefficient(); String effectiveOffset = offset != null ? offset : rule.getDefaultRemediationOffset(); - ruleDebt.setCharacteristicKey(characteristicKey); - ruleDebt.setFunction(DebtRemediationFunction.Type.valueOf(effectiveFunction)); + + ruleDebt.setFunction(DebtRemediationFunction.Type.valueOf(function)); ruleDebt.setCoefficient(effectiveCoefficient); ruleDebt.setOffset(effectiveOffset); return ruleDebt; |