import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-import org.sonar.db.component.ComponentQualifiers;
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.SnapshotDto;
import org.sonar.db.measure.MeasureDto;
import org.sonar.db.metric.MetricDto;
public void define(WebService.NewController context) {
WebService.NewAction action = context.createAction(ACTION_COMPONENT)
.setDescription("Return component with specified measures.<br>" +
- "Requires the following permission: 'Browse' on the project of specified component.")
+ "Requires the following permission: 'Browse' on the project of specified component.")
.setResponseExample(getClass().getResource("component-example.json"))
.setSince("5.4")
.setChangelog(
+ new Change("10.8", format("The following metrics are not deprecated anymore: %s",
+ MeasuresWsModule.getUndeprecatedMetricsinSonarQube108())),
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', " +
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.",
+ "without exact replacement. Use 'maintainability_issues', 'reliability_issues' and 'security_issues' instead.",
MeasuresWsModule.getDeprecatedMetricsInSonarQube105())),
new Change("10.5", "Added new accepted values for the 'metricKeys' param: 'new_maintainability_issues', 'new_reliability_issues', 'new_security_issues'"),
new Change("10.4", String.format("The metrics %s are now deprecated " +
import static org.sonar.server.ws.KeyExamples.KEY_BRANCH_EXAMPLE_001;
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
import static org.sonar.server.ws.KeyExamples.KEY_PULL_REQUEST_EXAMPLE_001;
-import static org.sonar.server.ws.WsParameterBuilder.QualifierParameterContext.newQualifierParameterContext;
import static org.sonar.server.ws.WsParameterBuilder.createQualifiersParameter;
+import static org.sonar.server.ws.WsParameterBuilder.QualifierParameterContext.newQualifierParameterContext;
import static org.sonar.server.ws.WsUtils.writeProtobuf;
/**
.setHandler(this)
.addPagingParams(100, MAX_SIZE)
.setChangelog(
+ new Change("10.8", String.format("The following metrics are not deprecated anymore: %s",
+ MeasuresWsModule.getUndeprecatedMetricsinSonarQube108())),
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', " +
new Change("10.5", "Added new accepted values for the 'metricKeys' param: 'new_maintainability_issues', 'new_reliability_issues'," +
" 'new_security_issues'"),
new Change("10.5", format("The metrics %s are now deprecated " +
- "without exact replacement. Use 'maintainability_issues', 'reliability_issues' and 'security_issues' instead.",
+ "without exact replacement. Use 'maintainability_issues', 'reliability_issues' and 'security_issues' instead.",
MeasuresWsModule.getDeprecatedMetricsInSonarQube105())),
new Change("10.5", "Added new accepted values for the 'metricKeys' param: 'maintainability_issues', 'reliability_issues', " +
"'security_issues'"),
new Change("10.4", format("The metrics %s are now deprecated " +
- "without exact replacement. Use 'maintainability_issues', 'reliability_issues' and 'security_issues' instead.",
+ "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."),
request,
data,
Paging.forPageIndex(
- request.getPage())
+ request.getPage())
.withPageSize(request.getPageSize())
.andTotal(data.getComponentCount()),
request.getMetricKeys());
List<MetricDto> metrics = searchMetrics(dbSession,
new HashSet<>(withRemovedMetricAlias(ofNullable(wsRequest.getMetricKeys()).orElse(List.of()))));
- Table<String, MetricDto, ComponentTreeData.Measure> measuresByComponentUuidAndMetric =
- searchMeasuresByComponentUuidAndMetric(dbSession, baseComponent, componentTreeQuery,
+ Table<String, MetricDto, ComponentTreeData.Measure> measuresByComponentUuidAndMetric = searchMeasuresByComponentUuidAndMetric(dbSession, baseComponent, componentTreeQuery,
components, metrics);
components = filterComponents(components, measuresByComponentUuidAndMetric, metrics, wsRequest);
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.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)
+ 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.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)
+ CoreMetrics.NEW_MAINTAINABILITY_ISSUES_KEY,
+ CoreMetrics.NEW_RELIABILITY_ISSUES_KEY,
+ CoreMetrics.NEW_SECURITY_ISSUES_KEY)
.map(e -> "'" + e + "'")
.collect(Collectors.joining(", "));
}
+
+ public static String getUndeprecatedMetricsinSonarQube108() {
+ return getDeprecatedMetricsInSonarQube104() + ", " + getDeprecatedMetricsInSonarQube105();
+ }
}
.setResponseExample(getClass().getResource("search-example.json"))
.setHandler(this)
.setChangelog(
+ new Change("10.8", format("The following metrics are not deprecated anymore: %s", MeasuresWsModule.getUndeprecatedMetricsinSonarQube108())),
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', " +
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.",
+ "without exact replacement. Use 'maintainability_issues', 'reliability_issues' and 'security_issues' instead.",
MeasuresWsModule.getDeprecatedMetricsInSonarQube105())),
new Change("10.5", "Added new accepted values for the 'metricKeys' param: 'new_maintainability_issues', 'new_reliability_issues', 'new_security_issues'"),
new Change("10.4", String.format("The metrics %s are now deprecated " +
- "without exact replacement. Use 'maintainability_issues', 'reliability_issues' and 'security_issues' instead.",
+ "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."),
.setResponseExample(getClass().getResource("search_history-example.json"))
.setSince("6.3")
.setChangelog(
+ new Change("10.8", String.format("The following metrics are not deprecated anymore: %s",
+ MeasuresWsModule.getUndeprecatedMetricsinSonarQube108())),
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', " +
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.",
+ "without exact replacement. Use 'maintainability_issues', 'reliability_issues' and 'security_issues' instead.",
MeasuresWsModule.getDeprecatedMetricsInSonarQube105())),
new Change("10.5", "Added new accepted values for the 'metricKeys' param: 'new_maintainability_issues', 'new_reliability_issues', 'new_security_issues'"),
new Change("10.4", String.format("The metrics %s are now deprecated " +
- "without exact replacement. Use 'maintainability_issues', 'reliability_issues' and 'security_issues' instead.",
+ "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_software_quality_medium_issues', 'new_software_quality_low_issues', 'new_software_quality_maintainability_issues', " +
"'new_software_quality_reliability_issues', 'new_software_quality_security_issues'");
}
+
+ @Test
+ void getUndeprecatedMetricsinSonarQube108_shouldReturnExactString() {
+ String actual = MeasuresWsModule.getUndeprecatedMetricsinSonarQube108();
+ assertThat(actual).isEqualTo("'bugs', 'new_bugs', 'vulnerabilities', 'new_vulnerabilities', 'code_smells', 'new_code_smells', 'high_impact_accepted_issues', " +
+ "'new_blocker_violations', 'new_critical_violations', 'new_major_violations', 'new_minor_violations', 'new_info_violations', 'blocker_violations', " +
+ "'critical_violations', 'major_violations', 'minor_violations', 'info_violations'");
+ }
}