.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.",
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;
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;
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;
.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())),
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;
.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(", "));
+ }
}
.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.",
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;
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;
.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.",
*/
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', " +
}
@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', " +
}
@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', " +
"'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'");
+ }
}