From 5362244699df98d65dfd3e0febad8aa46655f8c4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?L=C3=A9o=20Geoffroy?= Date: Tue, 29 Aug 2023 17:51:55 +0200 Subject: [PATCH] SONAR-20260 Fix quality gate --- .../ce/task/projectexport/rule/ExportAdHocRulesStep.java | 4 +++- .../src/main/java/org/sonar/db/rule/RuleForIndexingDto.java | 6 ++++-- .../src/main/java/org/sonar/server/rule/ws/RuleMapper.java | 1 - 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/rule/ExportAdHocRulesStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/rule/ExportAdHocRulesStep.java index 9a316c2b03c..cae6a5a94b0 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/rule/ExportAdHocRulesStep.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/rule/ExportAdHocRulesStep.java @@ -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(); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleForIndexingDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleForIndexingDto.java index d23db79bc15..68812d0551f 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleForIndexingDto.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleForIndexingDto.java @@ -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()); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleMapper.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleMapper.java index 427555e2512..b5ed3ea0fe3 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleMapper.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleMapper.java @@ -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; -- 2.39.5