aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-webapi
diff options
context:
space:
mode:
authorLéo Geoffroy <leo.geoffroy@sonarsource.com>2024-11-12 15:28:13 +0100
committersonartech <sonartech@sonarsource.com>2024-11-13 20:05:48 +0000
commitc056a2d19f6211db7a153d5056db51b2452f738c (patch)
tree908cdb28b3063c4bc744e76393f82d2fda2cf743 /server/sonar-webserver-webapi
parent2bfe0518401cbc7cc101fdbc42d8b1aa665cccdf (diff)
downloadsonarqube-c056a2d19f6211db7a153d5056db51b2452f738c.tar.gz
sonarqube-c056a2d19f6211db7a153d5056db51b2452f738c.zip
SONAR-23566 Remove deprecation on metrics based on type or severity
Diffstat (limited to 'server/sonar-webserver-webapi')
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java8
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java13
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/MeasuresWsModule.java48
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchAction.java5
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java6
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/MeasuresWsModuleTest.java8
6 files changed, 53 insertions, 35 deletions
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java
index 03604616f1f..e41a4f5d10d 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java
@@ -28,7 +28,6 @@ import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-import org.sonar.db.component.ComponentQualifiers;
import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
@@ -38,6 +37,7 @@ import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.component.BranchDto;
import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentQualifiers;
import org.sonar.db.component.SnapshotDto;
import org.sonar.db.measure.MeasureDto;
import org.sonar.db.metric.MetricDto;
@@ -88,10 +88,12 @@ public class ComponentAction implements MeasuresWsAction {
public void define(WebService.NewController context) {
WebService.NewAction action = context.createAction(ACTION_COMPONENT)
.setDescription("Return component with specified measures.<br>" +
- "Requires the following permission: 'Browse' on the project of specified component.")
+ "Requires the following permission: 'Browse' on the project of specified component.")
.setResponseExample(getClass().getResource("component-example.json"))
.setSince("5.4")
.setChangelog(
+ new Change("10.8", format("The following metrics are not deprecated anymore: %s",
+ MeasuresWsModule.getUndeprecatedMetricsinSonarQube108())),
new Change("10.8", String.format("Added new accepted values for the 'metricKeys' param: %s",
MeasuresWsModule.getNewMetricsInSonarQube108())),
new Change("10.8", String.format("The metrics %s are now deprecated. Use 'software_quality_maintainability_issues', " +
@@ -100,7 +102,7 @@ public class ComponentAction implements MeasuresWsAction {
MeasuresWsModule.getDeprecatedMetricsInSonarQube108())),
new Change("10.7", "Added new accepted values for the 'metricKeys' param: %s".formatted(MeasuresWsModule.getNewMetricsInSonarQube107())),
new Change("10.5", String.format("The metrics %s are now deprecated " +
- "without exact replacement. Use 'maintainability_issues', 'reliability_issues' and 'security_issues' instead.",
+ "without exact replacement. Use 'maintainability_issues', 'reliability_issues' and 'security_issues' instead.",
MeasuresWsModule.getDeprecatedMetricsInSonarQube105())),
new Change("10.5", "Added new accepted values for the 'metricKeys' param: 'new_maintainability_issues', 'new_reliability_issues', 'new_security_issues'"),
new Change("10.4", String.format("The metrics %s are now deprecated " +
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java
index 8c8d5565677..d6d8bc8fc91 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java
@@ -110,8 +110,8 @@ import static org.sonar.server.measure.ws.SnapshotDtoToWsPeriod.snapshotToWsPeri
import static org.sonar.server.ws.KeyExamples.KEY_BRANCH_EXAMPLE_001;
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
import static org.sonar.server.ws.KeyExamples.KEY_PULL_REQUEST_EXAMPLE_001;
-import static org.sonar.server.ws.WsParameterBuilder.QualifierParameterContext.newQualifierParameterContext;
import static org.sonar.server.ws.WsParameterBuilder.createQualifiersParameter;
+import static org.sonar.server.ws.WsParameterBuilder.QualifierParameterContext.newQualifierParameterContext;
import static org.sonar.server.ws.WsUtils.writeProtobuf;
/**
@@ -182,6 +182,8 @@ public class ComponentTreeAction implements MeasuresWsAction {
.setHandler(this)
.addPagingParams(100, MAX_SIZE)
.setChangelog(
+ new Change("10.8", String.format("The following metrics are not deprecated anymore: %s",
+ MeasuresWsModule.getUndeprecatedMetricsinSonarQube108())),
new Change("10.8", String.format("Added new accepted values for the 'metricKeys' param: %s",
MeasuresWsModule.getNewMetricsInSonarQube108())),
new Change("10.8", String.format("The metrics %s are now deprecated. Use 'software_quality_maintainability_issues', " +
@@ -194,12 +196,12 @@ public class ComponentTreeAction implements MeasuresWsAction {
new Change("10.5", "Added new accepted values for the 'metricKeys' param: 'new_maintainability_issues', 'new_reliability_issues'," +
" 'new_security_issues'"),
new Change("10.5", format("The metrics %s are now deprecated " +
- "without exact replacement. Use 'maintainability_issues', 'reliability_issues' and 'security_issues' instead.",
+ "without exact replacement. Use 'maintainability_issues', 'reliability_issues' and 'security_issues' instead.",
MeasuresWsModule.getDeprecatedMetricsInSonarQube105())),
new Change("10.5", "Added new accepted values for the 'metricKeys' param: 'maintainability_issues', 'reliability_issues', " +
"'security_issues'"),
new Change("10.4", format("The metrics %s are now deprecated " +
- "without exact replacement. Use 'maintainability_issues', 'reliability_issues' and 'security_issues' instead.",
+ "without exact replacement. Use 'maintainability_issues', 'reliability_issues' and 'security_issues' instead.",
MeasuresWsModule.getDeprecatedMetricsInSonarQube104())),
new Change("10.4", "The metrics 'open_issues', 'reopened_issues' and 'confirmed_issues' are now deprecated in the response. " +
"Consume 'violations' instead."),
@@ -316,7 +318,7 @@ public class ComponentTreeAction implements MeasuresWsAction {
request,
data,
Paging.forPageIndex(
- request.getPage())
+ request.getPage())
.withPageSize(request.getPageSize())
.andTotal(data.getComponentCount()),
request.getMetricKeys());
@@ -478,8 +480,7 @@ public class ComponentTreeAction implements MeasuresWsAction {
List<MetricDto> metrics = searchMetrics(dbSession,
new HashSet<>(withRemovedMetricAlias(ofNullable(wsRequest.getMetricKeys()).orElse(List.of()))));
- Table<String, MetricDto, ComponentTreeData.Measure> measuresByComponentUuidAndMetric =
- searchMeasuresByComponentUuidAndMetric(dbSession, baseComponent, componentTreeQuery,
+ Table<String, MetricDto, ComponentTreeData.Measure> measuresByComponentUuidAndMetric = searchMeasuresByComponentUuidAndMetric(dbSession, baseComponent, componentTreeQuery,
components, metrics);
components = filterComponents(components, measuresByComponentUuidAndMetric, metrics, wsRequest);
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/MeasuresWsModule.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/MeasuresWsModule.java
index 38d2263f782..cb24f754176 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/MeasuresWsModule.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/MeasuresWsModule.java
@@ -76,37 +76,41 @@ public class MeasuresWsModule extends Module {
public static String getNewMetricsInSonarQube108() {
return Stream.of(
- SoftwareQualitiesMetrics.SOFTWARE_QUALITY_BLOCKER_ISSUES,
- SoftwareQualitiesMetrics.SOFTWARE_QUALITY_HIGH_ISSUES,
- SoftwareQualitiesMetrics.SOFTWARE_QUALITY_INFO_ISSUES,
- SoftwareQualitiesMetrics.SOFTWARE_QUALITY_MEDIUM_ISSUES,
- SoftwareQualitiesMetrics.SOFTWARE_QUALITY_LOW_ISSUES,
- SoftwareQualitiesMetrics.SOFTWARE_QUALITY_MAINTAINABILITY_ISSUES,
- SoftwareQualitiesMetrics.SOFTWARE_QUALITY_RELIABILITY_ISSUES,
- SoftwareQualitiesMetrics.SOFTWARE_QUALITY_SECURITY_ISSUES,
+ SoftwareQualitiesMetrics.SOFTWARE_QUALITY_BLOCKER_ISSUES,
+ SoftwareQualitiesMetrics.SOFTWARE_QUALITY_HIGH_ISSUES,
+ SoftwareQualitiesMetrics.SOFTWARE_QUALITY_INFO_ISSUES,
+ SoftwareQualitiesMetrics.SOFTWARE_QUALITY_MEDIUM_ISSUES,
+ SoftwareQualitiesMetrics.SOFTWARE_QUALITY_LOW_ISSUES,
+ SoftwareQualitiesMetrics.SOFTWARE_QUALITY_MAINTAINABILITY_ISSUES,
+ SoftwareQualitiesMetrics.SOFTWARE_QUALITY_RELIABILITY_ISSUES,
+ SoftwareQualitiesMetrics.SOFTWARE_QUALITY_SECURITY_ISSUES,
- SoftwareQualitiesMetrics.NEW_SOFTWARE_QUALITY_BLOCKER_ISSUES,
- SoftwareQualitiesMetrics.NEW_SOFTWARE_QUALITY_HIGH_ISSUES,
- SoftwareQualitiesMetrics.NEW_SOFTWARE_QUALITY_INFO_ISSUES,
- SoftwareQualitiesMetrics.NEW_SOFTWARE_QUALITY_MEDIUM_ISSUES,
- SoftwareQualitiesMetrics.NEW_SOFTWARE_QUALITY_LOW_ISSUES,
- SoftwareQualitiesMetrics.NEW_SOFTWARE_QUALITY_MAINTAINABILITY_ISSUES,
- SoftwareQualitiesMetrics.NEW_SOFTWARE_QUALITY_RELIABILITY_ISSUES,
- SoftwareQualitiesMetrics.NEW_SOFTWARE_QUALITY_SECURITY_ISSUES)
+ SoftwareQualitiesMetrics.NEW_SOFTWARE_QUALITY_BLOCKER_ISSUES,
+ SoftwareQualitiesMetrics.NEW_SOFTWARE_QUALITY_HIGH_ISSUES,
+ SoftwareQualitiesMetrics.NEW_SOFTWARE_QUALITY_INFO_ISSUES,
+ SoftwareQualitiesMetrics.NEW_SOFTWARE_QUALITY_MEDIUM_ISSUES,
+ SoftwareQualitiesMetrics.NEW_SOFTWARE_QUALITY_LOW_ISSUES,
+ SoftwareQualitiesMetrics.NEW_SOFTWARE_QUALITY_MAINTAINABILITY_ISSUES,
+ SoftwareQualitiesMetrics.NEW_SOFTWARE_QUALITY_RELIABILITY_ISSUES,
+ SoftwareQualitiesMetrics.NEW_SOFTWARE_QUALITY_SECURITY_ISSUES)
.map(e -> "'" + e.getKey() + "'")
.collect(Collectors.joining(", "));
}
public static String getDeprecatedMetricsInSonarQube108() {
return Stream.of(
- CoreMetrics.MAINTAINABILITY_ISSUES_KEY,
- CoreMetrics.RELIABILITY_ISSUES_KEY,
- CoreMetrics.SECURITY_ISSUES_KEY,
+ CoreMetrics.MAINTAINABILITY_ISSUES_KEY,
+ CoreMetrics.RELIABILITY_ISSUES_KEY,
+ CoreMetrics.SECURITY_ISSUES_KEY,
- CoreMetrics.NEW_MAINTAINABILITY_ISSUES_KEY,
- CoreMetrics.NEW_RELIABILITY_ISSUES_KEY,
- CoreMetrics.NEW_SECURITY_ISSUES_KEY)
+ CoreMetrics.NEW_MAINTAINABILITY_ISSUES_KEY,
+ CoreMetrics.NEW_RELIABILITY_ISSUES_KEY,
+ CoreMetrics.NEW_SECURITY_ISSUES_KEY)
.map(e -> "'" + e + "'")
.collect(Collectors.joining(", "));
}
+
+ public static String getUndeprecatedMetricsinSonarQube108() {
+ return getDeprecatedMetricsInSonarQube104() + ", " + getDeprecatedMetricsInSonarQube105();
+ }
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchAction.java
index f19ef866e3c..a48b549934c 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchAction.java
@@ -87,6 +87,7 @@ public class SearchAction implements MeasuresWsAction {
.setResponseExample(getClass().getResource("search-example.json"))
.setHandler(this)
.setChangelog(
+ new Change("10.8", format("The following metrics are not deprecated anymore: %s", MeasuresWsModule.getUndeprecatedMetricsinSonarQube108())),
new Change("10.8", String.format("Added new accepted values for the 'metricKeys' param: %s",
MeasuresWsModule.getNewMetricsInSonarQube108())),
new Change("10.8", String.format("The metrics %s are now deprecated. Use 'software_quality_maintainability_issues', " +
@@ -95,11 +96,11 @@ public class SearchAction implements MeasuresWsAction {
MeasuresWsModule.getDeprecatedMetricsInSonarQube108())),
new Change("10.7", "Added new accepted values for the 'metricKeys' param: %s".formatted(MeasuresWsModule.getNewMetricsInSonarQube107())),
new Change("10.5", String.format("The metrics %s are now deprecated " +
- "without exact replacement. Use 'maintainability_issues', 'reliability_issues' and 'security_issues' instead.",
+ "without exact replacement. Use 'maintainability_issues', 'reliability_issues' and 'security_issues' instead.",
MeasuresWsModule.getDeprecatedMetricsInSonarQube105())),
new Change("10.5", "Added new accepted values for the 'metricKeys' param: 'new_maintainability_issues', 'new_reliability_issues', 'new_security_issues'"),
new Change("10.4", String.format("The metrics %s are now deprecated " +
- "without exact replacement. Use 'maintainability_issues', 'reliability_issues' and 'security_issues' instead.",
+ "without exact replacement. Use 'maintainability_issues', 'reliability_issues' and 'security_issues' instead.",
MeasuresWsModule.getDeprecatedMetricsInSonarQube104())),
new Change("10.4", "Added new accepted values for the 'metricKeys' param: 'maintainability_issues', 'reliability_issues', 'security_issues'"),
new Change("10.4", "The metrics 'open_issues', 'reopened_issues' and 'confirmed_issues' are now deprecated in the response. Consume 'violations' instead."),
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java
index 927587e28e5..777f0a8075c 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java
@@ -95,6 +95,8 @@ public class SearchHistoryAction implements MeasuresWsAction {
.setResponseExample(getClass().getResource("search_history-example.json"))
.setSince("6.3")
.setChangelog(
+ new Change("10.8", String.format("The following metrics are not deprecated anymore: %s",
+ MeasuresWsModule.getUndeprecatedMetricsinSonarQube108())),
new Change("10.8", String.format("Added new accepted values for the 'metricKeys' param: %s",
MeasuresWsModule.getNewMetricsInSonarQube108())),
new Change("10.8", String.format("The metrics %s are now deprecated. Use 'software_quality_maintainability_issues', " +
@@ -103,11 +105,11 @@ public class SearchHistoryAction implements MeasuresWsAction {
MeasuresWsModule.getDeprecatedMetricsInSonarQube108())),
new Change("10.7", "Added new accepted values for the 'metricKeys' param: %s".formatted(MeasuresWsModule.getNewMetricsInSonarQube107())),
new Change("10.5", String.format("The metrics %s are now deprecated " +
- "without exact replacement. Use 'maintainability_issues', 'reliability_issues' and 'security_issues' instead.",
+ "without exact replacement. Use 'maintainability_issues', 'reliability_issues' and 'security_issues' instead.",
MeasuresWsModule.getDeprecatedMetricsInSonarQube105())),
new Change("10.5", "Added new accepted values for the 'metricKeys' param: 'new_maintainability_issues', 'new_reliability_issues', 'new_security_issues'"),
new Change("10.4", String.format("The metrics %s are now deprecated " +
- "without exact replacement. Use 'maintainability_issues', 'reliability_issues' and 'security_issues' instead.",
+ "without exact replacement. Use 'maintainability_issues', 'reliability_issues' and 'security_issues' instead.",
MeasuresWsModule.getDeprecatedMetricsInSonarQube104())),
new Change("10.4", "The metrics 'open_issues', 'reopened_issues' and 'confirmed_issues' are now deprecated in the response. Consume 'violations' instead."),
new Change("10.4", "The use of 'open_issues', 'reopened_issues' and 'confirmed_issues' values in 'metricKeys' param are now deprecated. Use 'violations' instead."),
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/MeasuresWsModuleTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/MeasuresWsModuleTest.java
index 882e8d68af8..e37f9188619 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/MeasuresWsModuleTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/MeasuresWsModuleTest.java
@@ -76,4 +76,12 @@ class MeasuresWsModuleTest {
"'new_software_quality_medium_issues', 'new_software_quality_low_issues', 'new_software_quality_maintainability_issues', " +
"'new_software_quality_reliability_issues', 'new_software_quality_security_issues'");
}
+
+ @Test
+ void getUndeprecatedMetricsinSonarQube108_shouldReturnExactString() {
+ String actual = MeasuresWsModule.getUndeprecatedMetricsinSonarQube108();
+ assertThat(actual).isEqualTo("'bugs', 'new_bugs', 'vulnerabilities', 'new_vulnerabilities', 'code_smells', 'new_code_smells', 'high_impact_accepted_issues', " +
+ "'new_blocker_violations', 'new_critical_violations', 'new_major_violations', 'new_minor_violations', 'new_info_violations', 'blocker_violations', " +
+ "'critical_violations', 'major_violations', 'minor_violations', 'info_violations'");
+ }
}