use of org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction in project sonarqube by SonarSource.
the class UpdateAction method readDebt.
private void readDebt(Request request, RuleUpdate update) {
String value = defaultIfEmpty(request.param(PARAM_REMEDIATION_FN_TYPE), request.param(DEPRECATED_PARAM_REMEDIATION_FN_TYPE));
if (value != null) {
if (StringUtils.isBlank(value)) {
update.setDebtRemediationFunction(null);
} else {
DebtRemediationFunction fn = new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.valueOf(value), defaultIfEmpty(request.param(PARAM_REMEDIATION_FN_GAP_MULTIPLIER), request.param(DEPRECATED_PARAM_REMEDIATION_FN_COEFF)), defaultIfEmpty(request.param(PARAM_REMEDIATION_FN_BASE_EFFORT), request.param(DEPRECATED_PARAM_REMEDIATION_FN_OFFSET)));
update.setDebtRemediationFunction(fn);
}
}
}
use of org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction in project sonarqube by SonarSource.
the class DebtCalculatorTest method default_effort_to_fix_is_one_for_linear_function.
@Test
public void default_effort_to_fix_is_one_for_linear_function() {
int coefficient = 2;
rule.setFunction(new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR, coefficient + "min", null));
assertThat(underTest.calculate(issue).toMinutes()).isEqualTo(coefficient * 1);
}
use of org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction in project sonarqube by SonarSource.
the class DebtCalculatorTest method constant_function.
@Test
public void constant_function() {
int constant = 2;
issue.setGap(null);
rule.setFunction(new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE, null, constant + "min"));
assertThat(underTest.calculate(issue).toMinutes()).isEqualTo(2);
}
use of org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction in project sonarqube by SonarSource.
the class DebtCalculatorTest method effort_to_fix_must_not_be_set_with_constant_function.
@Test(expected = IllegalArgumentException.class)
public void effort_to_fix_must_not_be_set_with_constant_function() {
int constant = 2;
issue.setGap(3.0);
rule.setFunction(new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE, null, constant + "min"));
underTest.calculate(issue);
}
use of org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction in project sonarqube by SonarSource.
the class DebtCalculatorTest method linear_function.
@Test
public void linear_function() {
double effortToFix = 3.0;
int coefficient = 2;
issue.setGap(effortToFix);
rule.setFunction(new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR, coefficient + "min", null));
assertThat(underTest.calculate(issue).toMinutes()).isEqualTo((int) (coefficient * effortToFix));
}
Aggregations