]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-23298 Update Changelog with new and deprecated metrics
authorOrlovAlexander <alexander.orlov@sonarsource.com>
Wed, 30 Oct 2024 15:41:16 +0000 (16:41 +0100)
committersonartech <sonartech@sonarsource.com>
Tue, 5 Nov 2024 20:03:02 +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 a3cf37b30b3d00e8e46295207d70f22e7607b1ba..03604616f1fe38df8541ebd96023fc9521ddfaf1 100644 (file)
@@ -92,6 +92,12 @@ public class ComponentAction implements MeasuresWsAction {
       .setResponseExample(getClass().getResource("component-example.json"))
       .setSince("5.4")
       .setChangelog(
+        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', " +
+          "'software_quality_reliability_issues', 'software_quality_security_issues', 'new_software_quality_maintainability_issues', " +
+          "'new_software_quality_reliability_issues', 'new_software_quality_security_issues' instead.",
+          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.",
index 770adfcdf9b09f5c176c467a537ff91793deac37..8c8d55656778fbc3b27488f0ed13fa5088593ca9 100644 (file)
@@ -43,9 +43,6 @@ import java.util.stream.Stream;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
-import org.sonar.db.component.ComponentQualifiers;
-import org.sonar.server.component.ComponentTypes;
-import org.sonar.db.component.ComponentScopes;
 import org.sonar.api.server.ws.Change;
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.Response;
@@ -58,6 +55,8 @@ 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.ComponentScopes;
 import org.sonar.db.component.ComponentTreeQuery;
 import org.sonar.db.component.ComponentTreeQuery.Strategy;
 import org.sonar.db.component.SnapshotDto;
@@ -66,6 +65,7 @@ import org.sonar.db.measure.MeasureTreeQuery;
 import org.sonar.db.metric.MetricDto;
 import org.sonar.db.metric.MetricDtoFunctions;
 import org.sonar.server.component.ComponentFinder;
+import org.sonar.server.component.ComponentTypes;
 import org.sonar.server.exceptions.NotFoundException;
 import org.sonar.server.user.UserSession;
 import org.sonarqube.ws.Measures;
@@ -182,6 +182,12 @@ public class ComponentTreeAction implements MeasuresWsAction {
       .setHandler(this)
       .addPagingParams(100, MAX_SIZE)
       .setChangelog(
+        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', " +
+          "'software_quality_reliability_issues', 'software_quality_security_issues', 'new_software_quality_maintainability_issues', " +
+          "'new_software_quality_reliability_issues', 'new_software_quality_security_issues' instead.",
+          MeasuresWsModule.getDeprecatedMetricsInSonarQube108())),
         new Change("10.7", format("Number of metric keys is limited to %s", 25)),
         new Change("10.7",
           "Added new accepted values for the 'metricKeys' param: %s".formatted(MeasuresWsModule.getNewMetricsInSonarQube107())),
index 16a11c4b5a5b34f9509921dcb673c4e840c1260a..38d2263f782ffed4e167c2e0ec3c13b708479929 100644 (file)
@@ -21,6 +21,7 @@ package org.sonar.server.measure.ws;
 
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
+import org.sonar.api.measures.CoreMetrics;
 import org.sonar.core.metric.SoftwareQualitiesMetrics;
 import org.sonar.core.platform.Module;
 
@@ -72,4 +73,40 @@ public class MeasuresWsModule extends Module {
       .map(e -> "'" + e.getKey() + "'")
       .collect(Collectors.joining(", "));
   }
+
+  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.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.NEW_MAINTAINABILITY_ISSUES_KEY,
+        CoreMetrics.NEW_RELIABILITY_ISSUES_KEY,
+        CoreMetrics.NEW_SECURITY_ISSUES_KEY)
+      .map(e -> "'" + e + "'")
+      .collect(Collectors.joining(", "));
+  }
 }
