aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-09-07 22:08:45 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-09-09 10:13:43 +0200
commit84c39f50d53f7f4a76fcda6c58b6120875501e40 (patch)
tree66f3a96fc24de07bdf2cad46debe9f13e85792ee /server
parent9953f330120c5d4609dd695bc70885e8d46c5a99 (diff)
downloadsonarqube-84c39f50d53f7f4a76fcda6c58b6120875501e40.tar.gz
sonarqube-84c39f50d53f7f4a76fcda6c58b6120875501e40.zip
SONAR-6644 fix debt when characteristic is none
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleImpl.java17
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java5
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/RuleOperations.java3
3 files changed, 5 insertions, 20 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleImpl.java
index a30d9cd9d72..483ed15c924 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleImpl.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleImpl.java
@@ -48,7 +48,7 @@ public class RuleImpl implements Rule {
this.key = dto.getKey();
this.name = dto.getName();
this.status = dto.getStatus();
- this.subCharacteristicId = effectiveCharacteristicId(dto);
+ this.subCharacteristicId = dto.getEffectiveSubCharacteristicId();
this.tags = union(dto.getSystemTags(), dto.getTags());
this.remediationFunction = effectiveRemediationFunction(dto);
}
@@ -118,21 +118,6 @@ public class RuleImpl implements Rule {
}
@CheckForNull
- private static Integer effectiveCharacteristicId(RuleDto dto) {
- if (isEnabledCharacteristicId(dto.getSubCharacteristicId())) {
- return dto.getSubCharacteristicId();
- }
- if (isEnabledCharacteristicId(dto.getDefaultSubCharacteristicId())) {
- return dto.getDefaultSubCharacteristicId();
- }
- return null;
- }
-
- private static boolean isEnabledCharacteristicId(@Nullable Integer id) {
- return (id != null) && (id.intValue() != RuleDto.DISABLED_CHARACTERISTIC_ID);
- }
-
- @CheckForNull
private static DebtRemediationFunction effectiveRemediationFunction(RuleDto dto) {
String fn = dto.getRemediationFunction();
if (fn != null) {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java b/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java
index a16ea010fba..f3ab358f804 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java
@@ -346,9 +346,8 @@ public class DebtModelBackup {
@CheckForNull
private static RuleDebt toRuleDebt(RuleDto rule, DebtModel debtModel) {
RuleDebt ruleDebt = new RuleDebt().setRuleKey(RuleKey.of(rule.getRepositoryKey(), rule.getRuleKey()));
- Integer effectiveSubCharacteristicId = rule.getSubCharacteristicId() != null ? rule.getSubCharacteristicId() : rule.getDefaultSubCharacteristicId();
- DebtCharacteristic subCharacteristic = (effectiveSubCharacteristicId != null && !RuleDto.DISABLED_CHARACTERISTIC_ID.equals(effectiveSubCharacteristicId)) ?
- debtModel.characteristicById(effectiveSubCharacteristicId) : null;
+ Integer effectiveSubCharacteristicId = rule.getEffectiveSubCharacteristicId();
+ DebtCharacteristic subCharacteristic = effectiveSubCharacteristicId != null ? debtModel.characteristicById(effectiveSubCharacteristicId) : null;
if (subCharacteristic != null) {
ruleDebt.setSubCharacteristicKey(subCharacteristic.key());
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleOperations.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleOperations.java
index 8bbc7521acb..3172f6c9b18 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleOperations.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleOperations.java
@@ -111,7 +111,8 @@ public class RuleOperations {
// No sub-characteristic is given -> disable rule debt if not already disabled
} else {
// Rule characteristic is not already disabled -> update it
- if (ruleDto.getSubCharacteristicId() == null || !RuleDto.DISABLED_CHARACTERISTIC_ID.equals(ruleDto.getSubCharacteristicId())) {
+ Integer subCharacteristicId = ruleDto.getSubCharacteristicId();
+ if (subCharacteristicId == null || subCharacteristicId != RuleDto.DISABLED_CHARACTERISTIC_ID) {
// If default characteristic is not defined, set the overridden characteristic to null in order to be able to track debt plugin
// update
ruleDto.setSubCharacteristicId(ruleDto.getDefaultSubCharacteristicId() != null ? RuleDto.DISABLED_CHARACTERISTIC_ID : null);