aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core/src
diff options
context:
space:
mode:
authorLéo Geoffroy <leo.geoffroy@sonarsource.com>2023-10-31 11:51:38 +0100
committersonartech <sonartech@sonarsource.com>2023-11-08 20:02:52 +0000
commit954f9022337a4d568eef9cd221cafae2aadf9da4 (patch)
tree009d5144929f68e9572f2e10a095c40cf9195dbc /sonar-core/src
parent15d518496c28f5d782b0f9db53b61ff346b18542 (diff)
downloadsonarqube-954f9022337a4d568eef9cd221cafae2aadf9da4.tar.gz
sonarqube-954f9022337a4d568eef9cd221cafae2aadf9da4.zip
SONAR-20877 Add mapping for hotspots status
Diffstat (limited to 'sonar-core/src')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/status/SimpleStatus.java6
-rw-r--r--sonar-core/src/test/java/org/sonar/core/issue/status/SimpleStatusTest.java12
2 files changed, 18 insertions, 0 deletions
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
@@ -49,6 +49,18 @@ public class SimpleStatusTest {
}
@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))
.isInstanceOf(IllegalArgumentException.class)