diff options
author | lukasz-jarocki-sonarsource <lukasz.jarocki@sonarsource.com> | 2024-01-30 09:23:22 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-01-31 20:03:37 +0000 |
commit | 77027be15e99aab7b571783c4c6f91702ade8c03 (patch) | |
tree | fcc599168ecbfb3473b0c9058e0f6d290eec3694 | |
parent | 1965bd78437531eb63bd166ea8d08dc8e06a1886 (diff) | |
download | sonarqube-77027be15e99aab7b571783c4c6f91702ade8c03.tar.gz sonarqube-77027be15e99aab7b571783c4c6f91702ade8c03.zip |
SONAR-21455 Deprecate metrics in the api/measures/* endpoints
6 files changed, 28 insertions, 2 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 df415e0af1c..58a82e30f15 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 @@ -96,6 +96,9 @@ public class ComponentAction implements MeasuresWsAction { .setResponseExample(getClass().getResource("component-example.json")) .setSince("5.4") .setChangelog( + new Change("10.4", String.format("The metrics %s are now deprecated in the response " + + "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."), 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/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 f2589b80489..a888f34e9ae 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 @@ -181,6 +181,9 @@ public class ComponentTreeAction implements MeasuresWsAction { .setHandler(this) .addPagingParams(100, MAX_SIZE) .setChangelog( + new Change("10.4", String.format("The metrics %s are now deprecated in the response " + + "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."), 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/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 cd763c65c9f..a0027a8cd5c 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 @@ -34,8 +34,14 @@ public class MeasuresWsModule extends Module { public static String getDeprecatedMetricsInSonarQube93() { - return String.join(", ", "releasability_effort", "security_rating_effort", "reliability_rating_effort", "security_review_rating_effort", + return "'" + String.join("', '", "releasability_effort", "security_rating_effort", "reliability_rating_effort", "security_review_rating_effort", "maintainability_rating_effort", "last_change_on_maintainability_rating", "last_change_on_releasability_rating", "last_change_on_reliability_rating", - "last_change_on_security_rating", "last_change_on_security_review_rating"); + "last_change_on_security_rating", "last_change_on_security_review_rating") + "'"; + } + + public static String getDeprecatedMetricsInSonarQube104() { + return "'" + String.join("', '","bugs", "new_bugs", "vulnerabilities", "new_vulnerabilities", + "security_hotspots", "new_security_hotspots", "security_hotspots_reviewed", "new_security_hotspots_reviewed", + "code_smells", "new_code_smells") + "'"; } } 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 28100a08242..cb2ba56e9c2 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,9 @@ public class SearchAction implements MeasuresWsAction { .setResponseExample(getClass().getResource("search-example.json")) .setHandler(this) .setChangelog( + new Change("10.4", String.format("The metrics %s are now deprecated in the response " + + "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."), 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/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 2894feb5475..6fcf78f738a 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,9 @@ public class SearchHistoryAction implements MeasuresWsAction { .setResponseExample(getClass().getResource("search_history-example.json")) .setSince("6.3") .setChangelog( + new Change("10.4", String.format("The metrics %s are now deprecated in the response " + + "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."), new Change("10.4", "The metric 'wont_fix_issues' is now deprecated in the response. Consume 'accepted_issues' 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 9472e325c5f..21a72478a10 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 @@ -31,4 +31,12 @@ public class MeasuresWsModuleTest { new MeasuresWsModule().configure(container); assertThat(container.getAddedObjects()).hasSize(5); } + + @Test + public void getDeprecatedMetricsInSonarQube104_shouldReturnExactString() { + String actual = MeasuresWsModule.getDeprecatedMetricsInSonarQube104(); + + assertThat(actual).isEqualTo("'bugs', 'new_bugs', 'vulnerabilities', 'new_vulnerabilities', 'security_hotspots', " + + "'new_security_hotspots', 'security_hotspots_reviewed', 'new_security_hotspots_reviewed', 'code_smells', 'new_code_smells'"); + } } |