aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-03-17 14:31:56 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-03-17 14:32:04 +0100
commitc7a069f5fd7c65f8840cfea02c0a08cdbb5d7807 (patch)
tree44977f051919cb0230fa92c6ef27e4945f8dfe75 /sonar-server
parente35e1449ffdd0ef15d98df66088a6495e4f6a49d (diff)
downloadsonarqube-c7a069f5fd7c65f8840cfea02c0a08cdbb5d7807.tar.gz
sonarqube-c7a069f5fd7c65f8840cfea02c0a08cdbb5d7807.zip
Fix quality flaws
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/debt/DebtRulesXMLImporter.java29
1 files changed, 17 insertions, 12 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/debt/DebtRulesXMLImporter.java b/sonar-server/src/main/java/org/sonar/server/debt/DebtRulesXMLImporter.java
index 62942a1311a..3beb4daa1e4 100644
--- a/sonar-server/src/main/java/org/sonar/server/debt/DebtRulesXMLImporter.java
+++ b/sonar-server/src/main/java/org/sonar/server/debt/DebtRulesXMLImporter.java
@@ -171,7 +171,7 @@ public class DebtRulesXMLImporter implements ServerExtension {
}
@CheckForNull
- private RuleDebt processRule(RuleKey ruleKey, Properties properties){
+ private RuleDebt processRule(RuleKey ruleKey, Properties properties) {
try {
return createRule(ruleKey, properties);
} catch (DebtRemediationFunction.ValidationException e) {
@@ -189,17 +189,22 @@ public class DebtRulesXMLImporter implements ServerExtension {
Property offsetProperty = properties.offset();
String offset = offsetProperty != null ? offsetProperty.toDuration() : null;
- String functionKey = function.getTextValue();
- if ("linear_threshold".equals(functionKey) && factor != null) {
- LOG.warn(String.format("Linear with threshold function is no longer used, remediation function of '%s' is replaced by linear.", ruleKey));
- return new RuleDebt().setRuleKey(ruleKey).setFunction(DebtRemediationFunction.createLinear(factor));
- } else if ("constant_resource".equals(functionKey)) {
- LOG.warn(String.format("Constant/file function is no longer used, technical debt definitions on '%s' are ignored.", ruleKey));
- } else if (DebtRemediationFunction.Type.CONSTANT_ISSUE.name().toLowerCase().equals(functionKey) && factor != null && offset == null) {
- return new RuleDebt().setRuleKey(ruleKey).setFunction(DebtRemediationFunction.createConstantPerIssue(factor));
- } else {
- return new RuleDebt().setRuleKey(ruleKey).setFunction(DebtRemediationFunction.create(DebtRemediationFunction.Type.valueOf(functionKey.toUpperCase()), factor, offset));
- }
+ return createRuleDebt(ruleKey, function.getTextValue(), factor, offset);
+ }
+ return null;
+ }
+
+ @CheckForNull
+ private RuleDebt createRuleDebt(RuleKey ruleKey, String function, @Nullable String factor, @Nullable String offset) {
+ if ("linear_threshold".equals(function) && factor != null) {
+ LOG.warn(String.format("Linear with threshold function is no longer used, remediation function of '%s' is replaced by linear.", ruleKey));
+ return new RuleDebt().setRuleKey(ruleKey).setFunction(DebtRemediationFunction.createLinear(factor));
+ } else if ("constant_resource".equals(function)) {
+ LOG.warn(String.format("Constant/file function is no longer used, technical debt definitions on '%s' are ignored.", ruleKey));
+ } else if (DebtRemediationFunction.Type.CONSTANT_ISSUE.name().equalsIgnoreCase(function) && factor != null && offset == null) {
+ return new RuleDebt().setRuleKey(ruleKey).setFunction(DebtRemediationFunction.createConstantPerIssue(factor));
+ } else {
+ return new RuleDebt().setRuleKey(ruleKey).setFunction(DebtRemediationFunction.create(DebtRemediationFunction.Type.valueOf(function.toUpperCase()), factor, offset));
}
return null;
}