index 50d8ed92b93c3005f5caa2963a3464f4e523fad6..f19ef866e3c551d6f8d54aed4b402b73b6ba3222 100644 (file)
@@ -87,6 +87,12 @@ public class SearchAction implements MeasuresWsAction {
       .setResponseExample(getClass().getResource("search-example.json"))
       .setHandler(this)
       .setChangelog(
+        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', " +
+          "'software_quality_reliability_issues', 'software_quality_security_issues', 'new_software_quality_maintainability_issues', " +
+          "'new_software_quality_reliability_issues', 'new_software_quality_security_issues' instead.",
+          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.",
index 4519ffb796f94adf34e6238e65811afc72237345..927587e28e5e7c55c00cac7839ab3faa52f647ec 100644 (file)
@@ -29,8 +29,6 @@ import java.util.function.Function;
 import java.util.stream.Collectors;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
-import org.sonar.db.component.ComponentQualifiers;
-import org.sonar.db.component.ComponentScopes;
 import org.sonar.api.server.ws.Change;
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.Response;
@@ -40,12 +38,14 @@ import org.sonar.api.web.UserRole;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentQualifiers;
+import org.sonar.db.component.ComponentScopes;
 import org.sonar.db.component.SnapshotDto;
 import org.sonar.db.component.SnapshotQuery;
 import org.sonar.db.component.SnapshotQuery.SORT_FIELD;
 import org.sonar.db.component.SnapshotQuery.SORT_ORDER;
-import org.sonar.db.measure.ProjectMeasureDto;
 import org.sonar.db.measure.PastMeasureQuery;
+import org.sonar.db.measure.ProjectMeasureDto;
 import org.sonar.db.metric.MetricDto;
 import org.sonar.db.metric.RemovedMetricConverter;
 import org.sonar.server.component.ComponentFinder;
@@ -95,6 +95,12 @@ public class SearchHistoryAction implements MeasuresWsAction {
       .setResponseExample(getClass().getResource("search_history-example.json"))
       .setSince("6.3")
       .setChangelog(
+        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', " +
+          "'software_quality_reliability_issues', 'software_quality_security_issues', 'new_software_quality_maintainability_issues', " +
+          "'new_software_quality_reliability_issues', 'new_software_quality_security_issues' instead.",
+          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.",
index 1463035e7f1efbe818dda36a8a5a18e0747aadb6..882e8d68af80f6b3ba9d2577fabf89c216a909c0 100644 (file)
  */
 package org.sonar.server.measure.ws;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.sonar.core.platform.ListContainer;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-public class MeasuresWsModuleTest {
+class MeasuresWsModuleTest {
   @Test
-  public void verify_count_of_added_components() {
+  void verify_count_of_added_components() {
     ListContainer container = new ListContainer();
     new MeasuresWsModule().configure(container);
     assertThat(container.getAddedObjects()).hasSize(5);
   }
 
   @Test
-  public void getDeprecatedMetricsInSonarQube104_shouldReturnExactString() {
+  void getDeprecatedMetricsInSonarQube104_shouldReturnExactString() {
     String actual = MeasuresWsModule.getDeprecatedMetricsInSonarQube104();
 
     assertThat(actual).isEqualTo("'bugs', 'new_bugs', 'vulnerabilities', 'new_vulnerabilities', 'code_smells', 'new_code_smells', " +
@@ -41,7 +41,7 @@ public class MeasuresWsModuleTest {
   }
 
   @Test
-  public void getDeprecatedMetricsInSonarQube105_shouldReturnExactString() {
+  void getDeprecatedMetricsInSonarQube105_shouldReturnExactString() {
     String actual = MeasuresWsModule.getDeprecatedMetricsInSonarQube105();
 
     assertThat(actual).isEqualTo("'new_blocker_violations', 'new_critical_violations', 'new_major_violations', 'new_minor_violations', " +
@@ -49,7 +49,7 @@ public class MeasuresWsModuleTest {
   }
 
   @Test
-  public void getNewMetricsInSonarQube107_shouldReturnExactString() {
+  void getNewMetricsInSonarQube107_shouldReturnExactString() {
     String actual = MeasuresWsModule.getNewMetricsInSonarQube107();
     assertThat(actual).isEqualTo("'software_quality_maintainability_debt_ratio', 'software_quality_maintainability_rating', 'software_quality_reliability_rating', " +
       "'software_quality_security_rating', 'software_quality_maintainability_remediation_effort', " +
@@ -58,4 +58,22 @@ public class MeasuresWsModuleTest {
       "'new_software_quality_security_rating', 'new_software_quality_maintainability_remediation_effort'," +
       " 'new_software_quality_reliability_remediation_effort', 'new_software_quality_security_remediation_effort'");
   }
+
+  @Test
+  void getDeprecatedMetricsInSonarQube108_shouldReturnExactString() {
+    String actual = MeasuresWsModule.getDeprecatedMetricsInSonarQube108();
+    assertThat(actual).isEqualTo("'maintainability_issues', 'reliability_issues', 'security_issues', " +
+      "'new_maintainability_issues', 'new_reliability_issues', 'new_security_issues'");
+  }
+
+  @Test
+  void getNewMetricsInSonarQube108_shouldReturnExactString() {
+    String actual = MeasuresWsModule.getNewMetricsInSonarQube108();
+    assertThat(actual).isEqualTo("'software_quality_blocker_issues', 'software_quality_high_issues', 'software_quality_info_issues', " +
+      "'software_quality_medium_issues', 'software_quality_low_issues', 'software_quality_maintainability_issues', " +
+      "'software_quality_reliability_issues', 'software_quality_security_issues', " +
+      "'new_software_quality_blocker_issues', 'new_software_quality_high_issues', 'new_software_quality_info_issues', " +
+      "'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'");
+  }
 }