aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-server-common
diff options
context:
space:
mode:
authorDDMili <130993898+dejan-milisavljevic-sonarsource@users.noreply.github.com>2024-08-09 16:35:16 +0200
committersonartech <sonartech@sonarsource.com>2024-08-26 20:03:05 +0000
commit305b3d5937ece0b9aeaaa931fc0d9a4c1e6ba52b (patch)
treef4dabca3b2702a903b2c1c3e3a86db7ea5c7b5b6 /server/sonar-server-common
parentd3704d8bc1c5eeb059ef8f3a4d62bd0a59b05e2e (diff)
downloadsonarqube-305b3d5937ece0b9aeaaa931fc0d9a4c1e6ba52b.tar.gz
sonarqube-305b3d5937ece0b9aeaaa931fc0d9a4c1e6ba52b.zip
SONAR-22727 Add new software qualities rating measures
Diffstat (limited to 'server/sonar-server-common')
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/measure/Rating.java22
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/metric/SoftwareQualitiesMetrics.java10
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/metric/SoftwareQualitiesMetricsTest.java4
3 files changed, 21 insertions, 15 deletions
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/measure/Rating.java b/server/sonar-server-common/src/main/java/org/sonar/server/measure/Rating.java
index 885360be295..f00b8796dd8 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/measure/Rating.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/measure/Rating.java
@@ -19,8 +19,8 @@
*/
package org.sonar.server.measure;
-import com.google.common.collect.ImmutableMap;
import java.util.Map;
+import org.sonar.api.issue.impact.Severity;
import static java.lang.String.format;
import static java.util.Arrays.stream;
@@ -37,6 +37,18 @@ public enum Rating {
B(2),
A(1);
+ public static final Map<String, Rating> RATING_BY_SEVERITY = Map.of(
+ BLOCKER, E,
+ CRITICAL, D,
+ MAJOR, C,
+ MINOR, B,
+ INFO, A);
+
+ public static final Map<Severity, Rating> RATING_BY_SOFTWARE_QUALITY_SEVERITY = Map.of(
+ Severity.HIGH, Rating.D,
+ Severity.MEDIUM, Rating.C,
+ Severity.LOW, Rating.B);
+
private final int index;
Rating(int index) {
@@ -54,14 +66,6 @@ public enum Rating {
.orElseThrow(() -> new IllegalArgumentException(format("Unknown value '%s'", index)));
}
- public static final Map<String, Rating> RATING_BY_SEVERITY = ImmutableMap.of(
- BLOCKER, E,
- CRITICAL, D,
- MAJOR, C,
- MINOR, B,
- INFO, A);
-
-
public static Rating ratingFromValue(String value) {
return valueOf(Integer.parseInt(value));
}
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/metric/SoftwareQualitiesMetrics.java b/server/sonar-server-common/src/main/java/org/sonar/server/metric/SoftwareQualitiesMetrics.java
index 229e9ebb76f..de1e0c8476b 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/metric/SoftwareQualitiesMetrics.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/metric/SoftwareQualitiesMetrics.java
@@ -59,7 +59,8 @@ public class SoftwareQualitiesMetrics implements Metrics {
public static final String SOFTWARE_QUALITY_RELIABILITY_RATING_KEY = "software_quality_reliability_rating";
- public static final Metric<Integer> RELIABILITY_RATING = new Metric.Builder(SOFTWARE_QUALITY_RELIABILITY_RATING_KEY, "Software Quality Reliability Rating", Metric.ValueType.RATING)
+ public static final Metric<Integer> SOFTWARE_QUALITY_RELIABILITY_RATING = new Metric.Builder(SOFTWARE_QUALITY_RELIABILITY_RATING_KEY,
+ "Software Quality Reliability Rating", Metric.ValueType.RATING)
.setDescription("Software quality reliability rating")
.setDomain(DOMAIN_RELIABILITY)
.setDirection(Metric.DIRECTION_WORST)
@@ -70,7 +71,8 @@ public class SoftwareQualitiesMetrics implements Metrics {
public static final String NEW_SOFTWARE_QUALITY_RELIABILITY_RATING_KEY = "new_software_quality_reliability_rating";
- public static final Metric<Integer> NEW_RELIABILITY_RATING = new Metric.Builder(NEW_SOFTWARE_QUALITY_RELIABILITY_RATING_KEY,
+ public static final Metric<Integer> NEW_SOFTWARE_QUALITY_RELIABILITY_RATING =
+ new Metric.Builder(NEW_SOFTWARE_QUALITY_RELIABILITY_RATING_KEY,
"Software Quality Reliability Rating on New Code", Metric.ValueType.RATING)
.setDescription("Software quality reliability rating on new code")
.setDomain(DOMAIN_RELIABILITY)
@@ -264,8 +266,8 @@ public class SoftwareQualitiesMetrics implements Metrics {
return List.of(
SOFTWARE_QUALITY_MAINTAINABILITY_RATING,
NEW_SOFTWARE_QUALITY_MAINTAINABILITY_RATING,
- RELIABILITY_RATING,
- NEW_RELIABILITY_RATING,
+ SOFTWARE_QUALITY_RELIABILITY_RATING,
+ NEW_SOFTWARE_QUALITY_RELIABILITY_RATING,
SOFTWARE_QUALITY_SECURITY_RATING,
NEW_SOFTWARE_QUALITY_SECURITY_RATING,
SOFTWARE_QUALITY_SECURITY_REVIEW_RATING,
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/metric/SoftwareQualitiesMetricsTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/metric/SoftwareQualitiesMetricsTest.java
index b4315ffaa51..2c8f51177a5 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/metric/SoftwareQualitiesMetricsTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/metric/SoftwareQualitiesMetricsTest.java
@@ -30,8 +30,8 @@ class SoftwareQualitiesMetricsTest {
.containsExactlyInAnyOrder(
SoftwareQualitiesMetrics.SOFTWARE_QUALITY_MAINTAINABILITY_RATING,
SoftwareQualitiesMetrics.NEW_SOFTWARE_QUALITY_MAINTAINABILITY_RATING,
- SoftwareQualitiesMetrics.RELIABILITY_RATING,
- SoftwareQualitiesMetrics.NEW_RELIABILITY_RATING,
+ SoftwareQualitiesMetrics.SOFTWARE_QUALITY_RELIABILITY_RATING,
+ SoftwareQualitiesMetrics.NEW_SOFTWARE_QUALITY_RELIABILITY_RATING,
SoftwareQualitiesMetrics.SOFTWARE_QUALITY_SECURITY_RATING,
SoftwareQualitiesMetrics.NEW_SOFTWARE_QUALITY_SECURITY_RATING,
SoftwareQualitiesMetrics.SOFTWARE_QUALITY_SECURITY_REVIEW_RATING,