diff options
6 files changed, 91 insertions, 12 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 a3cf37b30b3..03604616f1f 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 @@ -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.", 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 770adfcdf9b..8c8d5565677 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 @@ -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())), 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 16a11c4b5a5..38d2263f782 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 @@ -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(", ")); + } } 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 50d8ed92b93..f19ef866e3c 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,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.", 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 4519ffb796f..927587e28e5 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 @@ -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.", 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 1463035e7f1..882e8d68af8 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 @@ -19,21 +19,21 @@ */ 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'"); + } } |