From 191a2c5e5ea80d3905d0042adafc391bf121e7f0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?L=C3=A9o=20Geoffroy?= Date: Wed, 6 Nov 2024 14:18:42 +0100 Subject: [PATCH] SONAR-23474 Project import/export supports manual impact severity --- .../ce/task/projectexport/issue/ExportIssuesStepIT.java | 9 +++++---- .../ce/task/projectexport/issue/ExportIssuesStep.java | 1 + .../src/main/protobuf/project_dump.proto | 1 + .../org/sonar/db/project/ProjectExportMapper.xml | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStepIT.java index 3dae30abdb8..fbd952c6cd6 100644 --- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStepIT.java +++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStepIT.java @@ -232,8 +232,8 @@ public class ExportIssuesStepIT { .setRuleDescriptionContextKey("test_rule_description_context_key") .setIssueCreationTime(963L) .setIssueUpdateTime(852L) - .addImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.HIGH)) - .addImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.SECURITY).setSeverity(Severity.BLOCKER)) + .addImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.HIGH).setManualSeverity(true)) + .addImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.SECURITY).setSeverity(Severity.BLOCKER).setManualSeverity(false)) .setIssueCloseTime(741L) .setCodeVariants(List.of("v1", "v2")); @@ -270,8 +270,9 @@ public class ExportIssuesStepIT { assertThat(issue.getIssueUpdatedAt()).isEqualTo(issueDto.getIssueUpdateTime()); assertThat(issue.getIssueClosedAt()).isEqualTo(issueDto.getIssueCloseTime()); assertThat(issue.getLocations()).isNotEmpty(); - assertThat(issue.getImpactsList()).extracting(ProjectDump.Impact::getSoftwareQuality, ProjectDump.Impact::getSeverity) - .containsOnly(tuple(ProjectDump.SoftwareQuality.MAINTAINABILITY, ProjectDump.Severity.HIGH), tuple(ProjectDump.SoftwareQuality.SECURITY, ProjectDump.Severity.BLOCKER)); + assertThat(issue.getImpactsList()).extracting(ProjectDump.Impact::getSoftwareQuality, ProjectDump.Impact::getSeverity, ProjectDump.Impact::getManualSeverity) + .containsOnly(tuple(ProjectDump.SoftwareQuality.MAINTAINABILITY, ProjectDump.Severity.HIGH, true), + tuple(ProjectDump.SoftwareQuality.SECURITY, ProjectDump.Severity.BLOCKER, false)); assertThat(issue.getMessageFormattingsList()) .isEqualTo(ExportIssuesStep.dbToDumpMessageFormatting(messageFormattings.getMessageFormattingList())); assertThat(issue.getCodeVariants()).isEqualTo(issueDto.getCodeVariantsString()); diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStep.java index 0838d75e35b..44982ffe6d9 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStep.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStep.java @@ -128,6 +128,7 @@ public class ExportIssuesStep implements ComputationStep { .map(impactDto -> ProjectDump.Impact.newBuilder() .setSoftwareQuality(ProjectDump.SoftwareQuality.valueOf(impactDto.getSoftwareQuality().name())) .setSeverity(ProjectDump.Severity.valueOf(impactDto.getSeverity().name())) + .setManualSeverity(impactDto.isManualSeverity()) .build()) .forEach(builder::addImpacts); } diff --git a/server/sonar-ce-task-projectanalysis/src/main/protobuf/project_dump.proto b/server/sonar-ce-task-projectanalysis/src/main/protobuf/project_dump.proto index e9847cea4c1..29ccf1c6cb2 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/protobuf/project_dump.proto +++ b/server/sonar-ce-task-projectanalysis/src/main/protobuf/project_dump.proto @@ -131,6 +131,7 @@ message Issue { message Impact { SoftwareQuality software_quality = 1; Severity severity = 2; + bool manual_severity = 3; } // Stream of issues changelog stored in file issues_changelog.pb diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectExportMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectExportMapper.xml index db9e9b8fc95..fbd9d82b547 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectExportMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectExportMapper.xml @@ -131,6 +131,7 @@ i.code_variants as codeVariantsString, ii.software_quality as ii_softwareQuality, ii.severity as ii_severity, + ii.manual_severity as ii_manualSeverity, rdi.software_quality as rdi_softwareQuality, rdi.severity as rdi_severity from issues i -- 2.39.5