]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-20260 Fix quality gate
authorLéo Geoffroy <leo.geoffroy@sonarsource.com>
Tue, 29 Aug 2023 15:51:55 +0000 (17:51 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 30 Aug 2023 20:03:06 +0000 (20:03 +0000)
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/rule/ExportAdHocRulesStep.java
server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleForIndexingDto.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleMapper.java

index 9a316c2b03c81a7a87a4b1cdaa27254a8be31094..cae6a5a94b041dcabff1a45636d136ad1483fc12 100644 (file)
@@ -25,6 +25,7 @@ import java.util.List;
 import java.util.Set;
 import org.apache.ibatis.cursor.Cursor;
 import org.slf4j.LoggerFactory;
+import org.sonar.api.rules.CleanCodeAttribute;
 import org.sonar.ce.task.projectexport.steps.DumpElement;
 import org.sonar.ce.task.projectexport.steps.DumpWriter;
 import org.sonar.ce.task.projectexport.steps.ProjectHolder;
@@ -73,6 +74,7 @@ public class ExportAdHocRulesStep implements ComputationStep {
   }
 
   private static ProjectDump.AdHocRule convertToAdHocRule(RuleDto ruleDto, ProjectDump.AdHocRule.Builder builder) {
+    CleanCodeAttribute cleanCodeAttribute = ruleDto.getCleanCodeAttribute();
     return builder
       .clear()
       .setRef(ruleDto.getUuid())
@@ -84,7 +86,7 @@ public class ExportAdHocRulesStep implements ComputationStep {
       .setType(ruleDto.getType())
       .setScope(ruleDto.getScope().name())
       .setMetadata(buildMetadata(ruleDto))
-      .setCleanCodeAttribute(ruleDto.getCleanCodeAttribute() != null ? ruleDto.getCleanCodeAttribute().name() : null)
+      .setCleanCodeAttribute(cleanCodeAttribute != null ? cleanCodeAttribute.name() : null)
       .addAllImpacts(buildImpacts(ruleDto.getDefaultImpacts()))
       .build();
   }
index d23db79bc15343242634eb21da18432a8047c270..68812d0551fc6d5bd9c6c23b96c3495a8dd63586 100644 (file)
@@ -27,6 +27,7 @@ import java.util.Set;
 import javax.annotation.CheckForNull;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.RuleStatus;
+import org.sonar.api.rules.CleanCodeAttribute;
 import org.sonar.api.rules.RuleType;
 import org.sonar.db.issue.ImpactDto;
 
@@ -87,8 +88,9 @@ public class RuleForIndexingDto {
       ruleForIndexingDto.setRuleDescriptionSectionsDtos(Sets.newHashSet(r.getRuleDescriptionSectionDtos()));
     }
 
-    if (r.getCleanCodeAttribute() != null) {
-      ruleForIndexingDto.cleanCodeAttributeCategory = r.getCleanCodeAttribute().getAttributeCategory().name();
+    CleanCodeAttribute cleanCodeAttribute = r.getCleanCodeAttribute();
+    if (cleanCodeAttribute != null) {
+      ruleForIndexingDto.cleanCodeAttributeCategory = cleanCodeAttribute.getAttributeCategory().name();
     }
     ruleForIndexingDto.setImpacts(r.getDefaultImpacts());
 
index 427555e2512946b29dd4008bc1ad76487512f2c3..b5ed3ea0fe3d2ee06b6ed211e0235a0fd2d768b1 100644 (file)
@@ -33,7 +33,6 @@ import org.sonar.api.resources.Language;
 import org.sonar.api.resources.Languages;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rules.CleanCodeAttribute;
-import org.sonar.api.rules.RuleType;
 import org.sonar.api.server.debt.DebtRemediationFunction;
 import org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction;
 import org.sonar.db.issue.ImpactDto;