From: Léo Geoffroy Date: Tue, 31 Oct 2023 10:51:38 +0000 (+0100) Subject: SONAR-20877 Add mapping for hotspots status X-Git-Tag: 10.4.0.87286~525 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=954f9022337a4d568eef9cd221cafae2aadf9da4;p=sonarqube.git SONAR-20877 Add mapping for hotspots status --- diff --git a/sonar-core/src/main/java/org/sonar/core/issue/status/SimpleStatus.java b/sonar-core/src/main/java/org/sonar/core/issue/status/SimpleStatus.java index e910d4d8161..ba9df611bfb 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/status/SimpleStatus.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/status/SimpleStatus.java @@ -19,6 +19,7 @@ */ package org.sonar.core.issue.status; +import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.api.issue.Issue; @@ -29,6 +30,7 @@ public enum SimpleStatus { ACCEPTED, FIXED; + @CheckForNull public static SimpleStatus of(String status, @Nullable String resolution) { switch (status) { case Issue.STATUS_OPEN: @@ -38,6 +40,10 @@ public enum SimpleStatus { return SimpleStatus.CONFIRMED; case Issue.STATUS_CLOSED: return SimpleStatus.FIXED; + //Security hotspot should not return simple status as they are deprecated. + case Issue.STATUS_REVIEWED: + case Issue.STATUS_TO_REVIEW: + return null; default: } if (resolution != null) { diff --git a/sonar-core/src/test/java/org/sonar/core/issue/status/SimpleStatusTest.java b/sonar-core/src/test/java/org/sonar/core/issue/status/SimpleStatusTest.java index b8cd9fd70de..6ba0af10fe5 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/status/SimpleStatusTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/status/SimpleStatusTest.java @@ -48,6 +48,18 @@ public class SimpleStatusTest { .isEqualTo(SimpleStatus.FIXED); } + @Test + public void of_shouldReturnNull_WhenStatusBelongsToHotspot() { + assertThat(SimpleStatus.of(Issue.STATUS_TO_REVIEW, null)) + .isNull(); + + assertThat(SimpleStatus.of(Issue.STATUS_REVIEWED, Issue.RESOLUTION_SAFE)) + .isNull(); + + assertThat(SimpleStatus.of(Issue.STATUS_REVIEWED, Issue.RESOLUTION_ACKNOWLEDGED)) + .isNull(); + } + @Test public void of_shouldThrowExceptionWhenUnknownMapping() { assertThatThrownBy(() -> SimpleStatus.of(Issue.STATUS_RESOLVED, null))