]> source.dussan.org Git - sonarqube.git/commitdiff
Fix quality flaws
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 12 Mar 2014 07:43:54 +0000 (08:43 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 12 Mar 2014 07:43:54 +0000 (08:43 +0100)
sonar-batch/src/main/java/org/sonar/batch/debt/DebtModelProvider.java
sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java
sonar-batch/src/main/java/org/sonar/batch/rule/RulesProvider.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultRule.java

index f86a2fe9fc5f1b24047f91c08688aa1fc06accc9..be7d9895cc29a6ff9c6fa4a51678b3f8d70c0c1d 100644 (file)
@@ -51,13 +51,13 @@ public class DebtModelProvider extends ProviderAdapter {
   }
 
   private TechnicalDebtModel load(CharacteristicDao dao) {
-    DefaultTechnicalDebtModel model = new DefaultTechnicalDebtModel();
+    DefaultTechnicalDebtModel debtModel = new DefaultTechnicalDebtModel();
     List<CharacteristicDto> dtos = dao.selectEnabledCharacteristics();
     Map<Integer, DefaultCharacteristic> characteristicsById = newHashMap();
 
-    addRootCharacteristics(model, dtos, characteristicsById);
+    addRootCharacteristics(debtModel, dtos, characteristicsById);
     addCharacteristics(dtos, characteristicsById);
-    return model;
+    return debtModel;
   }
 
   private void addRootCharacteristics(DefaultTechnicalDebtModel model, List<CharacteristicDto> dtos, Map<Integer, DefaultCharacteristic> characteristicsById) {
index 20f941cf691627c4cc8371d039283e1dc7f39a85..106cf3bada223ef0456290171370bdee80451d83 100644 (file)
@@ -127,7 +127,7 @@ public class ModuleIssues {
 
     if (factor != null) {
       int effortToFixValue = Objects.firstNonNull(effortToFix, 1).intValue();
-      result = rule.factor().multiply(effortToFixValue);
+      result = factor.multiply(effortToFixValue);
     }
 
     if (offset != null) {
index bc8c282020c128776993a0809355ebff90202e7e..9d68bc326ab8e7144ea8eb586feaa0f5294a878c 100644 (file)
@@ -78,11 +78,13 @@ public class RulesProvider extends ProviderAdapter {
         .setDescription(ruleDto.getDescription())
         .setStatus(RuleStatus.valueOf(ruleDto.getStatus()));
       // TODO should we set metadata ?
-      if (ruleDto.getCharacteristicId() != null) {
-        Characteristic characteristic = characteristic(ruleDto.getCharacteristicId(), ruleKey, debtModel);
+      Integer characteristicId = ruleDto.getCharacteristicId();
+      Integer defaultCharacteristicId = ruleDto.getDefaultCharacteristicId();
+      if (characteristicId != null) {
+        Characteristic characteristic = characteristic(characteristicId, ruleKey, debtModel);
         updateRuleDebtDefinitions(newRule, ruleKey, characteristic, ruleDto.getRemediationFunction(), ruleDto.getRemediationFactor(), ruleDto.getRemediationOffset(), durations);
-      } else if (ruleDto.getDefaultCharacteristicId() != null) {
-        Characteristic characteristic = characteristic(ruleDto.getDefaultCharacteristicId(), ruleKey, debtModel);
+      } else if (defaultCharacteristicId != null) {
+        Characteristic characteristic = characteristic(defaultCharacteristicId, ruleKey, debtModel);
         updateRuleDebtDefinitions(newRule, ruleKey, characteristic, ruleDto.getDefaultRemediationFunction(), ruleDto.getDefaultRemediationFactor(),
           ruleDto.getDefaultRemediationOffset(), durations);
       }
index 25d0cd7572b0347ea95f008ed7777acd689ae555..13a3d3890eba57c336a037d0f81b90a10ea4bdbe 100644 (file)
@@ -40,8 +40,8 @@ public class DefaultRule implements Rule {
   private final Integer id;
   private final String name, severity, description, metadata, characteristic;
   private final RuleStatus status;
-  RemediationFunction function;
-  Duration factor, offset;
+  private final RemediationFunction function;
+  private final Duration factor, offset;
 
   private final Map<String, RuleParam> params;