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;
}
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);
}
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;
.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())
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;
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()) {
.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())
// 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;
}
} 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;
}
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,
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());
}
}
}
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();
}
}
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());
}
}
@Override
public String coefficient() {
- return ruleDto.getDefaultRemediationCoefficient();
+ return ruleDto.getDefaultRemediationGapMultiplier();
}
@Override
public String offset() {
- return ruleDto.getDefaultRemediationOffset();
+ return ruleDto.getDefaultRemediationBaseEffort();
}
};
}
@Override
public String coefficient() {
- return ruleDto.getRemediationCoefficient();
+ return ruleDto.getRemediationGapMultiplier();
}
@Override
public String offset() {
- return ruleDto.getRemediationOffset();
+ return ruleDto.getRemediationBaseEffort();
}
};
}
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++;
}
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) {
// 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();
// -> 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();
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");
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();
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());
}
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();
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());
}
// 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();
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());
}
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/>");
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/>");
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");
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");
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);
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);
}
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);
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");
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();
.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())
.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);
.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);
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;
@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);
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();
}
@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);
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);
@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);
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);
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);
.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);
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
// 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);
// 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
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");
// 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)
// 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)
// 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);
// 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
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();
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();
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();
.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();
.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();
.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();
.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();
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
);
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"
/>
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"
/>
--- /dev/null
+#
+# 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
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;
}
@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;
}
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
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",
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},
(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>
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>
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;
"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,
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
.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)
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());
.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)
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());
.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);
}
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"/>
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>
<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"
/>