]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-20877 Add mapping for hotspots status
authorLéo Geoffroy <leo.geoffroy@sonarsource.com>
Tue, 31 Oct 2023 10:51:38 +0000 (11:51 +0100)
committersonartech <sonartech@sonarsource.com>
Wed, 8 Nov 2023 20:02:52 +0000 (20:02 +0000)
sonar-core/src/main/java/org/sonar/core/issue/status/SimpleStatus.java
sonar-core/src/test/java/org/sonar/core/issue/status/SimpleStatusTest.java

index e910d4d81617542f54fc02206611a472818c9e5a..ba9df611bfbb7f1d1e5d68b19ee9acb1f0685e4c 100644 (file)
@@ -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) {
index b8cd9fd70defb07621804c32f316f537e203e4be..6ba0af10fe5c3db68aaf8a82eab4dfd215380c94 100644 (file)
@@ -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))