]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-23474 Project import/export supports manual impact severity
authorLéo Geoffroy <leo.geoffroy@sonarsource.com>
Wed, 6 Nov 2024 13:18:42 +0000 (14:18 +0100)
committersonartech <sonartech@sonarsource.com>
Mon, 11 Nov 2024 20:02:44 +0000 (20:02 +0000)
server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStepIT.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStep.java
server/sonar-ce-task-projectanalysis/src/main/protobuf/project_dump.proto
server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectExportMapper.xml

index 3dae30abdb8e75dc862a8bb980c11379eb8e9cfb..fbd952c6cd66233a3402505126f4e5fac54e5015 100644 (file)
@@ -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());
index 0838d75e35b881e9d6475259c037b91812155c05..44982ffe6d96a55f4a8f1761910562f8b663e473 100644 (file)
@@ -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);
   }
index e9847cea4c1650ceccb0cc48beddf40063c3ee4c..29ccf1c6cb291df6c6401989171eba2a88539b15 100644 (file)
@@ -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
index db9e9b8fc95d14e622f4215b8db1929a5223b20c..fbd9d82b547649394f736e97707838b45e720702 100644 (file)
           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