aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooRulesDefinitionTest.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/rule/RulesProvider.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java20
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/rule/RuleMapper.xml12
-rw-r--r--sonar-core/src/test/java/org/sonar/core/rule/RuleDaoTest.java24
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/DebtRemediationFunction.java26
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Rule.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtRemediationFunction.java8
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java10
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/server/rule/DefaultDebtRemediationFunctions.java12
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java13
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java14
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/DefaultDebtRemediationFunctionTest.java6
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/internal/RulesBuilderTest.java2
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/server/debt/DefaultDebtRemediationFunctionTest.java34
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java2
-rw-r--r--sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java10
-rw-r--r--sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java4
-rw-r--r--sonar-server/src/main/java/org/sonar/server/debt/DebtModelService.java2
-rw-r--r--sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java10
-rw-r--r--sonar-server/src/main/java/org/sonar/server/startup/CopyRequirementsFromCharacteristicsToRules.java2
-rw-r--r--sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java58
-rw-r--r--sonar-server/src/test/java/org/sonar/server/debt/DebtModelOperationsTest.java10
-rw-r--r--sonar-server/src/test/java/org/sonar/server/rule/DeprecatedRulesDefinitionTest.java2
25 files changed, 150 insertions, 141 deletions
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooRulesDefinitionTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooRulesDefinitionTest.java
index ddf2c645498..ec34d3bdcaa 100644
--- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooRulesDefinitionTest.java
+++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooRulesDefinitionTest.java
@@ -46,7 +46,7 @@ public class XooRulesDefinitionTest {
assertThat(x1.debtSubCharacteristic()).isEqualTo(RulesDefinition.SubCharacteristics.INTEGRATION_TESTABILITY);
assertThat(x1.debtRemediationFunction().type()).isEqualTo(DebtRemediationFunction.Type.LINEAR_OFFSET);
- assertThat(x1.debtRemediationFunction().factor()).isEqualTo("1h");
+ assertThat(x1.debtRemediationFunction().coefficient()).isEqualTo("1h");
assertThat(x1.debtRemediationFunction().offset()).isEqualTo("30min");
}
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java b/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java
index de553d4435f..1e6bb240720 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java
@@ -119,7 +119,7 @@ public class ModuleIssues {
"because this rule does not have a fixed remediation cost.");
}
Duration result = Duration.create(0);
- Duration factor = function.factor();
+ Duration factor = function.coefficient();
Duration offset = function.offset();
if (factor != null) {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProvider.java b/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProvider.java
index 701a5b9f81e..b4ec1b061ff 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProvider.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProvider.java
@@ -107,9 +107,9 @@ public class RulesProvider extends ProviderAdapter {
String function = ruleDto.getRemediationFunction();
String defaultFunction = ruleDto.getDefaultRemediationFunction();
if (function != null) {
- return createDebtRemediationFunction(function, ruleDto.getRemediationFactor(), ruleDto.getRemediationOffset(), durations);
+ return createDebtRemediationFunction(function, ruleDto.getRemediationCoefficient(), ruleDto.getRemediationOffset(), durations);
} else if (defaultFunction != null) {
- return createDebtRemediationFunction(defaultFunction, ruleDto.getDefaultRemediationFactor(), ruleDto.getDefaultRemediationOffset(), durations);
+ return createDebtRemediationFunction(defaultFunction, ruleDto.getDefaultRemediationCoefficient(), ruleDto.getDefaultRemediationOffset(), durations);
} else {
throw new IllegalStateException(String.format("Remediation function should not be null on rule '%s'", ruleKey));
}
diff --git a/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java b/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java
index e53232b57f9..b2fa74dd187 100644
--- a/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java
@@ -53,8 +53,8 @@ public final class RuleDto {
private Integer defaultCharacteristicId;
private String remediationFunction;
private String defaultRemediationFunction;
- private String remediationFactor;
- private String defaultRemediationFactor;
+ private String remediationCoefficient;
+ private String defaultRemediationCoefficient;
private String remediationOffset;
private String defaultRemediationOffset;
private String effortToFixDescription;
@@ -247,22 +247,22 @@ public final class RuleDto {
}
@CheckForNull
- public String getRemediationFactor() {
- return remediationFactor;
+ public String getRemediationCoefficient() {
+ return remediationCoefficient;
}
- public RuleDto setRemediationFactor(@Nullable String remediationFactor) {
- this.remediationFactor = remediationFactor;
+ public RuleDto setRemediationCoefficient(@Nullable String remediationCoefficient) {
+ this.remediationCoefficient = remediationCoefficient;
return this;
}
@CheckForNull
- public String getDefaultRemediationFactor() {
- return defaultRemediationFactor;
+ public String getDefaultRemediationCoefficient() {
+ return defaultRemediationCoefficient;
}
- public RuleDto setDefaultRemediationFactor(@Nullable String defaultRemediationFactor) {
- this.defaultRemediationFactor = defaultRemediationFactor;
+ public RuleDto setDefaultRemediationCoefficient(@Nullable String defaultRemediationCoefficient) {
+ this.defaultRemediationCoefficient = defaultRemediationCoefficient;
return this;
}
diff --git a/sonar-core/src/main/resources/org/sonar/core/rule/RuleMapper.xml b/sonar-core/src/main/resources/org/sonar/core/rule/RuleMapper.xml
index c376bb984eb..235f5322d26 100644
--- a/sonar-core/src/main/resources/org/sonar/core/rule/RuleMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/core/rule/RuleMapper.xml
@@ -23,8 +23,8 @@
r.default_characteristic_id as "defaultCharacteristicId",
r.remediation_function as "remediationFunction",
r.default_remediation_function as "defaultRemediationFunction",
- r.remediation_factor as "remediationFactor",
- r.default_remediation_factor as "defaultRemediationFactor",
+ r.remediation_factor as "remediationCoefficient",
+ r.default_remediation_factor as "defaultRemediationCoefficient",
r.remediation_offset as "remediationOffset",
r.default_remediation_offset as "defaultRemediationOffset",
r.effort_to_fix_description as "effortToFixDescription",
@@ -84,8 +84,8 @@
default_characteristic_id=#{defaultCharacteristicId},
remediation_function=#{remediationFunction},
default_remediation_function=#{defaultRemediationFunction},
- remediation_factor=#{remediationFactor},
- default_remediation_factor=#{defaultRemediationFactor},
+ remediation_factor=#{remediationCoefficient},
+ default_remediation_factor=#{defaultRemediationCoefficient},
remediation_offset=#{remediationOffset},
default_remediation_offset=#{defaultRemediationOffset},
effort_to_fix_description=#{effortToFixDescription},
@@ -106,7 +106,7 @@
values (#{ruleKey}, #{repositoryKey}, #{description}, #{status}, #{name}, #{configKey},
#{severity}, #{cardinality}, #{language}, #{parentId},
#{characteristicId}, #{defaultCharacteristicId}, #{remediationFunction}, #{defaultRemediationFunction},
- #{remediationFactor}, #{defaultRemediationFactor}, #{remediationOffset}, #{defaultRemediationOffset},
+ #{remediationCoefficient}, #{defaultRemediationCoefficient}, #{remediationOffset}, #{defaultRemediationOffset},
#{effortToFixDescription},
#{createdAt}, #{updatedAt})
</insert>
@@ -116,7 +116,7 @@
values (#{ruleKey}, #{repositoryKey}, #{description}, #{status}, #{name}, #{configKey},
#{severity}, #{cardinality}, #{language}, #{parentId},
#{characteristicId}, #{defaultCharacteristicId}, #{remediationFunction}, #{defaultRemediationFunction},
- #{remediationFactor}, #{defaultRemediationFactor}, #{remediationOffset}, #{defaultRemediationOffset},
+ #{remediationCoefficient}, #{defaultRemediationCoefficient}, #{remediationOffset}, #{defaultRemediationOffset},
#{effortToFixDescription},
#{createdAt}, #{updatedAt})
</insert>
diff --git a/sonar-core/src/test/java/org/sonar/core/rule/RuleDaoTest.java b/sonar-core/src/test/java/org/sonar/core/rule/RuleDaoTest.java
index b0711dc5214..7fc19af9bdd 100644
--- a/sonar-core/src/test/java/org/sonar/core/rule/RuleDaoTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/rule/RuleDaoTest.java
@@ -63,8 +63,8 @@ public class RuleDaoTest extends AbstractDaoTestCase {
assertThat(ruleDto.getDefaultCharacteristicId()).isEqualTo(101);
assertThat(ruleDto.getRemediationFunction()).isEqualTo("linear");
assertThat(ruleDto.getDefaultRemediationFunction()).isEqualTo("linear_offset");
- assertThat(ruleDto.getRemediationFactor()).isEqualTo("1h");
- assertThat(ruleDto.getDefaultRemediationFactor()).isEqualTo("5d");
+ 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");
@@ -87,8 +87,8 @@ public class RuleDaoTest extends AbstractDaoTestCase {
assertThat(ruleDto.getDefaultCharacteristicId()).isEqualTo(101);
assertThat(ruleDto.getRemediationFunction()).isEqualTo("LINEAR");
assertThat(ruleDto.getDefaultRemediationFunction()).isEqualTo("LINEAR_OFFSET");
- assertThat(ruleDto.getRemediationFactor()).isEqualTo("1h");
- assertThat(ruleDto.getDefaultRemediationFactor()).isEqualTo("5d");
+ 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");
@@ -177,8 +177,8 @@ public class RuleDaoTest extends AbstractDaoTestCase {
.setDefaultCharacteristicId(101)
.setRemediationFunction("linear")
.setDefaultRemediationFunction("linear_offset")
- .setRemediationFactor("1h")
- .setDefaultRemediationFactor("5d")
+ .setRemediationCoefficient("1h")
+ .setDefaultRemediationCoefficient("5d")
.setRemediationOffset("5min")
.setDefaultRemediationOffset("10h")
.setEffortToFixDescription("squid.S115.effortToFix")
@@ -209,8 +209,8 @@ public class RuleDaoTest extends AbstractDaoTestCase {
.setDefaultCharacteristicId(101)
.setRemediationFunction("linear")
.setDefaultRemediationFunction("linear_offset")
- .setRemediationFactor("1h")
- .setDefaultRemediationFactor("5d")
+ .setRemediationCoefficient("1h")
+ .setDefaultRemediationCoefficient("5d")
.setRemediationOffset("5min")
.setDefaultRemediationOffset("10h")
.setEffortToFixDescription("squid.S115.effortToFix")
@@ -242,8 +242,8 @@ public class RuleDaoTest extends AbstractDaoTestCase {
.setDefaultCharacteristicId(101)
.setRemediationFunction("linear")
.setDefaultRemediationFunction("linear_offset")
- .setRemediationFactor("1h")
- .setDefaultRemediationFactor("5d")
+ .setRemediationCoefficient("1h")
+ .setDefaultRemediationCoefficient("5d")
.setRemediationOffset("5min")
.setDefaultRemediationOffset("10h")
.setEffortToFixDescription("squid.S115.effortToFix")
@@ -266,8 +266,8 @@ public class RuleDaoTest extends AbstractDaoTestCase {
.setDefaultCharacteristicId(103)
.setRemediationFunction("linear_offset")
.setDefaultRemediationFunction("linear")
- .setRemediationFactor("5d")
- .setDefaultRemediationFactor("1h")
+ .setRemediationCoefficient("5d")
+ .setDefaultRemediationCoefficient("1h")
.setRemediationOffset("10h")
.setDefaultRemediationOffset("5min")
.setEffortToFixDescription("squid.S115.effortToFix2")
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/DebtRemediationFunction.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/DebtRemediationFunction.java
index 459f96655de..5ce0a5e2482 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/DebtRemediationFunction.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/DebtRemediationFunction.java
@@ -39,25 +39,25 @@ public class DebtRemediationFunction {
}
private Type type;
- private Duration factor;
+ private Duration coefficient;
private Duration offset;
- private DebtRemediationFunction(Type type, @Nullable Duration factor, @Nullable Duration offset) {
+ private DebtRemediationFunction(Type type, @Nullable Duration coefficient, @Nullable Duration offset) {
this.type = type;
- this.factor = factor;
+ this.coefficient = coefficient;
this.offset = offset;
}
- public static DebtRemediationFunction create(Type type, @Nullable Duration factor, @Nullable Duration offset) {
- return new DebtRemediationFunction(type, factor, offset);
+ public static DebtRemediationFunction create(Type type, @Nullable Duration coefficient, @Nullable Duration offset) {
+ return new DebtRemediationFunction(type, coefficient, offset);
}
- public static DebtRemediationFunction createLinear(Duration factor) {
- return new DebtRemediationFunction(Type.LINEAR, factor, null);
+ public static DebtRemediationFunction createLinear(Duration coefficient) {
+ return new DebtRemediationFunction(Type.LINEAR, coefficient, null);
}
- public static DebtRemediationFunction createLinearWithOffset(Duration factor, Duration offset) {
- return new DebtRemediationFunction(Type.LINEAR_OFFSET, factor, offset);
+ public static DebtRemediationFunction createLinearWithOffset(Duration coefficient, Duration offset) {
+ return new DebtRemediationFunction(Type.LINEAR_OFFSET, coefficient, offset);
}
public static DebtRemediationFunction createConstantPerIssue(Duration offset) {
@@ -69,8 +69,8 @@ public class DebtRemediationFunction {
}
@CheckForNull
- public Duration factor() {
- return factor;
+ public Duration coefficient() {
+ return coefficient;
}
@CheckForNull
@@ -89,7 +89,7 @@ public class DebtRemediationFunction {
DebtRemediationFunction that = (DebtRemediationFunction) o;
return new EqualsBuilder()
.append(type, that.type())
- .append(factor, that.factor())
+ .append(coefficient, that.coefficient())
.append(offset, that.offset())
.isEquals();
}
@@ -98,7 +98,7 @@ public class DebtRemediationFunction {
public int hashCode() {
return new HashCodeBuilder(15, 31)
.append(type)
- .append(factor)
+ .append(coefficient)
.append(offset)
.toHashCode();
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Rule.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Rule.java
index b1aed121df0..f87317dfdab 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Rule.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Rule.java
@@ -61,7 +61,7 @@ public interface Rule {
String debtCharacteristic();
/**
- * Remediation function : can by Linear (with a factor), Linear with offset (with a factor and an offset) or Constant per issue (with an offset)
+ * Remediation function : can by Linear (with a coefficient), Linear with offset (with a coefficient and an offset) or Constant per issue (with an offset)
*
* @since 4.3
*/
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtRemediationFunction.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtRemediationFunction.java
index 3c8e9971dd2..fdb10ce1a6a 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtRemediationFunction.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtRemediationFunction.java
@@ -26,12 +26,12 @@ import javax.annotation.CheckForNull;
* Function used to calculate the remediation cost of an issue. There are three types :
* <ul>
* <li>
- * <b>Linear</b> - Each issue of the rule costs the same amount of time (factor) to fix.
+ * <b>Linear</b> - Each issue of the rule costs the same amount of time (coefficient) to fix.
* </li>
* <li>
* <b>Linear with offset</b> - It takes a certain amount of time to analyze the issues of such kind on the file (offset).
- * Then, each issue of the rule costs the same amount of time (factor) to fix. Total remediation cost
- * by file = offset + (number of issues x factor)
+ * Then, each issue of the rule costs the same amount of time (coefficient) to fix. Total remediation cost
+ * by file = offset + (number of issues x coefficient)
* </li>
* <li><b>Constant/issue</b> - The cost to fix all the issues of the rule is the same whatever the number of issues
* of this rule in the file. Total remediation cost by file = constant
@@ -52,7 +52,7 @@ public interface DebtRemediationFunction {
* Factor is set on types {@link Type#LINEAR} and {@link Type#LINEAR_OFFSET}, else it's null.
*/
@CheckForNull
- String factor();
+ String coefficient();
/**
* Offset is set on types {@link Type#LINEAR_OFFSET} and {@link Type#CONSTANT_ISSUE}, else it's null.
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java
index 1f13976ea27..68372f99eba 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java
@@ -38,7 +38,7 @@ public class DefaultDebtRemediationFunction implements DebtRemediationFunction {
public DefaultDebtRemediationFunction(Type type, @Nullable String factor, @Nullable String offset) {
this.type = type;
- this.factor = sanitizeValue("factor", factor);
+ this.factor = sanitizeValue("coefficient", factor);
this.offset = sanitizeValue("offset", offset);
validate();
}
@@ -63,7 +63,7 @@ public class DefaultDebtRemediationFunction implements DebtRemediationFunction {
@Override
@CheckForNull
- public String factor() {
+ public String coefficient() {
return factor;
}
@@ -77,12 +77,12 @@ public class DefaultDebtRemediationFunction implements DebtRemediationFunction {
switch (type) {
case LINEAR:
if (this.factor == null || this.offset != null) {
- throw new IllegalArgumentException(String.format("Only factor must be set on %s", this));
+ throw new IllegalArgumentException(String.format("Only coefficient must be set on %s", this));
}
break;
case LINEAR_OFFSET:
if (this.factor == null || this.offset == null) {
- throw new IllegalArgumentException(String.format("Both factor and offset are required on %s", this));
+ throw new IllegalArgumentException(String.format("Both coefficient and offset are required on %s", this));
}
break;
case CONSTANT_ISSUE:
@@ -125,7 +125,7 @@ public class DefaultDebtRemediationFunction implements DebtRemediationFunction {
public String toString() {
return Objects.toStringHelper(DebtRemediationFunction.class)
.add("type", type)
- .add("factor", factor)
+ .add("coefficient", factor)
.add("offset", offset)
.toString();
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/DefaultDebtRemediationFunctions.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/DefaultDebtRemediationFunctions.java
index a2fa542e6dd..0b97f49695e 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/DefaultDebtRemediationFunctions.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/DefaultDebtRemediationFunctions.java
@@ -41,13 +41,13 @@ class DefaultDebtRemediationFunctions implements RulesDefinition.DebtRemediation
}
@Override
- public DebtRemediationFunction linear(String factor) {
- return create(DefaultDebtRemediationFunction.Type.LINEAR, factor, null);
+ public DebtRemediationFunction linear(String coefficient) {
+ return create(DefaultDebtRemediationFunction.Type.LINEAR, coefficient, null);
}
@Override
- public DebtRemediationFunction linearWithOffset(String factor, String offset) {
- return create(DefaultDebtRemediationFunction.Type.LINEAR_OFFSET, factor, offset);
+ public DebtRemediationFunction linearWithOffset(String coefficient, String offset) {
+ return create(DefaultDebtRemediationFunction.Type.LINEAR_OFFSET, coefficient, offset);
}
@Override
@@ -55,9 +55,9 @@ class DefaultDebtRemediationFunctions implements RulesDefinition.DebtRemediation
return create(DefaultDebtRemediationFunction.Type.CONSTANT_ISSUE, null, offset);
}
- private DebtRemediationFunction create(DefaultDebtRemediationFunction.Type type, @Nullable String factor, @Nullable String offset) {
+ private DebtRemediationFunction create(DefaultDebtRemediationFunction.Type type, @Nullable String coefficient, @Nullable String offset) {
try {
- return new DefaultDebtRemediationFunction(type, factor, offset);
+ return new DefaultDebtRemediationFunction(type, coefficient, offset);
} catch (Exception e) {
throw MessageException.of(String.format("The rule '%s:%s' is invalid : %s ", this.repoKey, this.key, e.getMessage()));
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java
index 7c01f5836c7..4adcdfac2d1 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java
@@ -20,13 +20,7 @@
package org.sonar.api.server.rule;
import com.google.common.base.Strings;
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSortedSet;
-import com.google.common.collect.ListMultimap;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
+import com.google.common.collect.*;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.LoggerFactory;
@@ -38,6 +32,7 @@ import org.sonar.api.server.debt.DebtRemediationFunction;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
+
import java.io.IOException;
import java.net.URL;
import java.util.Collection;
@@ -509,9 +504,9 @@ public interface RulesDefinition extends ServerExtension {
* Factory of {@link org.sonar.api.server.debt.DebtRemediationFunction}.
*/
interface DebtRemediationFunctions {
- DebtRemediationFunction linear(String factor);
+ DebtRemediationFunction linear(String coefficient);
- DebtRemediationFunction linearWithOffset(String factor, String offset);
+ DebtRemediationFunction linearWithOffset(String coefficient, String offset);
DebtRemediationFunction constantPerIssue(String offset);
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java
index 31ea02837d2..e933c99a99e 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java
@@ -51,10 +51,16 @@ public class Duration implements Serializable {
this(((long) days * hoursInDay * MINUTES_IN_ONE_HOUR) + (hours * MINUTES_IN_ONE_HOUR) + minutes);
}
+ /**
+ *
+ */
public static Duration create(long durationInMinutes) {
return new Duration(durationInMinutes);
}
+ /**
+ *
+ */
public static Duration decode(String text, int hoursInDay) {
int days = 0, hours = 0, minutes = 0;
String sanitizedText = StringUtils.deleteWhitespace(text);
@@ -88,6 +94,9 @@ public class Duration implements Serializable {
}
}
+ /**
+ *
+ */
public String encode(int hoursInDay) {
int days = ((Double) ((double) durationInMinutes / hoursInDay / MINUTES_IN_ONE_HOUR)).intValue();
Long remainingDuration = durationInMinutes - (days * hoursInDay * MINUTES_IN_ONE_HOUR);
@@ -111,6 +120,11 @@ public class Duration implements Serializable {
return stringBuilder.toString();
}
+ /**
+ * Return the duration in minutes.
+ * <br>
+ * For instance, Duration.decode(1h, 24) will return 60.
+ */
public long toMinutes() {
return durationInMinutes;
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/DefaultDebtRemediationFunctionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/DefaultDebtRemediationFunctionTest.java
index d63bfea969f..4bcb659a5b2 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/DefaultDebtRemediationFunctionTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/DefaultDebtRemediationFunctionTest.java
@@ -31,7 +31,7 @@ public class DefaultDebtRemediationFunctionTest {
public void create_linear() throws Exception {
DebtRemediationFunction function = DebtRemediationFunction.createLinear(Duration.create(10));
assertThat(function.type()).isEqualTo(DebtRemediationFunction.Type.LINEAR);
- assertThat(function.factor()).isEqualTo(Duration.create(10));
+ assertThat(function.coefficient()).isEqualTo(Duration.create(10));
assertThat(function.offset()).isNull();
}
@@ -39,7 +39,7 @@ public class DefaultDebtRemediationFunctionTest {
public void create_linear_with_offset() throws Exception {
DebtRemediationFunction function = DebtRemediationFunction.createLinearWithOffset(Duration.create(10), Duration.create(5));
assertThat(function.type()).isEqualTo(DebtRemediationFunction.Type.LINEAR_OFFSET);
- assertThat(function.factor()).isEqualTo(Duration.create(10));
+ assertThat(function.coefficient()).isEqualTo(Duration.create(10));
assertThat(function.offset()).isEqualTo(Duration.create(5));
}
@@ -47,7 +47,7 @@ public class DefaultDebtRemediationFunctionTest {
public void create_constant_per_issue() throws Exception {
DebtRemediationFunction function = DebtRemediationFunction.createConstantPerIssue(Duration.create(10));
assertThat(function.type()).isEqualTo(DebtRemediationFunction.Type.CONSTANT_ISSUE);
- assertThat(function.factor()).isNull();
+ assertThat(function.coefficient()).isNull();
assertThat(function.offset()).isEqualTo(Duration.create(10));
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/internal/RulesBuilderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/internal/RulesBuilderTest.java
index 881823e3cf6..e569d4e1db1 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/internal/RulesBuilderTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/internal/RulesBuilderTest.java
@@ -73,7 +73,7 @@ public class RulesBuilderTest {
assertThat(squid1.severity()).isEqualTo(Severity.CRITICAL);
assertThat(squid1.debtCharacteristic()).isEqualTo("COMPILER");
assertThat(squid1.debtRemediationFunction().type()).isEqualTo(DebtRemediationFunction.Type.LINEAR_OFFSET);
- assertThat(squid1.debtRemediationFunction().factor()).isEqualTo(Duration.create(10));
+ assertThat(squid1.debtRemediationFunction().coefficient()).isEqualTo(Duration.create(10));
assertThat(squid1.debtRemediationFunction().offset()).isEqualTo(Duration.create(60));
assertThat(squid1.debtCharacteristic()).isEqualTo("COMPILER");
assertThat(squid1.params()).hasSize(2);
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/debt/DefaultDebtRemediationFunctionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/debt/DefaultDebtRemediationFunctionTest.java
index f4c28fe2737..8bdefe18651 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/server/debt/DefaultDebtRemediationFunctionTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/debt/DefaultDebtRemediationFunctionTest.java
@@ -32,7 +32,7 @@ public class DefaultDebtRemediationFunctionTest {
public void create_linear() {
DebtRemediationFunction function = new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR, "10h", null);
assertThat(function.type()).isEqualTo(DefaultDebtRemediationFunction.Type.LINEAR);
- assertThat(function.factor()).isEqualTo("10h");
+ assertThat(function.coefficient()).isEqualTo("10h");
assertThat(function.offset()).isNull();
}
@@ -40,7 +40,7 @@ public class DefaultDebtRemediationFunctionTest {
public void create_linear_with_offset() {
DebtRemediationFunction function = new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET, "10h", "5min");
assertThat(function.type()).isEqualTo(DefaultDebtRemediationFunction.Type.LINEAR_OFFSET);
- assertThat(function.factor()).isEqualTo("10h");
+ assertThat(function.coefficient()).isEqualTo("10h");
assertThat(function.offset()).isEqualTo("5min");
}
@@ -48,25 +48,25 @@ public class DefaultDebtRemediationFunctionTest {
public void create_constant_per_issue() {
DebtRemediationFunction function = new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE, null, "10h");
assertThat(function.type()).isEqualTo(DefaultDebtRemediationFunction.Type.CONSTANT_ISSUE);
- assertThat(function.factor()).isNull();
+ assertThat(function.coefficient()).isNull();
assertThat(function.offset()).isEqualTo("10h");
}
@Test
- public void sanitize_remediation_factor_and_offset() {
+ public void sanitize_remediation_coefficient_and_offset() {
DebtRemediationFunction function = new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET, " 1 h ", " 10 min");
- assertThat(function.factor()).isEqualTo("1h");
+ assertThat(function.coefficient()).isEqualTo("1h");
assertThat(function.offset()).isEqualTo("10min");
}
@Test
- public void fail_to_create_linear_when_no_factor() {
+ public void fail_to_create_linear_when_no_coefficient() {
try {
new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR, null, "10h");
fail();
} catch (IllegalArgumentException e) {
- assertThat(e).hasMessage("Only factor must be set on DebtRemediationFunction{type=LINEAR, factor=null, offset=10h}");
+ assertThat(e).hasMessage("Only coefficient must be set on DebtRemediationFunction{type=LINEAR, coefficient=null, offset=10h}");
}
}
@@ -76,7 +76,7 @@ public class DefaultDebtRemediationFunctionTest {
new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR, "5min", "10h");
fail();
} catch (IllegalArgumentException e) {
- assertThat(e).hasMessage("Only factor must be set on DebtRemediationFunction{type=LINEAR, factor=5min, offset=10h}");
+ assertThat(e).hasMessage("Only coefficient must be set on DebtRemediationFunction{type=LINEAR, coefficient=5min, offset=10h}");
}
}
@@ -86,27 +86,27 @@ public class DefaultDebtRemediationFunctionTest {
new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE, "10h", null);
fail();
} catch (IllegalArgumentException e) {
- assertThat(e).hasMessage("Only offset must be set on DebtRemediationFunction{type=CONSTANT_ISSUE, factor=10h, offset=null}");
+ assertThat(e).hasMessage("Only offset must be set on DebtRemediationFunction{type=CONSTANT_ISSUE, coefficient=10h, offset=null}");
}
}
@Test
- public void fail_to_create_constant_per_issue_when_factor() {
+ public void fail_to_create_constant_per_issue_when_coefficient() {
try {
new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE, "5min", "10h");
fail();
} catch (IllegalArgumentException e) {
- assertThat(e).hasMessage("Only offset must be set on DebtRemediationFunction{type=CONSTANT_ISSUE, factor=5min, offset=10h}");
+ assertThat(e).hasMessage("Only offset must be set on DebtRemediationFunction{type=CONSTANT_ISSUE, coefficient=5min, offset=10h}");
}
}
@Test
- public void fail_to_create_linear_with_offset_when_no_factor() {
+ public void fail_to_create_linear_with_offset_when_no_coefficient() {
try {
new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET, "", "10h");
fail();
} catch (IllegalArgumentException e) {
- assertThat(e).hasMessage("Both factor and offset are required on DebtRemediationFunction{type=LINEAR_OFFSET, factor=null, offset=10h}");
+ assertThat(e).hasMessage("Both coefficient and offset are required on DebtRemediationFunction{type=LINEAR_OFFSET, coefficient=null, offset=10h}");
}
}
@@ -116,7 +116,7 @@ public class DefaultDebtRemediationFunctionTest {
new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET, "5min", "");
fail();
} catch (IllegalArgumentException e) {
- assertThat(e).hasMessage("Both factor and offset are required on DebtRemediationFunction{type=LINEAR_OFFSET, factor=5min, offset=null}");
+ assertThat(e).hasMessage("Both coefficient and offset are required on DebtRemediationFunction{type=LINEAR_OFFSET, coefficient=5min, offset=null}");
}
}
@@ -143,16 +143,16 @@ public class DefaultDebtRemediationFunctionTest {
@Test
public void test_to_string() {
assertThat(new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET, "10h", "5min").toString())
- .isEqualTo("DebtRemediationFunction{type=LINEAR_OFFSET, factor=10h, offset=5min}");
+ .isEqualTo("DebtRemediationFunction{type=LINEAR_OFFSET, coefficient=10h, offset=5min}");
}
@Test
- public void fail_if_bad_factor_format() {
+ public void fail_if_bad_coefficient_format() {
try {
new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR, "foo", null);
fail();
} catch (IllegalArgumentException e) {
- assertThat(e).hasMessage("Invalid factor: foo");
+ assertThat(e).hasMessage("Invalid coefficient: foo");
}
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java
index 186fe99dc22..3a028382d3c 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java
@@ -95,7 +95,7 @@ public class RulesDefinitionTest {
assertThat(rule.status()).isEqualTo(RuleStatus.BETA);
assertThat(rule.debtSubCharacteristic()).isEqualTo("COMPILER");
assertThat(rule.debtRemediationFunction().type()).isEqualTo(DebtRemediationFunction.Type.LINEAR_OFFSET);
- assertThat(rule.debtRemediationFunction().factor()).isEqualTo("1h");
+ assertThat(rule.debtRemediationFunction().coefficient()).isEqualTo("1h");
assertThat(rule.debtRemediationFunction().offset()).isEqualTo("10min");
assertThat(rule.effortToFixDescription()).isEqualTo("squid.S115.effortToFix");
assertThat(rule.toString()).isEqualTo("[repository=findbugs, key=NPE]");
diff --git a/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java b/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java
index 068294006f1..37d7ce8f44d 100644
--- a/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java
+++ b/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java
@@ -29,8 +29,8 @@ import org.apache.ibatis.session.SqlSession;
import org.sonar.api.ServerComponent;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.server.debt.DebtCharacteristic;
-import org.sonar.api.server.debt.internal.DefaultDebtCharacteristic;
import org.sonar.api.server.debt.DebtRemediationFunction;
+import org.sonar.api.server.debt.internal.DefaultDebtCharacteristic;
import org.sonar.api.utils.System2;
import org.sonar.api.utils.ValidationMessages;
import org.sonar.core.permission.GlobalPermissions;
@@ -229,7 +229,7 @@ public class DebtModelBackup implements ServerComponent {
boolean isSameFunction = isSameRemediationFunction(ruleDebt, rule);
rule.setCharacteristicId((!isSameCharacteristic ? characteristicDto.getId() : null));
rule.setRemediationFunction((!isSameFunction ? ruleDebt.function().name() : null));
- rule.setRemediationFactor((!isSameFunction ? ruleDebt.factor() : null));
+ rule.setRemediationCoefficient((!isSameFunction ? ruleDebt.factor() : null));
rule.setRemediationOffset((!isSameFunction ? ruleDebt.offset() : null));
rule.setUpdatedAt(updateDate);
ruleDao.update(rule, session);
@@ -290,7 +290,7 @@ public class DebtModelBackup implements ServerComponent {
private static boolean isSameRemediationFunction(RuleDebt ruleDebt, RuleDto rule) {
return new EqualsBuilder()
.append(ruleDebt.function().name(), rule.getDefaultRemediationFunction())
- .append(ruleDebt.factor(), rule.getDefaultRemediationFactor())
+ .append(ruleDebt.factor(), rule.getDefaultRemediationCoefficient())
.append(ruleDebt.offset(), rule.getDefaultRemediationOffset())
.isEquals();
}
@@ -298,7 +298,7 @@ public class DebtModelBackup implements ServerComponent {
private void disabledRuleDebt(RuleDto rule, Date updateDate, SqlSession session){
rule.setCharacteristicId(rule.getDefaultCharacteristicId() != null ? RuleDto.DISABLED_CHARACTERISTIC_ID : null);
rule.setRemediationFunction(null);
- rule.setRemediationFactor(null);
+ rule.setRemediationCoefficient(null);
rule.setRemediationOffset(null);
rule.setUpdatedAt(updateDate);
ruleDao.update(rule, session);
@@ -349,7 +349,7 @@ public class DebtModelBackup implements ServerComponent {
private static RuleDebt toRuleDebt(RuleDto rule, String characteristicKey) {
RuleDebt ruleDebt = new RuleDebt().setRuleKey(RuleKey.of(rule.getRepositoryKey(), rule.getRuleKey()));
String function = rule.getRemediationFunction() != null ? rule.getRemediationFunction() : rule.getDefaultRemediationFunction();
- String factor = rule.getRemediationFactor() != null ? rule.getRemediationFactor() : rule.getDefaultRemediationFactor();
+ String factor = rule.getRemediationCoefficient() != null ? rule.getRemediationCoefficient() : rule.getDefaultRemediationCoefficient();
String offset = rule.getRemediationOffset() != null ? rule.getRemediationOffset() : rule.getDefaultRemediationOffset();
ruleDebt.setCharacteristicKey(characteristicKey);
ruleDebt.setFunction(DebtRemediationFunction.Type.valueOf(function));
diff --git a/sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java b/sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java
index 521322cc48c..0c4b0cd2db6 100644
--- a/sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java
+++ b/sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java
@@ -170,7 +170,7 @@ public class DebtModelOperations implements ServerComponent {
/**
* Disable characteristic and its sub characteristics or only sub characteristic.
- * Will also update every rules linked to sub characteristics by setting characteristic id to -1 and remove function, factor and offset.
+ * Will also update every rules linked to sub characteristics by setting characteristic id to -1 and remove function, coefficient and offset.
*/
public void delete(int characteristicId) {
checkPermission();
@@ -205,7 +205,7 @@ public class DebtModelOperations implements ServerComponent {
for (RuleDto ruleDto : ruleDtos) {
ruleDto.setCharacteristicId(RuleDto.DISABLED_CHARACTERISTIC_ID);
ruleDto.setRemediationFunction(null);
- ruleDto.setRemediationFactor(null);
+ ruleDto.setRemediationCoefficient(null);
ruleDto.setRemediationOffset(null);
ruleDto.setUpdatedAt(updateDate);
ruleDao.update(ruleDto, session);
diff --git a/sonar-server/src/main/java/org/sonar/server/debt/DebtModelService.java b/sonar-server/src/main/java/org/sonar/server/debt/DebtModelService.java
index 40b1e27f48f..040f8468917 100644
--- a/sonar-server/src/main/java/org/sonar/server/debt/DebtModelService.java
+++ b/sonar-server/src/main/java/org/sonar/server/debt/DebtModelService.java
@@ -76,7 +76,7 @@ public class DebtModelService implements DebtModel {
/**
* Disable characteristic and sub characteristic or only sub characteristic.
- * Will also update every rules linked to sub characteristics by setting characteristic id to -1 and remove function, factor and offset.
+ * Will also update every rules linked to sub characteristics by setting characteristic id to -1 and remove function, coefficient and offset.
*/
public void delete(int characteristicId) {
debtModelOperations.delete(characteristicId);
diff --git a/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java b/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java
index 9d0261e5eb9..93fd8571951 100644
--- a/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java
+++ b/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java
@@ -193,7 +193,7 @@ public class RegisterRules implements Startable {
if (characteristic != null && remediationFunction != null) {
ruleDto.setDefaultCharacteristicId(characteristic.getId())
.setDefaultRemediationFunction(remediationFunction.type().name())
- .setDefaultRemediationFactor(remediationFunction.factor())
+ .setDefaultRemediationCoefficient(remediationFunction.coefficient())
.setDefaultRemediationOffset(remediationFunction.offset())
.setEffortToFixDescription(ruleDef.effortToFixDescription());
}
@@ -272,7 +272,7 @@ public class RegisterRules implements Startable {
boolean hasCharacteristic = characteristic != null;
DebtRemediationFunction debtRemediationFunction = characteristic != null ? def.debtRemediationFunction() : null;
Integer characteristicId = characteristic != null ? characteristic.getId() : null;
- String remediationFactor = hasCharacteristic ? debtRemediationFunction.factor() : null;
+ String remediationFactor = hasCharacteristic ? debtRemediationFunction.coefficient() : null;
String remediationOffset = hasCharacteristic ? debtRemediationFunction.offset() : null;
String effortToFixDescription = hasCharacteristic ? def.effortToFixDescription() : null;
@@ -285,8 +285,8 @@ public class RegisterRules implements Startable {
dto.setDefaultRemediationFunction(remediationFunctionString);
changed = true;
}
- if (!StringUtils.equals(dto.getDefaultRemediationFactor(), remediationFactor)) {
- dto.setDefaultRemediationFactor(remediationFactor);
+ if (!StringUtils.equals(dto.getDefaultRemediationCoefficient(), remediationFactor)) {
+ dto.setDefaultRemediationCoefficient(remediationFactor);
changed = true;
}
if (!StringUtils.equals(dto.getDefaultRemediationOffset(), remediationOffset)) {
@@ -418,7 +418,7 @@ public class RegisterRules implements Startable {
ruleDto.setStatus(parent.getStatus());
ruleDto.setDefaultCharacteristicId(parent.getDefaultCharacteristicId());
ruleDto.setDefaultRemediationFunction(parent.getDefaultRemediationFunction());
- ruleDto.setDefaultRemediationFactor(parent.getDefaultRemediationFactor());
+ ruleDto.setDefaultRemediationCoefficient(parent.getDefaultRemediationCoefficient());
ruleDto.setDefaultRemediationOffset(parent.getDefaultRemediationOffset());
ruleDto.setEffortToFixDescription(parent.getEffortToFixDescription());
ruleDto.setUpdatedAt(buffer.now());
diff --git a/sonar-server/src/main/java/org/sonar/server/startup/CopyRequirementsFromCharacteristicsToRules.java b/sonar-server/src/main/java/org/sonar/server/startup/CopyRequirementsFromCharacteristicsToRules.java
index c7e99ffad16..351ffbc70e7 100644
--- a/sonar-server/src/main/java/org/sonar/server/startup/CopyRequirementsFromCharacteristicsToRules.java
+++ b/sonar-server/src/main/java/org/sonar/server/startup/CopyRequirementsFromCharacteristicsToRules.java
@@ -51,7 +51,7 @@ import java.util.List;
/**
* This script copy every requirements from characteristics table (every row where rule_id is not null) to the rules table.
*
- * This script need to be executed after rules registration because default debt columns (characteristics, function, factor and offset) has to be populated
+ * This script need to be executed after rules registration because default debt columns (characteristics, function, coefficient and offset) has to be populated
* in order to be able to compare default values with overridden values.
*
* @since 4.3 this component could be removed after 4 or 5 releases.
diff --git a/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java b/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java
index f96bfdbfab1..f9def473ead 100644
--- a/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java
@@ -31,8 +31,8 @@ import org.mockito.invocation.InvocationOnMock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
import org.sonar.api.rule.RuleKey;
-import org.sonar.api.server.debt.internal.DefaultDebtCharacteristic;
import org.sonar.api.server.debt.DebtRemediationFunction;
+import org.sonar.api.server.debt.internal.DefaultDebtCharacteristic;
import org.sonar.api.utils.DateUtils;
import org.sonar.api.utils.System2;
import org.sonar.api.utils.ValidationMessages;
@@ -148,10 +148,10 @@ public class DebtModelBackupTest {
when(ruleDao.selectEnablesAndNonManual(session)).thenReturn(newArrayList(
// Rule with overridden debt values
- new RuleDto().setRepositoryKey("squid").setRuleKey("UselessImportCheck").setCharacteristicId(2).setRemediationFunction("LINEAR_OFFSET").setRemediationFactor("2h").setRemediationOffset("15min"),
+ new RuleDto().setRepositoryKey("squid").setRuleKey("UselessImportCheck").setCharacteristicId(2).setRemediationFunction("LINEAR_OFFSET").setRemediationCoefficient("2h").setRemediationOffset("15min"),
// Rule with default debt values
- new RuleDto().setRepositoryKey("squid").setRuleKey("AvoidNPE").setDefaultCharacteristicId(2).setDefaultRemediationFunction("LINEAR").setDefaultRemediationFactor("2h")
+ new RuleDto().setRepositoryKey("squid").setRuleKey("AvoidNPE").setDefaultCharacteristicId(2).setDefaultRemediationFunction("LINEAR").setDefaultRemediationCoefficient("2h")
));
debtModelBackup.backup();
@@ -216,7 +216,7 @@ public class DebtModelBackupTest {
.setCreatedAt(oldDate).setUpdatedAt(oldDate),
// Should be ignored
new RuleDto().setId(2).setRepositoryKey("checkstyle").setLanguage("java2")
- .setCharacteristicId(3).setRemediationFunction("LINEAR").setRemediationFactor("2h")
+ .setCharacteristicId(3).setRemediationFunction("LINEAR").setRemediationCoefficient("2h")
.setCreatedAt(oldDate).setUpdatedAt(oldDate)
));
@@ -330,7 +330,7 @@ public class DebtModelBackupTest {
));
when(ruleDao.selectEnablesAndNonManual(session)).thenReturn(newArrayList(
- new RuleDto().setRepositoryKey("squid").setCharacteristicId(2).setRemediationFunction("LINEAR_OFFSET").setRemediationFactor("2h").setRemediationOffset("15min")
+ new RuleDto().setRepositoryKey("squid").setCharacteristicId(2).setRemediationFunction("LINEAR_OFFSET").setRemediationCoefficient("2h").setRemediationOffset("15min")
.setCreatedAt(oldDate).setUpdatedAt(oldDate)
));
@@ -347,7 +347,7 @@ public class DebtModelBackupTest {
RuleDto rule = ruleArgument.getValue();
assertThat(rule.getCharacteristicId()).isNull();
assertThat(rule.getRemediationFunction()).isNull();
- assertThat(rule.getRemediationFactor()).isNull();
+ assertThat(rule.getRemediationCoefficient()).isNull();
assertThat(rule.getRemediationOffset()).isNull();
assertThat(rule.getUpdatedAt()).isEqualTo(now);
@@ -358,11 +358,11 @@ public class DebtModelBackupTest {
public void restore_from_language() throws Exception {
when(ruleDao.selectEnablesAndNonManual(session)).thenReturn(newArrayList(
new RuleDto().setId(1).setRepositoryKey("squid").setLanguage("java")
- .setCharacteristicId(2).setRemediationFunction("LINEAR_OFFSET").setRemediationFactor("2h").setRemediationOffset("15min")
+ .setCharacteristicId(2).setRemediationFunction("LINEAR_OFFSET").setRemediationCoefficient("2h").setRemediationOffset("15min")
.setCreatedAt(oldDate).setUpdatedAt(oldDate),
// Should be ignored because linked on another language
new RuleDto().setId(2).setRepositoryKey("checkstyle").setLanguage("java2")
- .setCharacteristicId(2).setRemediationFunction("LINEAR").setRemediationFactor("2h")
+ .setCharacteristicId(2).setRemediationFunction("LINEAR").setRemediationCoefficient("2h")
.setCreatedAt(oldDate).setUpdatedAt(oldDate)
));
@@ -378,7 +378,7 @@ public class DebtModelBackupTest {
assertThat(rule.getId()).isEqualTo(1);
assertThat(rule.getCharacteristicId()).isNull();
assertThat(rule.getRemediationFunction()).isNull();
- assertThat(rule.getRemediationFactor()).isNull();
+ assertThat(rule.getRemediationCoefficient()).isNull();
assertThat(rule.getRemediationOffset()).isNull();
assertThat(rule.getUpdatedAt()).isEqualTo(now);
@@ -395,8 +395,8 @@ public class DebtModelBackupTest {
when(ruleDao.selectEnablesAndNonManual(session)).thenReturn(newArrayList(
// Linked on a disabled default characteristic -> Rule debt should be disabled
new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck").setLanguage("java")
- .setDefaultCharacteristicId(3).setDefaultRemediationFunction("LINEAR").setDefaultRemediationFactor("2h")
- .setCharacteristicId(2).setRemediationFunction("LINEAR_OFFSET").setRemediationFactor("2h").setRemediationOffset("15min")
+ .setDefaultCharacteristicId(3).setDefaultRemediationFunction("LINEAR").setDefaultRemediationCoefficient("2h")
+ .setCharacteristicId(2).setRemediationFunction("LINEAR_OFFSET").setRemediationCoefficient("2h").setRemediationOffset("15min")
.setCreatedAt(oldDate).setUpdatedAt(oldDate)
));
@@ -410,7 +410,7 @@ public class DebtModelBackupTest {
assertThat(rule.getId()).isEqualTo(1);
assertThat(rule.getCharacteristicId()).isEqualTo(-1);
assertThat(rule.getRemediationFunction()).isNull();
- assertThat(rule.getRemediationFactor()).isNull();
+ assertThat(rule.getRemediationCoefficient()).isNull();
assertThat(rule.getRemediationOffset()).isNull();
assertThat(rule.getUpdatedAt()).isEqualTo(now);
@@ -432,7 +432,7 @@ public class DebtModelBackupTest {
when(ruleDao.selectEnablesAndNonManual(session)).thenReturn(newArrayList(
new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck")
- .setDefaultCharacteristicId(10).setDefaultRemediationFunction("LINEAR").setDefaultRemediationFactor("2h")
+ .setDefaultCharacteristicId(10).setDefaultRemediationFunction("LINEAR").setDefaultRemediationCoefficient("2h")
.setCreatedAt(oldDate).setUpdatedAt(oldDate)
));
@@ -446,7 +446,7 @@ public class DebtModelBackupTest {
assertThat(rule.getId()).isEqualTo(1);
assertThat(rule.getCharacteristicId()).isEqualTo(2);
assertThat(rule.getRemediationFunction()).isNull();
- assertThat(rule.getRemediationFactor()).isNull();
+ assertThat(rule.getRemediationCoefficient()).isNull();
assertThat(rule.getRemediationOffset()).isNull();
assertThat(rule.getUpdatedAt()).isEqualTo(now);
@@ -468,7 +468,7 @@ public class DebtModelBackupTest {
when(ruleDao.selectEnablesAndNonManual(session)).thenReturn(newArrayList(
new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck")
- .setDefaultCharacteristicId(2).setDefaultRemediationFunction("LINEAR").setDefaultRemediationFactor("2h")
+ .setDefaultCharacteristicId(2).setDefaultRemediationFunction("LINEAR").setDefaultRemediationCoefficient("2h")
.setCreatedAt(oldDate).setUpdatedAt(oldDate)
));
@@ -482,7 +482,7 @@ public class DebtModelBackupTest {
assertThat(rule.getId()).isEqualTo(1);
assertThat(rule.getCharacteristicId()).isNull();
assertThat(rule.getRemediationFunction()).isEqualTo("LINEAR_OFFSET");
- assertThat(rule.getRemediationFactor()).isEqualTo("12h");
+ assertThat(rule.getRemediationCoefficient()).isEqualTo("12h");
assertThat(rule.getRemediationOffset()).isEqualTo("11min");
assertThat(rule.getUpdatedAt()).isEqualTo(now);
@@ -504,7 +504,7 @@ public class DebtModelBackupTest {
when(ruleDao.selectEnablesAndNonManual(session)).thenReturn(newArrayList(
new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck")
- .setDefaultCharacteristicId(2).setDefaultRemediationFunction("LINEAR_OFFSET").setDefaultRemediationFactor("2h").setDefaultRemediationOffset("15min")
+ .setDefaultCharacteristicId(2).setDefaultRemediationFunction("LINEAR_OFFSET").setDefaultRemediationCoefficient("2h").setDefaultRemediationOffset("15min")
.setCreatedAt(oldDate).setUpdatedAt(oldDate)
));
@@ -518,7 +518,7 @@ public class DebtModelBackupTest {
assertThat(rule.getId()).isEqualTo(1);
assertThat(rule.getCharacteristicId()).isNull();
assertThat(rule.getRemediationFunction()).isNull();
- assertThat(rule.getRemediationFactor()).isNull();
+ assertThat(rule.getRemediationCoefficient()).isNull();
assertThat(rule.getRemediationOffset()).isNull();
assertThat(rule.getUpdatedAt()).isEqualTo(now);
@@ -537,7 +537,7 @@ public class DebtModelBackupTest {
when(ruleDao.selectEnablesAndNonManual(session)).thenReturn(newArrayList(
new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck")
- .setDefaultCharacteristicId(2).setDefaultRemediationFunction("LINEAR_OFFSET").setDefaultRemediationFactor("2h").setDefaultRemediationOffset("15min")
+ .setDefaultCharacteristicId(2).setDefaultRemediationFunction("LINEAR_OFFSET").setDefaultRemediationCoefficient("2h").setDefaultRemediationOffset("15min")
.setCreatedAt(oldDate).setUpdatedAt(oldDate)
));
@@ -551,7 +551,7 @@ public class DebtModelBackupTest {
assertThat(rule.getId()).isEqualTo(1);
assertThat(rule.getCharacteristicId()).isEqualTo(-1);
assertThat(rule.getRemediationFunction()).isNull();
- assertThat(rule.getRemediationFactor()).isNull();
+ assertThat(rule.getRemediationCoefficient()).isNull();
assertThat(rule.getRemediationOffset()).isNull();
assertThat(rule.getUpdatedAt()).isEqualTo(now);
@@ -584,7 +584,7 @@ public class DebtModelBackupTest {
// As rule has no debt value, characteristic is set to null
assertThat(rule.getCharacteristicId()).isNull();
assertThat(rule.getRemediationFunction()).isNull();
- assertThat(rule.getRemediationFactor()).isNull();
+ assertThat(rule.getRemediationCoefficient()).isNull();
assertThat(rule.getRemediationOffset()).isNull();
assertThat(rule.getUpdatedAt()).isEqualTo(now);
@@ -602,11 +602,11 @@ public class DebtModelBackupTest {
when(ruleDao.selectEnablesAndNonManual(session)).thenReturn(newArrayList(
new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck").setLanguage("java")
- .setDefaultCharacteristicId(10).setDefaultRemediationFunction("LINEAR").setDefaultRemediationFactor("2h")
+ .setDefaultCharacteristicId(10).setDefaultRemediationFunction("LINEAR").setDefaultRemediationCoefficient("2h")
.setCreatedAt(oldDate).setUpdatedAt(oldDate),
// Should be ignored
new RuleDto().setId(2).setRepositoryKey("checkstyle").setLanguage("java2")
- .setCharacteristicId(3).setRemediationFunction("LINEAR").setRemediationFactor("2h")
+ .setCharacteristicId(3).setRemediationFunction("LINEAR").setRemediationCoefficient("2h")
.setCreatedAt(oldDate).setUpdatedAt(oldDate)
));
@@ -636,8 +636,8 @@ public class DebtModelBackupTest {
when(ruleDao.selectEnablesAndNonManual(session)).thenReturn(newArrayList(
// Linked on a default disabled characteristic -> Rule debt should be disabled
new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck").setLanguage("java")
- .setDefaultCharacteristicId(3).setDefaultRemediationFunction("LINEAR").setDefaultRemediationFactor("2h")
- .setCharacteristicId(2).setRemediationFunction("LINEAR_OFFSET").setRemediationFactor("2h").setRemediationOffset("15min")
+ .setDefaultCharacteristicId(3).setDefaultRemediationFunction("LINEAR").setDefaultRemediationCoefficient("2h")
+ .setCharacteristicId(2).setRemediationFunction("LINEAR_OFFSET").setRemediationCoefficient("2h").setRemediationOffset("15min")
.setCreatedAt(oldDate).setUpdatedAt(oldDate)
));
@@ -654,7 +654,7 @@ public class DebtModelBackupTest {
assertThat(rule.getId()).isEqualTo(1);
assertThat(rule.getCharacteristicId()).isEqualTo(-1);
assertThat(rule.getRemediationFunction()).isNull();
- assertThat(rule.getRemediationFactor()).isNull();
+ assertThat(rule.getRemediationCoefficient()).isNull();
assertThat(rule.getRemediationOffset()).isNull();
assertThat(rule.getUpdatedAt()).isEqualTo(now);
@@ -670,8 +670,8 @@ public class DebtModelBackupTest {
when(ruleDao.selectEnablesAndNonManual(session)).thenReturn(newArrayList(
new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck").setLanguage("java")
- .setDefaultCharacteristicId(3).setDefaultRemediationFunction("LINEAR").setDefaultRemediationFactor("2h")
- .setCharacteristicId(2).setRemediationFunction("LINEAR_OFFSET").setRemediationFactor("2h").setRemediationOffset("15min")
+ .setDefaultCharacteristicId(3).setDefaultRemediationFunction("LINEAR").setDefaultRemediationCoefficient("2h")
+ .setCharacteristicId(2).setRemediationFunction("LINEAR_OFFSET").setRemediationCoefficient("2h").setRemediationOffset("15min")
.setCreatedAt(oldDate).setUpdatedAt(oldDate)
));
@@ -692,7 +692,7 @@ public class DebtModelBackupTest {
assertThat(rule.getId()).isEqualTo(1);
assertThat(rule.getCharacteristicId()).isEqualTo(-1);
assertThat(rule.getRemediationFunction()).isNull();
- assertThat(rule.getRemediationFactor()).isNull();
+ assertThat(rule.getRemediationCoefficient()).isNull();
assertThat(rule.getRemediationOffset()).isNull();
assertThat(rule.getUpdatedAt()).isEqualTo(now);
diff --git a/sonar-server/src/test/java/org/sonar/server/debt/DebtModelOperationsTest.java b/sonar-server/src/test/java/org/sonar/server/debt/DebtModelOperationsTest.java
index 97570e977c3..02deb490d5f 100644
--- a/sonar-server/src/test/java/org/sonar/server/debt/DebtModelOperationsTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/debt/DebtModelOperationsTest.java
@@ -305,8 +305,8 @@ public class DebtModelOperationsTest {
when(ruleDao.selectBySubCharacteristicId(2, batchSession)).thenReturn(newArrayList(
new RuleDto()
- .setCharacteristicId(2).setRemediationFunction("LINEAR_OFFSET").setRemediationFactor("2h").setRemediationOffset("5min")
- .setDefaultCharacteristicId(10).setDefaultRemediationFunction("LINEAR_OFFSET").setDefaultRemediationFactor("4h").setDefaultRemediationOffset("15min")
+ .setCharacteristicId(2).setRemediationFunction("LINEAR_OFFSET").setRemediationCoefficient("2h").setRemediationOffset("5min")
+ .setDefaultCharacteristicId(10).setDefaultRemediationFunction("LINEAR_OFFSET").setDefaultRemediationCoefficient("4h").setDefaultRemediationOffset("15min")
));
when(dao.selectById(2, batchSession)).thenReturn(subCharacteristicDto);
@@ -319,14 +319,14 @@ public class DebtModelOperationsTest {
// Overridden debt data are disabled
assertThat(ruleDto.getCharacteristicId()).isEqualTo(-1);
assertThat(ruleDto.getRemediationFunction()).isNull();
- assertThat(ruleDto.getRemediationFactor()).isNull();
+ assertThat(ruleDto.getRemediationCoefficient()).isNull();
assertThat(ruleDto.getRemediationOffset()).isNull();
assertThat(ruleDto.getUpdatedAt()).isEqualTo(now);
// Default debt data should not be touched
assertThat(ruleDto.getDefaultCharacteristicId()).isEqualTo(10);
assertThat(ruleDto.getDefaultRemediationFunction()).isEqualTo("LINEAR_OFFSET");
- assertThat(ruleDto.getDefaultRemediationFactor()).isEqualTo("4h");
+ assertThat(ruleDto.getDefaultRemediationCoefficient()).isEqualTo("4h");
assertThat(ruleDto.getDefaultRemediationOffset()).isEqualTo("15min");
ArgumentCaptor<CharacteristicDto> characteristicArgument = ArgumentCaptor.forClass(CharacteristicDto.class);
@@ -345,7 +345,7 @@ public class DebtModelOperationsTest {
when(mybatis.openBatchSession()).thenReturn(batchSession);
when(ruleDao.selectBySubCharacteristicId(subCharacteristicDto.getId(), batchSession)).thenReturn(newArrayList(
- new RuleDto().setCharacteristicId(subCharacteristicDto.getId()).setRemediationFunction("LINEAR_OFFSET").setRemediationFactor("2h").setRemediationOffset("5min")
+ new RuleDto().setCharacteristicId(subCharacteristicDto.getId()).setRemediationFunction("LINEAR_OFFSET").setRemediationCoefficient("2h").setRemediationOffset("5min")
));
when(dao.selectCharacteristicsByParentId(1, batchSession)).thenReturn(newArrayList(
subCharacteristicDto
diff --git a/sonar-server/src/test/java/org/sonar/server/rule/DeprecatedRulesDefinitionTest.java b/sonar-server/src/test/java/org/sonar/server/rule/DeprecatedRulesDefinitionTest.java
index a69875ff4b5..9bdbcaf21c1 100644
--- a/sonar-server/src/test/java/org/sonar/server/rule/DeprecatedRulesDefinitionTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/rule/DeprecatedRulesDefinitionTest.java
@@ -182,7 +182,7 @@ public class DeprecatedRulesDefinitionTest {
assertThat(rule.key()).isEqualTo("ConstantName");
assertThat(rule.debtSubCharacteristic()).isEqualTo("MEMORY_EFFICIENCY");
assertThat(rule.debtRemediationFunction().type()).isEqualTo(DebtRemediationFunction.Type.LINEAR_OFFSET);
- assertThat(rule.debtRemediationFunction().factor()).isEqualTo("1d");
+ assertThat(rule.debtRemediationFunction().coefficient()).isEqualTo("1d");
assertThat(rule.debtRemediationFunction().offset()).isEqualTo("10min");
}