]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-21455 Deprecate metrics in the api/measures/* endpoints
authorlukasz-jarocki-sonarsource <lukasz.jarocki@sonarsource.com>
Tue, 30 Jan 2024 08:23:22 +0000 (09:23 +0100)
committersonartech <sonartech@sonarsource.com>
Wed, 31 Jan 2024 20:03:37 +0000 (20:03 +0000)
server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/MeasuresWsModule.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/MeasuresWsModuleTest.java

index df415e0af1c37602575caef33e543bed04147c96..58a82e30f159196b69db2f7dae0d1404bcfa344c 100644 (file)
@@ -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."),
index f2589b804894d035377775c469be42eda71ee052..a888f34e9ae30313c5866fc658845ac4a91423c6 100644 (file)
@@ -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."),
index cd763c65c9f1ef09f5144f6fa3b68d2d6883c24d..a0027a8cd5caa668a3ece67e4fe1dae703fcfa11 100644 (file)
@@ -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") + "'";
   }
 }
index 28100a08242f0a2e00d79d7c306a326821646bb8..cb2ba56e9c2beb2253f0c72630c2124d16f7d26b 100644 (file)
@@ -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."),
index 2894feb547521d18f12406adbeeb7f0adcefa515..6fcf78f738abf9e668cd7dc34de2b79b201eae65 100644 (file)
@@ -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."),
index 9472e325c5fc75c10b409ed2fc8fe37a7e245331..21a72478a1063a269833eb71196f39c23a7b8e78 100644 (file)
@@ -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'");
+  }
 }