diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-03-08 19:10:08 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-03-10 15:20:12 +0100 |
commit | eaecfdf4c2f3df6e0a11de96b585de603e702c9f (patch) | |
tree | 3e134ed3fb0f867c70ade4f115eaef4bff7eaa7e | |
parent | 3e81655d523661ee43318d2a9f285b7b710528f2 (diff) | |
download | sonarqube-eaecfdf4c2f3df6e0a11de96b585de603e702c9f.tar.gz sonarqube-eaecfdf4c2f3df6e0a11de96b585de603e702c9f.zip |
SONAR-7453 Rename rules remediation function fields in DB
"effort_to_fix_description" becomes "gap_description"
"remediation_coeff" becomes "remediation_gap_mult"
"default_remediation_coeff" becomes "default_remediation_gap_mult"
"remediation_offset" becomes "remediation_base_effort"
"default_remediation_offset" becomes "default_remediation_base_effort"
30 files changed, 321 insertions, 286 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleImpl.java index a094a4c00e1..b7c91f3e5c5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleImpl.java @@ -121,11 +121,11 @@ public class RuleImpl implements Rule { private static DebtRemediationFunction effectiveRemediationFunction(RuleDto dto) { String fn = dto.getRemediationFunction(); if (fn != null) { - return new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.valueOf(fn), dto.getRemediationCoefficient(), dto.getRemediationOffset()); + return new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.valueOf(fn), dto.getRemediationGapMultiplier(), dto.getRemediationBaseEffort()); } String defaultFn = dto.getDefaultRemediationFunction(); if (defaultFn != null) { - return new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.valueOf(defaultFn), dto.getDefaultRemediationCoefficient(), dto.getDefaultRemediationOffset()); + return new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.valueOf(defaultFn), dto.getDefaultRemediationGapMultiplier(), dto.getDefaultRemediationBaseEffort()); } return null; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java b/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java index ad69b0639a4..abb8f896c03 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java +++ b/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java @@ -150,14 +150,14 @@ public class DebtModelBackup { boolean hasDebtDefinition = remediationFunction != null; rule.setDefaultRemediationFunction(hasDebtDefinition ? remediationFunction.type().name() : null); - rule.setDefaultRemediationCoefficient(hasDebtDefinition ? remediationFunction.coefficient() : null); - rule.setDefaultRemediationOffset(hasDebtDefinition ? remediationFunction.offset() : null); + rule.setDefaultRemediationGapMultiplier(hasDebtDefinition ? remediationFunction.coefficient() : null); + rule.setDefaultRemediationBaseEffort(hasDebtDefinition ? remediationFunction.offset() : null); } // Reset overridden debt definitions rule.setRemediationFunction(null); - rule.setRemediationCoefficient(null); - rule.setRemediationOffset(null); + rule.setRemediationGapMultiplier(null); + rule.setRemediationBaseEffort(null); rule.setUpdatedAt(updateDate); dbClient.ruleDao().update(session, rule); } @@ -246,13 +246,13 @@ public class DebtModelBackup { String defaultFunction = rule.getDefaultRemediationFunction(); if (overriddenFunction != null) { ruleDebt.setFunction(overriddenFunction); - ruleDebt.setCoefficient(rule.getRemediationCoefficient()); - ruleDebt.setOffset(rule.getRemediationOffset()); + ruleDebt.setCoefficient(rule.getRemediationGapMultiplier()); + ruleDebt.setOffset(rule.getRemediationBaseEffort()); return ruleDebt; } else if (defaultFunction != null) { ruleDebt.setFunction(defaultFunction); - ruleDebt.setCoefficient(rule.getDefaultRemediationCoefficient()); - ruleDebt.setOffset(rule.getDefaultRemediationOffset()); + ruleDebt.setCoefficient(rule.getDefaultRemediationGapMultiplier()); + ruleDebt.setOffset(rule.getDefaultRemediationBaseEffort()); return ruleDebt; } return null; diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java index 0240aaf7af8..e9dd263c302 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java @@ -176,7 +176,7 @@ public class RegisterRules implements Startable { .setName(ruleDef.name()) .setSeverity(ruleDef.severity()) .setStatus(ruleDef.status()) - .setEffortToFixDescription(ruleDef.effortToFixDescription()) + .setGapDescription(ruleDef.effortToFixDescription()) .setSystemTags(ruleDef.tags()) .setType(RuleType.valueOf(ruleDef.type().name())) .setCreatedAt(system2.now()) @@ -272,16 +272,16 @@ public class RegisterRules implements Startable { dto.setDefaultRemediationFunction(remediationFunction); changed = true; } - if (!StringUtils.equals(dto.getDefaultRemediationCoefficient(), remediationCoefficient)) { - dto.setDefaultRemediationCoefficient(remediationCoefficient); + if (!StringUtils.equals(dto.getDefaultRemediationGapMultiplier(), remediationCoefficient)) { + dto.setDefaultRemediationGapMultiplier(remediationCoefficient); changed = true; } - if (!StringUtils.equals(dto.getDefaultRemediationOffset(), remediationOffset)) { - dto.setDefaultRemediationOffset(remediationOffset); + if (!StringUtils.equals(dto.getDefaultRemediationBaseEffort(), remediationOffset)) { + dto.setDefaultRemediationBaseEffort(remediationOffset); changed = true; } - if (!StringUtils.equals(dto.getEffortToFixDescription(), effortToFixDescription)) { - dto.setEffortToFixDescription(effortToFixDescription); + if (!StringUtils.equals(dto.getGapDescription(), effortToFixDescription)) { + dto.setGapDescription(effortToFixDescription); changed = true; } return changed; @@ -414,16 +414,16 @@ public class RegisterRules implements Startable { customRule.setDefaultRemediationFunction(templateRule.getDefaultRemediationFunction()); changed = true; } - if (!StringUtils.equals(customRule.getDefaultRemediationCoefficient(), templateRule.getDefaultRemediationCoefficient())) { - customRule.setDefaultRemediationCoefficient(templateRule.getDefaultRemediationCoefficient()); + if (!StringUtils.equals(customRule.getDefaultRemediationGapMultiplier(), templateRule.getDefaultRemediationGapMultiplier())) { + customRule.setDefaultRemediationGapMultiplier(templateRule.getDefaultRemediationGapMultiplier()); changed = true; } - if (!StringUtils.equals(customRule.getDefaultRemediationOffset(), templateRule.getDefaultRemediationOffset())) { - customRule.setDefaultRemediationOffset(templateRule.getDefaultRemediationOffset()); + if (!StringUtils.equals(customRule.getDefaultRemediationBaseEffort(), templateRule.getDefaultRemediationBaseEffort())) { + customRule.setDefaultRemediationBaseEffort(templateRule.getDefaultRemediationBaseEffort()); changed = true; } - if (!StringUtils.equals(customRule.getEffortToFixDescription(), templateRule.getEffortToFixDescription())) { - customRule.setEffortToFixDescription(templateRule.getEffortToFixDescription()); + if (!StringUtils.equals(customRule.getGapDescription(), templateRule.getGapDescription())) { + customRule.setGapDescription(templateRule.getGapDescription()); changed = true; } if (customRule.getStatus() != templateRule.getStatus()) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java index d4f3fa32fcb..26affc8228b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java @@ -211,9 +211,9 @@ public class RuleCreator { .setStatus(newRule.status()) .setLanguage(templateRuleDto.getLanguage()) .setDefaultRemediationFunction(templateRuleDto.getDefaultRemediationFunction()) - .setDefaultRemediationCoefficient(templateRuleDto.getDefaultRemediationCoefficient()) - .setDefaultRemediationOffset(templateRuleDto.getDefaultRemediationOffset()) - .setEffortToFixDescription(templateRuleDto.getEffortToFixDescription()) + .setDefaultRemediationGapMultiplier(templateRuleDto.getDefaultRemediationGapMultiplier()) + .setDefaultRemediationBaseEffort(templateRuleDto.getDefaultRemediationBaseEffort()) + .setGapDescription(templateRuleDto.getGapDescription()) .setTags(templateRuleDto.getTags()) .setSystemTags(templateRuleDto.getSystemTags()) .setType(templateRuleDto.getType()) diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleOperations.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleOperations.java index 22849e98244..60846a424d2 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleOperations.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleOperations.java @@ -78,16 +78,16 @@ public class RuleOperations { // New values are the same as the default values -> set overridden values to null if (isRuleDebtSameAsDefaultValues(ruleDto, newFunction, newCoefficient, newOffset)) { ruleDto.setRemediationFunction(null); - ruleDto.setRemediationCoefficient(null); - ruleDto.setRemediationOffset(null); + ruleDto.setRemediationGapMultiplier(null); + ruleDto.setRemediationBaseEffort(null); needUpdate = true; // New values are not the same as the overridden values -> update overridden values with new values } else if (!isRuleDebtSameAsOverriddenValues(ruleDto, newFunction, newCoefficient, newOffset)) { DefaultDebtRemediationFunction debtRemediationFunction = new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.valueOf(newFunction), newCoefficient, newOffset); ruleDto.setRemediationFunction(debtRemediationFunction.type().name()); - ruleDto.setRemediationCoefficient(debtRemediationFunction.coefficient()); - ruleDto.setRemediationOffset(debtRemediationFunction.offset()); + ruleDto.setRemediationGapMultiplier(debtRemediationFunction.coefficient()); + ruleDto.setRemediationBaseEffort(debtRemediationFunction.offset()); needUpdate = true; } @@ -95,8 +95,8 @@ public class RuleOperations { } else { // Rule characteristic is not already disabled -> update it ruleDto.setRemediationFunction(null); - ruleDto.setRemediationCoefficient(null); - ruleDto.setRemediationOffset(null); + ruleDto.setRemediationGapMultiplier(null); + ruleDto.setRemediationBaseEffort(null); needUpdate = true; } @@ -108,13 +108,13 @@ public class RuleOperations { private static boolean isRuleDebtSameAsDefaultValues(RuleDto ruleDto, @Nullable String newFunction, @Nullable String newCoefficient, @Nullable String newOffset) { - return isSameRemediationFunction(newFunction, newCoefficient, newOffset, ruleDto.getDefaultRemediationFunction(), ruleDto.getDefaultRemediationCoefficient(), - ruleDto.getDefaultRemediationOffset()); + return isSameRemediationFunction(newFunction, newCoefficient, newOffset, ruleDto.getDefaultRemediationFunction(), ruleDto.getDefaultRemediationGapMultiplier(), + ruleDto.getDefaultRemediationBaseEffort()); } private static boolean isRuleDebtSameAsOverriddenValues(RuleDto ruleDto, @Nullable String newFunction, @Nullable String newCoefficient, @Nullable String newOffset) { - return isSameRemediationFunction(newFunction, newCoefficient, newOffset, ruleDto.getRemediationFunction(), ruleDto.getRemediationCoefficient(), ruleDto.getRemediationOffset()); + return isSameRemediationFunction(newFunction, newCoefficient, newOffset, ruleDto.getRemediationFunction(), ruleDto.getRemediationGapMultiplier(), ruleDto.getRemediationBaseEffort()); } private static boolean isSameRemediationFunction(@Nullable String newFunction, @Nullable String newCoefficient, @Nullable String newOffset, diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java index 16facc8c011..ad350b9ecf0 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java @@ -186,18 +186,18 @@ public class RuleUpdater { DebtRemediationFunction function = update.getDebtRemediationFunction(); if (function == null) { context.rule.setRemediationFunction(null); - context.rule.setRemediationCoefficient(null); - context.rule.setRemediationOffset(null); + context.rule.setRemediationGapMultiplier(null); + context.rule.setRemediationBaseEffort(null); } else { if (isSameAsDefaultFunction(function, context.rule)) { // reset to default context.rule.setRemediationFunction(null); - context.rule.setRemediationCoefficient(null); - context.rule.setRemediationOffset(null); + context.rule.setRemediationGapMultiplier(null); + context.rule.setRemediationBaseEffort(null); } else { context.rule.setRemediationFunction(function.type().name()); - context.rule.setRemediationCoefficient(function.coefficient()); - context.rule.setRemediationOffset(function.offset()); + context.rule.setRemediationGapMultiplier(function.coefficient()); + context.rule.setRemediationBaseEffort(function.offset()); } } } @@ -220,8 +220,8 @@ public class RuleUpdater { private static boolean isSameAsDefaultFunction(DebtRemediationFunction fn, RuleDto rule) { return new EqualsBuilder() .append(fn.type().name(), rule.getDefaultRemediationFunction()) - .append(fn.coefficient(), rule.getDefaultRemediationCoefficient()) - .append(fn.offset(), rule.getDefaultRemediationOffset()) + .append(fn.coefficient(), rule.getDefaultRemediationGapMultiplier()) + .append(fn.offset(), rule.getDefaultRemediationBaseEffort()) .isEquals(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/RuleMapper.java b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/RuleMapper.java index 5da852ecf80..46cec77119a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/RuleMapper.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/RuleMapper.java @@ -114,8 +114,8 @@ public class RuleMapper { } private static void setEffortToFixDescription(Rules.Rule.Builder ruleResponse, RuleDto ruleDto, Set<String> fieldsToReturn) { - if (shouldReturnField(fieldsToReturn, FIELD_EFFORT_TO_FIX_DESCRIPTION) && ruleDto.getEffortToFixDescription() != null) { - ruleResponse.setEffortToFixDescription(ruleDto.getEffortToFixDescription()); + if (shouldReturnField(fieldsToReturn, FIELD_EFFORT_TO_FIX_DESCRIPTION) && ruleDto.getGapDescription() != null) { + ruleResponse.setEffortToFixDescription(ruleDto.getGapDescription()); } } @@ -294,12 +294,12 @@ public class RuleMapper { @Override public String coefficient() { - return ruleDto.getDefaultRemediationCoefficient(); + return ruleDto.getDefaultRemediationGapMultiplier(); } @Override public String offset() { - return ruleDto.getDefaultRemediationOffset(); + return ruleDto.getDefaultRemediationBaseEffort(); } }; } @@ -318,12 +318,12 @@ public class RuleMapper { @Override public String coefficient() { - return ruleDto.getRemediationCoefficient(); + return ruleDto.getRemediationGapMultiplier(); } @Override public String offset() { - return ruleDto.getRemediationOffset(); + return ruleDto.getRemediationBaseEffort(); } }; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/startup/ClearRulesOverloadedDebt.java b/server/sonar-server/src/main/java/org/sonar/server/startup/ClearRulesOverloadedDebt.java index 87e9e944d5c..7e4e4b2ea1b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/startup/ClearRulesOverloadedDebt.java +++ b/server/sonar-server/src/main/java/org/sonar/server/startup/ClearRulesOverloadedDebt.java @@ -82,8 +82,8 @@ public class ClearRulesOverloadedDebt implements Startable { for (RuleDto rule : dbClient.ruleDao().selectAll(session)) { if (isDebtOverridden(rule)) { rule.setRemediationFunction(null); - rule.setRemediationCoefficient(null); - rule.setRemediationOffset(null); + rule.setRemediationGapMultiplier(null); + rule.setRemediationBaseEffort(null); rule.setUpdatedAt(system2.now()); dbClient.ruleDao().update(session, rule); countClearedRules++; @@ -96,8 +96,8 @@ public class ClearRulesOverloadedDebt implements Startable { } private static boolean isDebtOverridden(RuleDto ruleDto) { - return ruleDto.getRemediationFunction() != null || ruleDto.getRemediationCoefficient() != null - || ruleDto.getRemediationOffset() != null; + return ruleDto.getRemediationFunction() != null || ruleDto.getRemediationGapMultiplier() != null + || ruleDto.getRemediationBaseEffort() != null; } private boolean isSqalePluginInstalled(DbSession session) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java b/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java index 5219db120d3..8059f475f04 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java @@ -119,12 +119,12 @@ public class DebtModelBackupTest { // Rule with overridden debt values new RuleDto().setRepositoryKey("squid").setRuleKey("UselessImportCheck") .setRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.toString()) - .setRemediationCoefficient("2h") - .setRemediationOffset("15min"), + .setRemediationGapMultiplier("2h") + .setRemediationBaseEffort("15min"), // Rule with default debt values new RuleDto().setRepositoryKey("squid").setRuleKey("AvoidNPE") - .setDefaultRemediationFunction("LINEAR").setDefaultRemediationCoefficient("2h") + .setDefaultRemediationFunction("LINEAR").setDefaultRemediationGapMultiplier("2h") )); underTest.backup(); @@ -173,9 +173,9 @@ public class DebtModelBackupTest { // -> Ony offset should be set new RuleDto().setRepositoryKey("squid").setRuleKey("AvoidNPE") .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR.toString()) - .setDefaultRemediationCoefficient("2h") + .setDefaultRemediationGapMultiplier("2h") .setRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE.toString()) - .setRemediationOffset("15min") + .setRemediationBaseEffort("15min") )); underTest.backup(); @@ -198,12 +198,12 @@ public class DebtModelBackupTest { when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck").setLanguage("java") .setRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE.toString()) - .setRemediationOffset("15min"), + .setRemediationBaseEffort("15min"), // Should be ignored new RuleDto().setId(2).setRepositoryKey("checkstyle") .setLanguage("java2") .setRemediationFunction(DebtRemediationFunction.Type.LINEAR.toString()) - .setRemediationCoefficient("2h") + .setRemediationGapMultiplier("2h") )); underTest.backup("java"); @@ -226,10 +226,10 @@ public class DebtModelBackupTest { when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( new RuleDto().setRepositoryKey("squid").setRuleKey("NPE") .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR.toString()) - .setDefaultRemediationCoefficient("2h") + .setDefaultRemediationGapMultiplier("2h") .setRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.toString()) - .setRemediationCoefficient("2h") - .setRemediationOffset("15min") + .setRemediationGapMultiplier("2h") + .setRemediationBaseEffort("15min") )); RulesDefinition.Context context = new RulesDefinition.Context(); @@ -255,13 +255,13 @@ public class DebtModelBackupTest { RuleDto rule = ruleCaptor.getValue(); assertThat(rule.getDefaultRemediationFunction()).isEqualTo("LINEAR_OFFSET"); - assertThat(rule.getDefaultRemediationCoefficient()).isEqualTo("4h"); - assertThat(rule.getDefaultRemediationOffset()).isEqualTo("20min"); + assertThat(rule.getDefaultRemediationGapMultiplier()).isEqualTo("4h"); + assertThat(rule.getDefaultRemediationBaseEffort()).isEqualTo("20min"); assertThat(rule.getUpdatedAt()).isEqualTo(now.getTime()); assertThat(rule.getRemediationFunction()).isNull(); - assertThat(rule.getRemediationCoefficient()).isNull(); - assertThat(rule.getRemediationOffset()).isNull(); + assertThat(rule.getRemediationGapMultiplier()).isNull(); + assertThat(rule.getRemediationBaseEffort()).isNull(); assertThat(rule.getUpdatedAt()).isEqualTo(now.getTime()); } @@ -270,10 +270,10 @@ public class DebtModelBackupTest { when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( new RuleDto().setRepositoryKey("squid").setRuleKey("NPE") .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR.toString()) - .setDefaultRemediationCoefficient("2h") + .setDefaultRemediationGapMultiplier("2h") .setRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.toString()) - .setRemediationCoefficient("2h") - .setRemediationOffset("15min") + .setRemediationGapMultiplier("2h") + .setRemediationBaseEffort("15min") )); RulesDefinition.Context context = new RulesDefinition.Context(); @@ -297,8 +297,8 @@ public class DebtModelBackupTest { RuleDto rule = ruleCaptor.getValue(); assertThat(rule.getDefaultRemediationFunction()).isNull(); - assertThat(rule.getDefaultRemediationCoefficient()).isNull(); - assertThat(rule.getDefaultRemediationOffset()).isNull(); + assertThat(rule.getDefaultRemediationGapMultiplier()).isNull(); + assertThat(rule.getDefaultRemediationBaseEffort()).isNull(); assertThat(rule.getUpdatedAt()).isEqualTo(now.getTime()); } @@ -308,13 +308,13 @@ public class DebtModelBackupTest { // Template rule new RuleDto().setId(5).setRepositoryKey("squid").setRuleKey("XPath") .setRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.toString()) - .setRemediationCoefficient("2h") - .setRemediationOffset("15min"), + .setRemediationGapMultiplier("2h") + .setRemediationBaseEffort("15min"), // Custom rule new RuleDto().setId(6).setRepositoryKey("squid").setRuleKey("XPath_1369910135").setTemplateId(5) .setRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.toString()) - .setRemediationCoefficient("2h") - .setRemediationOffset("15min") + .setRemediationGapMultiplier("2h") + .setRemediationBaseEffort("15min") )); RulesDefinition.Context context = new RulesDefinition.Context(); @@ -341,13 +341,13 @@ public class DebtModelBackupTest { assertThat(rule.getId()).isEqualTo(6); assertThat(rule.getDefaultRemediationFunction()).isEqualTo("LINEAR_OFFSET"); - assertThat(rule.getDefaultRemediationCoefficient()).isEqualTo("4h"); - assertThat(rule.getDefaultRemediationOffset()).isEqualTo("20min"); + assertThat(rule.getDefaultRemediationGapMultiplier()).isEqualTo("4h"); + assertThat(rule.getDefaultRemediationBaseEffort()).isEqualTo("20min"); assertThat(rule.getUpdatedAt()).isEqualTo(now.getTime()); assertThat(rule.getRemediationFunction()).isNull(); - assertThat(rule.getRemediationCoefficient()).isNull(); - assertThat(rule.getRemediationOffset()).isNull(); + assertThat(rule.getRemediationGapMultiplier()).isNull(); + assertThat(rule.getRemediationBaseEffort()).isNull(); assertThat(rule.getUpdatedAt()).isEqualTo(now.getTime()); } @@ -373,7 +373,7 @@ public class DebtModelBackupTest { when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck") - .setDefaultRemediationFunction("LINEAR").setDefaultRemediationCoefficient("2h") + .setDefaultRemediationFunction("LINEAR").setDefaultRemediationGapMultiplier("2h") )); underTest.restoreFromXml("<xml/>"); @@ -389,7 +389,7 @@ public class DebtModelBackupTest { public void restore_from_xml_disable_rule_debt_when_not_in_xml_and_rule_have_default_debt_values() { when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck") - .setDefaultRemediationFunction("LINEAR_OFFSET").setDefaultRemediationCoefficient("2h").setDefaultRemediationOffset("15min") + .setDefaultRemediationFunction("LINEAR_OFFSET").setDefaultRemediationGapMultiplier("2h").setDefaultRemediationBaseEffort("15min") )); underTest.restoreFromXml("<xml/>"); @@ -409,11 +409,11 @@ public class DebtModelBackupTest { when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck").setLanguage("java") .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR.toString()) - .setDefaultRemediationCoefficient("2h"), + .setDefaultRemediationGapMultiplier("2h"), // Should be ignored new RuleDto().setId(2).setRepositoryKey("checkstyle").setLanguage("java2") .setRemediationFunction(DebtRemediationFunction.Type.LINEAR.toString()) - .setRemediationCoefficient("2h") + .setRemediationGapMultiplier("2h") )); underTest.restoreFromXml("<xml/>", "java"); @@ -431,10 +431,10 @@ public class DebtModelBackupTest { when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( // Rule does not exits in XML -> debt will be disabled new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck").setLanguage("java") - .setDefaultRemediationFunction("LINEAR").setDefaultRemediationCoefficient("2h") + .setDefaultRemediationFunction("LINEAR").setDefaultRemediationGapMultiplier("2h") .setRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.toString()) - .setRemediationCoefficient("2h") - .setRemediationOffset("15min") + .setRemediationGapMultiplier("2h") + .setRemediationBaseEffort("15min") )); underTest.restoreFromXml("<xml/>", "java"); @@ -469,7 +469,7 @@ public class DebtModelBackupTest { when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck") - .setDefaultRemediationFunction("LINEAR").setDefaultRemediationCoefficient("2h") + .setDefaultRemediationFunction("LINEAR").setDefaultRemediationGapMultiplier("2h") )); when(ruleOperations.updateRule(any(RuleDto.class), anyString(), anyString(), anyString(), eq(session))).thenThrow(IllegalArgumentException.class); diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java index 4fb4f5d0b03..db7037386bb 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java @@ -298,7 +298,7 @@ public class RegisterRulesMediumTest { assertThat(customRule.getSeverityString()).isEqualTo(Severity.BLOCKER); assertThat(customRule.getStatus()).isEqualTo(RuleStatus.BETA); assertThat(customRule.getDefaultRemediationFunction()).isEqualTo(DebtRemediationFunction.Type.LINEAR_OFFSET.name()); - assertThat(customRule.getEffortToFixDescription()).isEqualTo("Effort"); + assertThat(customRule.getGapDescription()).isEqualTo("Effort"); assertThat(ruleIndex.search(new RuleQuery().setKey(customRuleKey.toString()), new SearchOptions()).getTotal()).isEqualTo(1); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java index 4c7ae491e28..6f46e1d31e8 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java @@ -109,8 +109,8 @@ public class RegisterRulesTest { assertThat(rule1.getCreatedAt()).isEqualTo(DATE1.getTime()); assertThat(rule1.getUpdatedAt()).isEqualTo(DATE1.getTime()); assertThat(rule1.getDefaultRemediationFunction()).isEqualTo(DebtRemediationFunction.Type.LINEAR_OFFSET.name()); - assertThat(rule1.getDefaultRemediationCoefficient()).isEqualTo("5d"); - assertThat(rule1.getDefaultRemediationOffset()).isEqualTo("10h"); + assertThat(rule1.getDefaultRemediationGapMultiplier()).isEqualTo("5d"); + assertThat(rule1.getDefaultRemediationBaseEffort()).isEqualTo("10h"); assertThat(rule1.getType()).isEqualTo(RuleType.CODE_SMELL.getDbConstant()); List<RuleParamDto> params = dbClient.ruleDao().selectRuleParamsByRuleKey(dbTester.getSession(), RULE_KEY1); diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java index 47530bb8ddb..e3b6ee24220 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java @@ -107,9 +107,9 @@ public class RuleCreatorMediumTest { assertThat(rule.getLanguage()).isEqualTo("java"); assertThat(rule.getConfigKey()).isEqualTo("S001"); assertThat(rule.getDefaultRemediationFunction()).isEqualTo("LINEAR_OFFSET"); - assertThat(rule.getDefaultRemediationCoefficient()).isEqualTo("1h"); - assertThat(rule.getDefaultRemediationOffset()).isEqualTo("5min"); - assertThat(rule.getEffortToFixDescription()).isEqualTo("desc"); + assertThat(rule.getDefaultRemediationGapMultiplier()).isEqualTo("1h"); + assertThat(rule.getDefaultRemediationBaseEffort()).isEqualTo("5min"); + assertThat(rule.getGapDescription()).isEqualTo("desc"); assertThat(rule.getTags()).containsOnly("usertag1", "usertag2"); assertThat(rule.getSystemTags()).containsOnly("tag1", "tag4"); @@ -514,7 +514,7 @@ public class RuleCreatorMediumTest { assertThat(rule.getStatus()).isEqualTo(RuleStatus.READY); assertThat(rule.getLanguage()).isNull(); assertThat(rule.getConfigKey()).isNull(); - assertThat(rule.getDefaultRemediationOffset()).isNull(); + assertThat(rule.getDefaultRemediationBaseEffort()).isNull(); assertThat(rule.getTags()).isEmpty(); assertThat(rule.getSystemTags()).isEmpty(); @@ -685,9 +685,9 @@ public class RuleCreatorMediumTest { .setLanguage("java") .setConfigKey("S001") .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name()) - .setDefaultRemediationCoefficient("1h") - .setDefaultRemediationOffset("5min") - .setEffortToFixDescription("desc") + .setDefaultRemediationGapMultiplier("1h") + .setDefaultRemediationBaseEffort("5min") + .setGapDescription("desc") .setTags(Sets.newHashSet("usertag1", "usertag2")) .setSystemTags(Sets.newHashSet("tag1", "tag4")) .setCreatedAt(new Date().getTime()) @@ -706,9 +706,9 @@ public class RuleCreatorMediumTest { .setLanguage("java") .setConfigKey("S002") .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name()) - .setDefaultRemediationCoefficient("1h") - .setDefaultRemediationOffset("5min") - .setEffortToFixDescription("desc") + .setDefaultRemediationGapMultiplier("1h") + .setDefaultRemediationBaseEffort("5min") + .setGapDescription("desc") .setCreatedAt(new Date().getTime()) .setUpdatedAt(new Date().getTime()); dao.insert(dbSession, templateRule); @@ -726,9 +726,9 @@ public class RuleCreatorMediumTest { .setLanguage("java") .setConfigKey("S003") .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name()) - .setDefaultRemediationCoefficient("1h") - .setDefaultRemediationOffset("5min") - .setEffortToFixDescription("desc") + .setDefaultRemediationGapMultiplier("1h") + .setDefaultRemediationBaseEffort("5min") + .setGapDescription("desc") .setCreatedAt(new Date().getTime()) .setUpdatedAt(new Date().getTime()); dao.insert(dbSession, templateRule); diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java index ece0b19f3f5..51de3cee65f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java @@ -33,7 +33,6 @@ import org.sonar.db.DbSession; import org.sonar.db.rule.RuleDao; import org.sonar.db.rule.RuleDto; import org.sonar.server.exceptions.BadRequestException; -import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.rule.RuleOperations.RuleChange; import org.sonar.server.rule.index.RuleIndexer; import org.sonar.server.tester.MockUserSession; @@ -77,7 +76,7 @@ public class RuleOperationsTest { @Test public void update_rule() { RuleDto dto = new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck") - .setRemediationFunction("CONSTANT_ISSUE").setRemediationOffset("10min"); + .setRemediationFunction("CONSTANT_ISSUE").setRemediationBaseEffort("10min"); RuleKey ruleKey = RuleKey.of("squid", "UselessImportCheck"); when(ruleDao.selectOrFailByKey(session, ruleKey)).thenReturn(dto); @@ -95,8 +94,8 @@ public class RuleOperationsTest { assertThat(result.getId()).isEqualTo(1); assertThat(result.getRemediationFunction()).isEqualTo("LINEAR_OFFSET"); - assertThat(result.getRemediationCoefficient()).isEqualTo("2h"); - assertThat(result.getRemediationOffset()).isEqualTo("20min"); + assertThat(result.getRemediationGapMultiplier()).isEqualTo("2h"); + assertThat(result.getRemediationBaseEffort()).isEqualTo("20min"); verify(ruleIndexer).index(); } @@ -104,8 +103,8 @@ public class RuleOperationsTest { @Test public void update_rule_set_overridden_values_to_null_when_new_values_are_equals_to_default_values() { RuleDto dto = new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck") - .setRemediationFunction("CONSTANT_ISSUE").setRemediationOffset("10min") - .setDefaultRemediationFunction("CONSTANT_ISSUE").setDefaultRemediationOffset("10min"); + .setRemediationFunction("CONSTANT_ISSUE").setRemediationBaseEffort("10min") + .setDefaultRemediationFunction("CONSTANT_ISSUE").setDefaultRemediationBaseEffort("10min"); RuleKey ruleKey = RuleKey.of("squid", "UselessImportCheck"); when(ruleDao.selectOrFailByKey(session, ruleKey)).thenReturn(dto); @@ -124,14 +123,14 @@ public class RuleOperationsTest { assertThat(result.getId()).isEqualTo(1); assertThat(result.getRemediationFunction()).isNull(); - assertThat(result.getRemediationCoefficient()).isNull(); - assertThat(result.getRemediationOffset()).isNull(); + assertThat(result.getRemediationGapMultiplier()).isNull(); + assertThat(result.getRemediationBaseEffort()).isNull(); } @Test public void not_update_rule_if_same_function() { RuleDto dto = new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck") - .setRemediationFunction("CONSTANT_ISSUE").setRemediationOffset("10min"); + .setRemediationFunction("CONSTANT_ISSUE").setRemediationBaseEffort("10min"); RuleKey ruleKey = RuleKey.of("squid", "UselessImportCheck"); when(ruleDao.selectOrFailByKey(session, ruleKey)).thenReturn(dto); @@ -150,7 +149,7 @@ public class RuleOperationsTest { @Test public void update_rule_set_remediation_function_if_different_from_default_one() { RuleDto dto = new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck") - .setDefaultRemediationFunction("CONSTANT_ISSUE").setDefaultRemediationOffset("10min"); + .setDefaultRemediationFunction("CONSTANT_ISSUE").setDefaultRemediationBaseEffort("10min"); RuleKey ruleKey = RuleKey.of("squid", "UselessImportCheck"); when(ruleDao.selectOrFailByKey(session, ruleKey)).thenReturn(dto); @@ -169,14 +168,14 @@ public class RuleOperationsTest { assertThat(result.getId()).isEqualTo(1); assertThat(result.getRemediationFunction()).isEqualTo("LINEAR"); - assertThat(result.getRemediationOffset()).isNull(); - assertThat(result.getRemediationCoefficient()).isEqualTo("10min"); + assertThat(result.getRemediationBaseEffort()).isNull(); + assertThat(result.getRemediationGapMultiplier()).isEqualTo("10min"); } @Test public void disable_rule_debt_when_update_rule_with_no_function() { RuleDto dto = new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck") - .setDefaultRemediationFunction("CONSTANT_ISSUE").setDefaultRemediationOffset("10min"); + .setDefaultRemediationFunction("CONSTANT_ISSUE").setDefaultRemediationBaseEffort("10min"); RuleKey ruleKey = RuleKey.of("squid", "UselessImportCheck"); when(ruleDao.selectOrFailByKey(session, ruleKey)).thenReturn(dto); @@ -190,14 +189,14 @@ public class RuleOperationsTest { assertThat(result.getId()).isEqualTo(1); assertThat(result.getRemediationFunction()).isNull(); - assertThat(result.getRemediationCoefficient()).isNull(); - assertThat(result.getRemediationOffset()).isNull(); + assertThat(result.getRemediationGapMultiplier()).isNull(); + assertThat(result.getRemediationBaseEffort()).isNull(); } @Test public void fail_to_update_rule_on_invalid_coefficient() { RuleDto dto = new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck") - .setRemediationFunction("LINEAR").setRemediationCoefficient("1h"); + .setRemediationFunction("LINEAR").setRemediationGapMultiplier("1h"); RuleKey ruleKey = RuleKey.of("squid", "UselessImportCheck"); when(ruleDao.selectOrFailByKey(session, ruleKey)).thenReturn(dto); diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterMediumTest.java index ad97535d049..19f30e7692d 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterMediumTest.java @@ -110,8 +110,8 @@ public class RuleUpdaterMediumTest { .setNoteUserLogin("me") .setTags(ImmutableSet.of("tag1")) .setRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE.name()) - .setRemediationCoefficient("1d") - .setRemediationOffset("5min")); + .setRemediationGapMultiplier("1d") + .setRemediationBaseEffort("5min")); dbSession.commit(); RuleUpdate update = RuleUpdate.createForPluginRule(RULE_KEY); @@ -124,8 +124,8 @@ public class RuleUpdaterMediumTest { assertThat(rule.getNoteUserLogin()).isEqualTo("me"); assertThat(rule.getTags()).containsOnly("tag1"); assertThat(rule.getRemediationFunction()).isEqualTo(DebtRemediationFunction.Type.CONSTANT_ISSUE.name()); - assertThat(rule.getRemediationCoefficient()).isEqualTo("1d"); - assertThat(rule.getRemediationOffset()).isEqualTo("5min"); + assertThat(rule.getRemediationGapMultiplier()).isEqualTo("1d"); + assertThat(rule.getRemediationBaseEffort()).isEqualTo("5min"); } @Test @@ -139,8 +139,8 @@ public class RuleUpdaterMediumTest { // the following fields are not supposed to be updated .setTags(ImmutableSet.of("tag1")) .setRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE.name()) - .setRemediationCoefficient("1d") - .setRemediationOffset("5min")); + .setRemediationGapMultiplier("1d") + .setRemediationBaseEffort("5min")); dbSession.commit(); RuleUpdate update = RuleUpdate.createForPluginRule(RULE_KEY); @@ -156,8 +156,8 @@ public class RuleUpdaterMediumTest { // no other changes assertThat(rule.getTags()).containsOnly("tag1"); assertThat(rule.getRemediationFunction()).isEqualTo(DebtRemediationFunction.Type.CONSTANT_ISSUE.name()); - assertThat(rule.getRemediationCoefficient()).isEqualTo("1d"); - assertThat(rule.getRemediationOffset()).isEqualTo("5min"); + assertThat(rule.getRemediationGapMultiplier()).isEqualTo("1d"); + assertThat(rule.getRemediationBaseEffort()).isEqualTo("5min"); } @Test @@ -224,11 +224,11 @@ public class RuleUpdaterMediumTest { public void override_debt() { ruleDao.insert(dbSession, RuleTesting.newDto(RULE_KEY) .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name()) - .setDefaultRemediationCoefficient("1d") - .setDefaultRemediationOffset("5min") + .setDefaultRemediationGapMultiplier("1d") + .setDefaultRemediationBaseEffort("5min") .setRemediationFunction(null) - .setRemediationCoefficient(null) - .setRemediationOffset(null)); + .setRemediationGapMultiplier(null) + .setRemediationBaseEffort(null)); dbSession.commit(); DefaultDebtRemediationFunction fn = new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE, null, "1min"); @@ -240,23 +240,23 @@ public class RuleUpdaterMediumTest { // verify debt is overridden RuleDto rule = ruleDao.selectOrFailByKey(dbSession, RULE_KEY); assertThat(rule.getRemediationFunction()).isEqualTo(DebtRemediationFunction.Type.CONSTANT_ISSUE.name()); - assertThat(rule.getRemediationCoefficient()).isNull(); - assertThat(rule.getRemediationOffset()).isEqualTo("1min"); + assertThat(rule.getRemediationGapMultiplier()).isNull(); + assertThat(rule.getRemediationBaseEffort()).isEqualTo("1min"); assertThat(rule.getDefaultRemediationFunction()).isEqualTo(DebtRemediationFunction.Type.LINEAR_OFFSET.name()); - assertThat(rule.getDefaultRemediationCoefficient()).isEqualTo("1d"); - assertThat(rule.getDefaultRemediationOffset()).isEqualTo("5min"); + assertThat(rule.getDefaultRemediationGapMultiplier()).isEqualTo("1d"); + assertThat(rule.getDefaultRemediationBaseEffort()).isEqualTo("5min"); } @Test public void override_debt_only_offset() { ruleDao.insert(dbSession, RuleTesting.newDto(RULE_KEY) .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR.name()) - .setDefaultRemediationCoefficient("1d") - .setDefaultRemediationOffset(null) + .setDefaultRemediationGapMultiplier("1d") + .setDefaultRemediationBaseEffort(null) .setRemediationFunction(null) - .setRemediationCoefficient(null) - .setRemediationOffset(null)); + .setRemediationGapMultiplier(null) + .setRemediationBaseEffort(null)); dbSession.commit(); RuleUpdate update = RuleUpdate.createForPluginRule(RULE_KEY) @@ -267,23 +267,23 @@ public class RuleUpdaterMediumTest { // verify debt is overridden RuleDto rule = ruleDao.selectOrFailByKey(dbSession, RULE_KEY); assertThat(rule.getRemediationFunction()).isEqualTo(DebtRemediationFunction.Type.LINEAR.name()); - assertThat(rule.getRemediationCoefficient()).isEqualTo("2d"); - assertThat(rule.getRemediationOffset()).isNull(); + assertThat(rule.getRemediationGapMultiplier()).isEqualTo("2d"); + assertThat(rule.getRemediationBaseEffort()).isNull(); assertThat(rule.getDefaultRemediationFunction()).isEqualTo(DebtRemediationFunction.Type.LINEAR.name()); - assertThat(rule.getDefaultRemediationCoefficient()).isEqualTo("1d"); - assertThat(rule.getDefaultRemediationOffset()).isNull(); + assertThat(rule.getDefaultRemediationGapMultiplier()).isEqualTo("1d"); + assertThat(rule.getDefaultRemediationBaseEffort()).isNull(); } @Test public void override_debt_from_linear_with_offset_to_constant() { ruleDao.insert(dbSession, RuleTesting.newDto(RULE_KEY) .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name()) - .setDefaultRemediationCoefficient("1d") - .setDefaultRemediationOffset("5min") + .setDefaultRemediationGapMultiplier("1d") + .setDefaultRemediationBaseEffort("5min") .setRemediationFunction(null) - .setRemediationCoefficient(null) - .setRemediationOffset(null)); + .setRemediationGapMultiplier(null) + .setRemediationBaseEffort(null)); dbSession.commit(); RuleUpdate update = RuleUpdate.createForPluginRule(RULE_KEY) @@ -294,23 +294,23 @@ public class RuleUpdaterMediumTest { // verify debt is overridden RuleDto rule = ruleDao.selectOrFailByKey(dbSession, RULE_KEY); assertThat(rule.getRemediationFunction()).isEqualTo(DebtRemediationFunction.Type.CONSTANT_ISSUE.name()); - assertThat(rule.getRemediationCoefficient()).isNull(); - assertThat(rule.getRemediationOffset()).isEqualTo("10min"); + assertThat(rule.getRemediationGapMultiplier()).isNull(); + assertThat(rule.getRemediationBaseEffort()).isEqualTo("10min"); assertThat(rule.getDefaultRemediationFunction()).isEqualTo(DebtRemediationFunction.Type.LINEAR_OFFSET.name()); - assertThat(rule.getDefaultRemediationCoefficient()).isEqualTo("1d"); - assertThat(rule.getDefaultRemediationOffset()).isEqualTo("5min"); + assertThat(rule.getDefaultRemediationGapMultiplier()).isEqualTo("1d"); + assertThat(rule.getDefaultRemediationBaseEffort()).isEqualTo("5min"); } @Test public void reset_remediation_function() { ruleDao.insert(dbSession, RuleTesting.newDto(RULE_KEY) .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR.name()) - .setDefaultRemediationCoefficient("1d") - .setDefaultRemediationOffset("5min") + .setDefaultRemediationGapMultiplier("1d") + .setDefaultRemediationBaseEffort("5min") .setRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE.name()) - .setRemediationCoefficient(null) - .setRemediationOffset("1min")); + .setRemediationGapMultiplier(null) + .setRemediationBaseEffort("1min")); dbSession.commit(); RuleUpdate update = RuleUpdate.createForPluginRule(RULE_KEY).setDebtRemediationFunction(null); @@ -320,12 +320,12 @@ public class RuleUpdaterMediumTest { // verify debt is coming from default values RuleDto rule = ruleDao.selectOrFailByKey(dbSession, RULE_KEY); assertThat(rule.getDefaultRemediationFunction()).isEqualTo(DebtRemediationFunction.Type.LINEAR.name()); - assertThat(rule.getDefaultRemediationCoefficient()).isEqualTo("1d"); - assertThat(rule.getDefaultRemediationOffset()).isEqualTo("5min"); + assertThat(rule.getDefaultRemediationGapMultiplier()).isEqualTo("1d"); + assertThat(rule.getDefaultRemediationBaseEffort()).isEqualTo("5min"); assertThat(rule.getRemediationFunction()).isNull(); - assertThat(rule.getRemediationCoefficient()).isNull(); - assertThat(rule.getRemediationOffset()).isNull(); + assertThat(rule.getRemediationGapMultiplier()).isNull(); + assertThat(rule.getRemediationBaseEffort()).isNull(); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java index 7293c78c615..a52e8ba57cd 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java @@ -224,11 +224,11 @@ public class SearchActionMediumTest { public void search_debt_rules_with_default_and_overridden_debt_values() throws Exception { ruleDao.insert(dbSession, RuleTesting.newXooX1() .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name()) - .setDefaultRemediationCoefficient("1h") - .setDefaultRemediationOffset("15min") + .setDefaultRemediationGapMultiplier("1h") + .setDefaultRemediationBaseEffort("15min") .setRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name()) - .setRemediationCoefficient("2h") - .setRemediationOffset("25min")); + .setRemediationGapMultiplier("2h") + .setRemediationBaseEffort("25min")); dbSession.commit(); ruleIndexer.index(); @@ -242,11 +242,11 @@ public class SearchActionMediumTest { public void search_debt_rules_with_default_linear_offset_and_overridden_constant_debt() throws Exception { ruleDao.insert(dbSession, RuleTesting.newXooX1() .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name()) - .setDefaultRemediationCoefficient("1h") - .setDefaultRemediationOffset("15min") + .setDefaultRemediationGapMultiplier("1h") + .setDefaultRemediationBaseEffort("15min") .setRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE.name()) - .setRemediationCoefficient(null) - .setRemediationOffset("5min")); + .setRemediationGapMultiplier(null) + .setRemediationBaseEffort("5min")); dbSession.commit(); ruleIndexer.index(); @@ -260,11 +260,11 @@ public class SearchActionMediumTest { public void search_debt_rules_with_default_linear_offset_and_overridden_linear_debt() throws Exception { ruleDao.insert(dbSession, RuleTesting.newXooX1() .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name()) - .setDefaultRemediationCoefficient("1h") - .setDefaultRemediationOffset("15min") + .setDefaultRemediationGapMultiplier("1h") + .setDefaultRemediationBaseEffort("15min") .setRemediationFunction(DebtRemediationFunction.Type.LINEAR.name()) - .setRemediationCoefficient("1h") - .setRemediationOffset(null)); + .setRemediationGapMultiplier("1h") + .setRemediationBaseEffort(null)); dbSession.commit(); ruleIndexer.index(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionMediumTest.java index a74fa604440..538fb438be8 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionMediumTest.java @@ -107,11 +107,11 @@ public class ShowActionMediumTest { .setConfigKey("InternalKeyS001") .setLanguage("xoo") .setDefaultRemediationFunction("LINEAR_OFFSET") - .setDefaultRemediationCoefficient("5d") - .setDefaultRemediationOffset("10h") + .setDefaultRemediationGapMultiplier("5d") + .setDefaultRemediationBaseEffort("10h") .setRemediationFunction(null) - .setRemediationCoefficient(null) - .setRemediationOffset(null); + .setRemediationGapMultiplier(null) + .setRemediationBaseEffort(null); ruleDao.insert(session, ruleDto); session.commit(); session.clearCache(); @@ -134,11 +134,11 @@ public class ShowActionMediumTest { .setConfigKey("InternalKeyS001") .setLanguage("xoo") .setDefaultRemediationFunction(null) - .setDefaultRemediationCoefficient(null) - .setDefaultRemediationOffset(null) + .setDefaultRemediationGapMultiplier(null) + .setDefaultRemediationBaseEffort(null) .setRemediationFunction("LINEAR_OFFSET") - .setRemediationCoefficient("5d") - .setRemediationOffset("10h"); + .setRemediationGapMultiplier("5d") + .setRemediationBaseEffort("10h"); ruleDao.insert(session, ruleDto); session.commit(); session.clearCache(); @@ -158,11 +158,11 @@ public class ShowActionMediumTest { .setConfigKey("InternalKeyS001") .setLanguage("xoo") .setDefaultRemediationFunction("LINEAR") - .setDefaultRemediationCoefficient("5min") - .setDefaultRemediationOffset(null) + .setDefaultRemediationGapMultiplier("5min") + .setDefaultRemediationBaseEffort(null) .setRemediationFunction("LINEAR_OFFSET") - .setRemediationCoefficient("5d") - .setRemediationOffset("10h"); + .setRemediationGapMultiplier("5d") + .setRemediationBaseEffort("10h"); ruleDao.insert(session, ruleDto); session.commit(); session.clearCache(); @@ -183,11 +183,11 @@ public class ShowActionMediumTest { .setConfigKey("InternalKeyS001") .setLanguage("xoo") .setDefaultRemediationFunction(null) - .setDefaultRemediationCoefficient(null) - .setDefaultRemediationOffset(null) + .setDefaultRemediationGapMultiplier(null) + .setDefaultRemediationBaseEffort(null) .setRemediationFunction(null) - .setRemediationCoefficient(null) - .setRemediationOffset(null); + .setRemediationGapMultiplier(null) + .setRemediationBaseEffort(null); ruleDao.insert(session, ruleDto); session.commit(); session.clearCache(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/startup/ClearRulesOverloadedDebtTest.java b/server/sonar-server/src/test/java/org/sonar/server/startup/ClearRulesOverloadedDebtTest.java index ffb53b62375..cd31054a11f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/startup/ClearRulesOverloadedDebtTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/startup/ClearRulesOverloadedDebtTest.java @@ -134,12 +134,12 @@ public class ClearRulesOverloadedDebtTest { RuleDto ruleDto = ruleDao.selectOrFailByKey(dbSession, ruleKey); assertThat(ruleDto.getRemediationFunction()).isNull(); - assertThat(ruleDto.getRemediationCoefficient()).isNull(); - assertThat(ruleDto.getRemediationOffset()).isNull(); + assertThat(ruleDto.getRemediationGapMultiplier()).isNull(); + assertThat(ruleDto.getRemediationBaseEffort()).isNull(); } private RuleDto insertRuleDto(RuleKey ruleKey, @Nullable String function, @Nullable String coeff, @Nullable String offset) { - RuleDto ruleDto = RuleTesting.newDto(ruleKey).setRemediationFunction(function).setRemediationOffset(offset).setRemediationCoefficient(coeff); + RuleDto ruleDto = RuleTesting.newDto(ruleKey).setRemediationFunction(function).setRemediationBaseEffort(offset).setRemediationGapMultiplier(coeff); ruleDao.insert(dbSession, ruleDto ); diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistIssuesStepTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistIssuesStepTest/shared.xml index 450f750caf0..5dba31fbc10 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistIssuesStepTest/shared.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistIssuesStepTest/shared.xml @@ -4,9 +4,9 @@ plugin_config_key="[null]" priority="0" is_template="[true]" language="xoo" template_id="[null]" note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]" remediation_function="LINEAR" default_remediation_function="LINEAR_OFFSET" - remediation_coeff="1h" default_remediation_coeff="5d" - remediation_offset="5min" default_remediation_offset="10h" - effort_to_fix_description="[null]" description_format="MARKDOWN" + remediation_gap_mult="1h" default_remediation_gap_mult="5d" + remediation_base_effort="5min" default_remediation_base_effort="10h" + gap_description="[null]" description_format="MARKDOWN" tags="[null]" system_tags="[null]" created_at="1500000000000" updated_at="1500000000000" /> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupMediumTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupMediumTest/shared.xml index f43e773b86e..f6cdc7f6fb4 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupMediumTest/shared.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupMediumTest/shared.xml @@ -12,9 +12,9 @@ plugin_config_key="NewConfigKey" priority="0" is_template="[true]" language="dart" template_id="3" note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]" remediation_function="LINEAR" default_remediation_function="LINEAR_OFFSET" - remediation_coeff="1h" default_remediation_coeff="5d" - remediation_offset="5min" default_remediation_offset="10h" - effort_to_fix_description="squid.S115.effortToFix" description_format="MARKDOWN" + remediation_gap_mult="1h" default_remediation_gap_mult="5d" + remediation_base_effort="5min" default_remediation_base_effort="10h" + gap_description="squid.S115.effortToFix" description_format="MARKDOWN" created_at="150000" updated_at="150000" /> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1117_rename_rules_columns.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1117_rename_rules_columns.rb new file mode 100644 index 00000000000..f8471b7c774 --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1117_rename_rules_columns.rb @@ -0,0 +1,35 @@ +# +# SonarQube, open source software quality management tool. +# Copyright (C) 2008-2014 SonarSource +# mailto:contact AT sonarsource DOT com +# +# SonarQube is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# SonarQube is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +# +# SonarQube 5.5 +# SONAR-7453 +# +class RenameRulesColumns < ActiveRecord::Migration + + def self.up + rename_column 'rules', 'effort_to_fix_description', 'gap_description' + rename_column 'rules', 'remediation_coeff', 'remediation_gap_mult' + rename_column 'rules', 'default_remediation_coeff', 'default_remediation_gap_mult' + rename_column 'rules', 'remediation_offset', 'remediation_base_effort' + rename_column 'rules', 'default_remediation_offset', 'default_remediation_base_effort' + end + +end diff --git a/sonar-db/src/main/java/org/sonar/db/rule/RuleDto.java b/sonar-db/src/main/java/org/sonar/db/rule/RuleDto.java index 6f8bca7fd5e..41115748c70 100644 --- a/sonar-db/src/main/java/org/sonar/db/rule/RuleDto.java +++ b/sonar-db/src/main/java/org/sonar/db/rule/RuleDto.java @@ -61,11 +61,11 @@ public class RuleDto { private Date noteUpdatedAt; private String remediationFunction; private String defaultRemediationFunction; - private String remediationCoefficient; - private String defaultRemediationCoefficient; - private String remediationOffset; - private String defaultRemediationOffset; - private String effortToFixDescription; + private String remediationGapMultiplier; + private String defaultRemediationGapMultiplier; + private String remediationBaseEffort; + private String defaultRemediationBaseEffort; + private String gapDescription; private String tags; private String systemTags; private int type; @@ -262,52 +262,52 @@ public class RuleDto { } @CheckForNull - public String getRemediationCoefficient() { - return remediationCoefficient; + public String getRemediationGapMultiplier() { + return remediationGapMultiplier; } - public RuleDto setRemediationCoefficient(@Nullable String remediationCoefficient) { - this.remediationCoefficient = remediationCoefficient; + public RuleDto setRemediationGapMultiplier(@Nullable String remediationGapMultiplier) { + this.remediationGapMultiplier = remediationGapMultiplier; return this; } @CheckForNull - public String getDefaultRemediationCoefficient() { - return defaultRemediationCoefficient; + public String getDefaultRemediationGapMultiplier() { + return defaultRemediationGapMultiplier; } - public RuleDto setDefaultRemediationCoefficient(@Nullable String defaultRemediationCoefficient) { - this.defaultRemediationCoefficient = defaultRemediationCoefficient; + public RuleDto setDefaultRemediationGapMultiplier(@Nullable String defaultRemediationGapMultiplier) { + this.defaultRemediationGapMultiplier = defaultRemediationGapMultiplier; return this; } @CheckForNull - public String getRemediationOffset() { - return remediationOffset; + public String getRemediationBaseEffort() { + return remediationBaseEffort; } - public RuleDto setRemediationOffset(@Nullable String remediationOffset) { - this.remediationOffset = remediationOffset; + public RuleDto setRemediationBaseEffort(@Nullable String remediationBaseEffort) { + this.remediationBaseEffort = remediationBaseEffort; return this; } @CheckForNull - public String getDefaultRemediationOffset() { - return defaultRemediationOffset; + public String getDefaultRemediationBaseEffort() { + return defaultRemediationBaseEffort; } - public RuleDto setDefaultRemediationOffset(@Nullable String defaultRemediationOffset) { - this.defaultRemediationOffset = defaultRemediationOffset; + public RuleDto setDefaultRemediationBaseEffort(@Nullable String defaultRemediationBaseEffort) { + this.defaultRemediationBaseEffort = defaultRemediationBaseEffort; return this; } @CheckForNull - public String getEffortToFixDescription() { - return effortToFixDescription; + public String getGapDescription() { + return gapDescription; } - public RuleDto setEffortToFixDescription(@Nullable String s) { - this.effortToFixDescription = s; + public RuleDto setGapDescription(@Nullable String s) { + this.gapDescription = s; return this; } diff --git a/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java b/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java index 8cdd6772ce2..83e52658375 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java +++ b/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java @@ -29,7 +29,7 @@ import org.sonar.db.MyBatis; public class DatabaseVersion { - public static final int LAST_VERSION = 1116; + public static final int LAST_VERSION = 1117; /** * The minimum supported version which can be upgraded. Lower diff --git a/sonar-db/src/main/resources/org/sonar/db/rule/RuleMapper.xml b/sonar-db/src/main/resources/org/sonar/db/rule/RuleMapper.xml index 3f4aec95f3d..00924617ab7 100644 --- a/sonar-db/src/main/resources/org/sonar/db/rule/RuleMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/rule/RuleMapper.xml @@ -22,11 +22,11 @@ r.note_updated_at as "noteUpdatedAt", r.remediation_function as "remediationFunction", r.default_remediation_function as "defaultRemediationFunction", - r.remediation_coeff as "remediationCoefficient", - r.default_remediation_coeff as "defaultRemediationCoefficient", - r.remediation_offset as "remediationOffset", - r.default_remediation_offset as "defaultRemediationOffset", - r.effort_to_fix_description as "effortToFixDescription", + r.remediation_gap_mult as "remediationGapMultiplier", + r.default_remediation_gap_mult as "defaultRemediationGapMultiplier", + r.remediation_base_effort as "remediationBaseEffort", + r.default_remediation_base_effort as "defaultRemediationBaseEffort", + r.gap_description as "gapDescription", r.tags as "tagsField", r.system_tags as "systemTagsField", r.rule_type as "type", @@ -130,11 +130,11 @@ note_updated_at=#{noteUpdatedAt}, remediation_function=#{remediationFunction}, default_remediation_function=#{defaultRemediationFunction}, - remediation_coeff=#{remediationCoefficient}, - default_remediation_coeff=#{defaultRemediationCoefficient}, - remediation_offset=#{remediationOffset}, - default_remediation_offset=#{defaultRemediationOffset}, - effort_to_fix_description=#{effortToFixDescription}, + remediation_gap_mult=#{remediationGapMultiplier}, + default_remediation_gap_mult=#{defaultRemediationGapMultiplier}, + remediation_base_effort=#{remediationBaseEffort}, + default_remediation_base_effort=#{defaultRemediationBaseEffort}, + gap_description=#{gapDescription}, tags=#{tagsField}, system_tags=#{systemTagsField}, rule_type=#{type}, @@ -146,8 +146,8 @@ (plugin_rule_key, plugin_name, description, description_format, status, name, plugin_config_key, priority, is_template, language, template_id, remediation_function, default_remediation_function, - remediation_coeff, default_remediation_coeff, remediation_offset, default_remediation_offset, - effort_to_fix_description, tags, system_tags, rule_type, note_data, note_user_login, note_created_at, note_updated_at, + remediation_gap_mult, default_remediation_gap_mult, remediation_base_effort, default_remediation_base_effort, + gap_description, tags, system_tags, rule_type, note_data, note_user_login, note_created_at, note_updated_at, created_at, updated_at) </sql> @@ -157,8 +157,8 @@ values (#{ruleKey}, #{repositoryKey}, #{description}, #{descriptionFormat}, #{status}, #{name}, #{configKey}, #{severity}, #{isTemplate}, #{language}, #{templateId}, #{remediationFunction}, #{defaultRemediationFunction}, - #{remediationCoefficient}, #{defaultRemediationCoefficient}, #{remediationOffset}, #{defaultRemediationOffset}, - #{effortToFixDescription}, #{tagsField}, #{systemTagsField}, #{type,jdbcType=INTEGER}, #{noteData}, #{noteUserLogin}, #{noteCreatedAt}, + #{remediationGapMultiplier}, #{defaultRemediationGapMultiplier}, #{remediationBaseEffort}, #{defaultRemediationBaseEffort}, + #{gapDescription}, #{tagsField}, #{systemTagsField}, #{type,jdbcType=INTEGER}, #{noteData}, #{noteUserLogin}, #{noteCreatedAt}, #{noteUpdatedAt}, #{createdAt}, #{updatedAt}) </insert> diff --git a/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql b/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql index 99f1f1b0bd7..cc1d19832fa 100644 --- a/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql +++ b/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql @@ -394,6 +394,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1113'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1114'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1115'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1116'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1117'); INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, EXTERNAL_IDENTITY, EXTERNAL_IDENTITY_PROVIDER, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'admin', 'sonarqube', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '1418215735482', '1418215735482', null, null); ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2; diff --git a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl index 8a8677eb8ad..a7111f6dad0 100644 --- a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl +++ b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl @@ -115,11 +115,11 @@ CREATE TABLE "RULES" ( "NOTE_UPDATED_AT" TIMESTAMP, "REMEDIATION_FUNCTION" VARCHAR(20), "DEFAULT_REMEDIATION_FUNCTION" VARCHAR(20), - "REMEDIATION_COEFF" VARCHAR(20), - "DEFAULT_REMEDIATION_COEFF" VARCHAR(20), - "REMEDIATION_OFFSET" VARCHAR(20), - "DEFAULT_REMEDIATION_OFFSET" VARCHAR(20), - "EFFORT_TO_FIX_DESCRIPTION" VARCHAR(4000), + "REMEDIATION_GAP_MULT" VARCHAR(20), + "DEFAULT_REMEDIATION_GAP_MULT" VARCHAR(20), + "REMEDIATION_BASE_EFFORT" VARCHAR(20), + "DEFAULT_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), "TAGS" VARCHAR(4000), "SYSTEM_TAGS" VARCHAR(4000), "RULE_TYPE" TINYINT, diff --git a/sonar-db/src/test/java/org/sonar/db/rule/RuleDaoTest.java b/sonar-db/src/test/java/org/sonar/db/rule/RuleDaoTest.java index a563b721ea5..cf40b8abf74 100644 --- a/sonar-db/src/test/java/org/sonar/db/rule/RuleDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/rule/RuleDaoTest.java @@ -136,11 +136,11 @@ public class RuleDaoTest { assertThat(ruleDto.getNoteData()).isEqualTo("Rule note with accents \u00e9\u00e8\u00e0"); assertThat(ruleDto.getRemediationFunction()).isEqualTo("LINEAR"); assertThat(ruleDto.getDefaultRemediationFunction()).isEqualTo("LINEAR_OFFSET"); - assertThat(ruleDto.getRemediationCoefficient()).isEqualTo("1h"); - assertThat(ruleDto.getDefaultRemediationCoefficient()).isEqualTo("5d"); - assertThat(ruleDto.getRemediationOffset()).isEqualTo("5min"); - assertThat(ruleDto.getDefaultRemediationOffset()).isEqualTo("10h"); - assertThat(ruleDto.getEffortToFixDescription()).isEqualTo("squid.S115.effortToFix"); + assertThat(ruleDto.getRemediationGapMultiplier()).isEqualTo("1h"); + assertThat(ruleDto.getDefaultRemediationGapMultiplier()).isEqualTo("5d"); + assertThat(ruleDto.getRemediationBaseEffort()).isEqualTo("5min"); + assertThat(ruleDto.getDefaultRemediationBaseEffort()).isEqualTo("10h"); + assertThat(ruleDto.getGapDescription()).isEqualTo("squid.S115.effortToFix"); } @Test @@ -218,11 +218,11 @@ public class RuleDaoTest { .setNoteUpdatedAt(DateUtils.parseDate("2013-12-20")) .setRemediationFunction(DebtRemediationFunction.Type.LINEAR.toString()) .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.toString()) - .setRemediationCoefficient("1h") - .setDefaultRemediationCoefficient("5d") - .setRemediationOffset("5min") - .setDefaultRemediationOffset("10h") - .setEffortToFixDescription("squid.S115.effortToFix") + .setRemediationGapMultiplier("1h") + .setDefaultRemediationGapMultiplier("5d") + .setRemediationBaseEffort("5min") + .setDefaultRemediationBaseEffort("10h") + .setGapDescription("squid.S115.effortToFix") .setTags(newHashSet("tag1", "tag2")) .setSystemTags(newHashSet("systag1", "systag2")) .setType(RuleType.BUG) @@ -250,11 +250,11 @@ public class RuleDaoTest { assertThat(ruleDto.getNoteUpdatedAt()).isNotNull(); assertThat(ruleDto.getRemediationFunction()).isEqualTo("LINEAR"); assertThat(ruleDto.getDefaultRemediationFunction()).isEqualTo("LINEAR_OFFSET"); - assertThat(ruleDto.getRemediationCoefficient()).isEqualTo("1h"); - assertThat(ruleDto.getDefaultRemediationCoefficient()).isEqualTo("5d"); - assertThat(ruleDto.getRemediationOffset()).isEqualTo("5min"); - assertThat(ruleDto.getDefaultRemediationOffset()).isEqualTo("10h"); - assertThat(ruleDto.getEffortToFixDescription()).isEqualTo("squid.S115.effortToFix"); + assertThat(ruleDto.getRemediationGapMultiplier()).isEqualTo("1h"); + assertThat(ruleDto.getDefaultRemediationGapMultiplier()).isEqualTo("5d"); + assertThat(ruleDto.getRemediationBaseEffort()).isEqualTo("5min"); + assertThat(ruleDto.getDefaultRemediationBaseEffort()).isEqualTo("10h"); + assertThat(ruleDto.getGapDescription()).isEqualTo("squid.S115.effortToFix"); assertThat(ruleDto.getTags()).containsOnly("tag1", "tag2"); assertThat(ruleDto.getSystemTags()).containsOnly("systag1", "systag2"); assertThat(ruleDto.getType()).isEqualTo(RuleType.BUG.getDbConstant()); @@ -285,11 +285,11 @@ public class RuleDaoTest { .setNoteUpdatedAt(DateUtils.parseDate("2013-12-20")) .setRemediationFunction(DebtRemediationFunction.Type.LINEAR.toString()) .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.toString()) - .setRemediationCoefficient("1h") - .setDefaultRemediationCoefficient("5d") - .setRemediationOffset("5min") - .setDefaultRemediationOffset("10h") - .setEffortToFixDescription("squid.S115.effortToFix") + .setRemediationGapMultiplier("1h") + .setDefaultRemediationGapMultiplier("5d") + .setRemediationBaseEffort("5min") + .setDefaultRemediationBaseEffort("10h") + .setGapDescription("squid.S115.effortToFix") .setTags(newHashSet("tag1", "tag2")) .setSystemTags(newHashSet("systag1", "systag2")) .setType(RuleType.BUG) @@ -316,11 +316,11 @@ public class RuleDaoTest { assertThat(ruleDto.getNoteUpdatedAt()).isNotNull(); assertThat(ruleDto.getRemediationFunction()).isEqualTo("LINEAR"); assertThat(ruleDto.getDefaultRemediationFunction()).isEqualTo("LINEAR_OFFSET"); - assertThat(ruleDto.getRemediationCoefficient()).isEqualTo("1h"); - assertThat(ruleDto.getDefaultRemediationCoefficient()).isEqualTo("5d"); - assertThat(ruleDto.getRemediationOffset()).isEqualTo("5min"); - assertThat(ruleDto.getDefaultRemediationOffset()).isEqualTo("10h"); - assertThat(ruleDto.getEffortToFixDescription()).isEqualTo("squid.S115.effortToFix"); + assertThat(ruleDto.getRemediationGapMultiplier()).isEqualTo("1h"); + assertThat(ruleDto.getDefaultRemediationGapMultiplier()).isEqualTo("5d"); + assertThat(ruleDto.getRemediationBaseEffort()).isEqualTo("5min"); + assertThat(ruleDto.getDefaultRemediationBaseEffort()).isEqualTo("10h"); + assertThat(ruleDto.getGapDescription()).isEqualTo("squid.S115.effortToFix"); assertThat(ruleDto.getTags()).containsOnly("tag1", "tag2"); assertThat(ruleDto.getSystemTags()).containsOnly("systag1", "systag2"); assertThat(ruleDto.getType()).isEqualTo(RuleType.BUG.getDbConstant()); diff --git a/sonar-db/src/test/java/org/sonar/db/rule/RuleTesting.java b/sonar-db/src/test/java/org/sonar/db/rule/RuleTesting.java index efc99594c9f..ba4bb76b3e8 100644 --- a/sonar-db/src/test/java/org/sonar/db/rule/RuleTesting.java +++ b/sonar-db/src/test/java/org/sonar/db/rule/RuleTesting.java @@ -76,10 +76,10 @@ public class RuleTesting { .setLanguage("js") .setRemediationFunction("LINEAR") .setDefaultRemediationFunction("LINEAR_OFFSET") - .setRemediationCoefficient("1h") - .setDefaultRemediationCoefficient("5d") - .setDefaultRemediationOffset("10h") - .setEffortToFixDescription(ruleKey.repository() + "." + ruleKey.rule() + ".effortToFix") + .setRemediationGapMultiplier("1h") + .setDefaultRemediationGapMultiplier("5d") + .setDefaultRemediationBaseEffort("10h") + .setGapDescription(ruleKey.repository() + "." + ruleKey.rule() + ".effortToFix") .setType(RuleType.CODE_SMELL); } diff --git a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/insert_parameter-result.xml b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/insert_parameter-result.xml index 97c6a59f3f7..6ce3b6763da 100644 --- a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/insert_parameter-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/insert_parameter-result.xml @@ -3,9 +3,9 @@ plugin_config_key="NewConfigKey" priority="0" is_template="[true]" language="dart" template_id="3" note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]" remediation_function="linear" default_remediation_function="linear_offset" - remediation_coeff="1h" default_remediation_coeff="5d" - remediation_offset="5min" default_remediation_offset="10h" - effort_to_fix_description="squid.S115.effortToFix" + remediation_gap_mult="1h" default_remediation_gap_mult="5d" + remediation_base_effort="5min" default_remediation_base_effort="10h" + gap_description="squid.S115.effortToFix" created_at="[null]" updated_at="[null]" /> <rules_parameters id="1" rule_id="1" name="max" param_type="INTEGER" default_value="30" description="My Parameter"/> diff --git a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/insert_parameter.xml b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/insert_parameter.xml index df6a143c5d3..71bd1477503 100644 --- a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/insert_parameter.xml +++ b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/insert_parameter.xml @@ -3,9 +3,9 @@ plugin_config_key="NewConfigKey" priority="0" is_template="[true]" language="dart" template_id="3" note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]" remediation_function="linear" default_remediation_function="linear_offset" - remediation_coeff="1h" default_remediation_coeff="5d" - remediation_offset="5min" default_remediation_offset="10h" - effort_to_fix_description="squid.S115.effortToFix" + remediation_gap_mult="1h" default_remediation_gap_mult="5d" + remediation_base_effort="5min" default_remediation_base_effort="10h" + gap_description="squid.S115.effortToFix" created_at="[null]" updated_at="[null]" /> </dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/selectEnabledAndNonManual.xml b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/selectEnabledAndNonManual.xml index 92cd6f505ba..38512c1508f 100644 --- a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/selectEnabledAndNonManual.xml +++ b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/selectEnabledAndNonManual.xml @@ -3,27 +3,27 @@ <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle" name="Avoid Null" description="Should avoid NULL" status="READY" note_data="Rule note with accents éèà" note_user_login="polop.palap" note_created_at="2013-12-25" description_format="HTML" remediation_function="LINEAR" default_remediation_function="LINEAR_OFFSET" - remediation_coeff="1h" default_remediation_coeff="5d" - remediation_offset="5min" default_remediation_offset="10h" - effort_to_fix_description="squid.S115.effortToFix" + remediation_gap_mult="1h" default_remediation_gap_mult="5d" + remediation_base_effort="5min" default_remediation_base_effort="10h" + gap_description="squid.S115.effortToFix" created_at="1500000000000" updated_at="1600000000000" /> <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="AvoidNull" plugin_name="squid" name="Avoid Null" description="Should avoid NULL" status="REMOVED" note_data="[null]" note_user_login="[null]" note_created_at="[null]" description_format="HTML" remediation_function="[null]" default_remediation_function="[null]" - remediation_coeff="[null]" default_remediation_coeff="[null]" - remediation_offset="[null]" default_remediation_offset="[null]" - effort_to_fix_description="[null]" + remediation_gap_mult="[null]" default_remediation_gap_mult="[null]" + remediation_base_effort="[null]" default_remediation_base_effort="[null]" + gap_description="[null]" created_at="1500000000000" updated_at="1600000000000" /> <rules tags="[null]" system_tags="[null]" id="3" plugin_rule_key="AvoidNull" plugin_name="manual" name="Manual Rule" description="Should not appear" status="READY" note_data="[null]" note_user_login="[null]" note_created_at="[null]" description_format="HTML" remediation_function="[null]" default_remediation_function="[null]" - remediation_coeff="[null]" default_remediation_coeff="[null]" - remediation_offset="[null]" default_remediation_offset="[null]" - effort_to_fix_description="[null]" + remediation_gap_mult="[null]" default_remediation_gap_mult="[null]" + remediation_base_effort="[null]" default_remediation_base_effort="[null]" + gap_description="[null]" created_at="1500000000000" updated_at="1600000000000" /> |