diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-03-18 11:33:43 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-03-18 11:33:54 +0100 |
commit | f9b18cc1aea5d6b80095664248ee18a5afb8a655 (patch) | |
tree | 2e8e40be6c081bfc81ede4269c0d7c584e650a79 /sonar-batch | |
parent | d4cc5ad93f1043e9f992be95dc5b1b1e056ea7c7 (diff) | |
download | sonarqube-f9b18cc1aea5d6b80095664248ee18a5afb8a655.tar.gz sonarqube-f9b18cc1aea5d6b80095664248ee18a5afb8a655.zip |
Fix quality flaws
Diffstat (limited to 'sonar-batch')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java | 10 | ||||
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/rule/RulesProvider.java | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java b/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java index 751aa64eedd..de553d4435f 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java +++ b/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java @@ -107,15 +107,15 @@ public class ModuleIssues { if (issue.severity() == null) { issue.setSeverity(activeRule.severity()); } - if (rule.debtCharacteristic() != null) { - issue.setDebt(calculateDebt(rule, issue.effortToFix())); + DebtRemediationFunction function = rule.debtRemediationFunction(); + if (rule.debtCharacteristic() != null && function != null) { + issue.setDebt(calculateDebt(function, issue.effortToFix(), rule.key())); } } - private Duration calculateDebt(Rule rule, @Nullable Double effortToFix) { - DebtRemediationFunction function = rule.debtRemediationFunction(); + private Duration calculateDebt(DebtRemediationFunction function, @Nullable Double effortToFix, RuleKey ruleKey) { if (DebtRemediationFunction.Type.CONSTANT_ISSUE.equals(function.type()) && effortToFix != null) { - throw new IllegalArgumentException("Rule '" + rule.key() + "' can not use 'Constant/issue' remediation function " + + throw new IllegalArgumentException("Rule '" + ruleKey + "' can not use 'Constant/issue' remediation function " + "because this rule does not have a fixed remediation cost."); } Duration result = Duration.create(0); 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 2d0f1294e8d..75afe603f4f 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 @@ -109,7 +109,7 @@ public class RulesProvider extends ProviderAdapter { if (function != null) { return createDebtRemediationFunction(function, ruleDto.getRemediationFactor(), ruleDto.getRemediationOffset(), durations); } else if (defaultFunction != null) { - return createDebtRemediationFunction(ruleDto.getDefaultRemediationFunction(), ruleDto.getDefaultRemediationFactor(), ruleDto.getDefaultRemediationOffset(), durations); + return createDebtRemediationFunction(defaultFunction, ruleDto.getDefaultRemediationFactor(), ruleDto.getDefaultRemediationOffset(), durations); } else { throw new IllegalStateException(String.format("Remediation function should not be null on rule '%s'", ruleKey)); } |