ソースを参照

Fix quality flaws

tags/6.3-RC1
Teryk Bellahsene 7年前
コミット
e52ca10a4a

+ 17
- 16
server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java ファイルの表示

@@ -369,25 +369,26 @@ public class SearchAction implements IssuesWsAction {
addMandatoryValuesToFacet(facets, PARAM_TYPES, RuleType.names());
addMandatoryValuesToFacet(facets, PARAM_COMPONENT_UUIDS, request.getComponentUuids());

for (String facetName : request.getFacets()) {
LinkedHashMap<String, Long> buckets = facets.get(facetName);
if (!FACET_ASSIGNED_TO_ME.equals(facetName)) {
if (buckets != null) {
List<String> requestParams = wsRequest.paramAsStrings(facetName);
if (requestParams != null) {
for (String param : requestParams) {
if (!buckets.containsKey(param) && !IssueQueryService.LOGIN_MYSELF.equals(param)) {
// Prevent appearance of a glitch value due to dedicated parameter for this facet
buckets.put(param, 0L);
}
}
}
}
}
List<String> requestedFacets = request.getFacets();
if (requestedFacets == null) {
return;
}
requestedFacets.stream()
.filter(facetName -> !FACET_ASSIGNED_TO_ME.equals(facetName))
.forEach(facetName -> {
LinkedHashMap<String, Long> buckets = facets.get(facetName);
List<String> requestParams = wsRequest.paramAsStrings(facetName);
if (buckets == null || requestParams == null) {
return;
}
requestParams.stream()
.filter(param -> !buckets.containsKey(param) && !IssueQueryService.LOGIN_MYSELF.equals(param))
// Prevent appearance of a glitch value due to dedicated parameter for this facet
.forEach(param -> buckets.put(param, 0L));
});
}

private void addMandatoryValuesToFacet(Facets facets, String facetName, @Nullable Iterable<String> mandatoryValues) {
private static void addMandatoryValuesToFacet(Facets facets, String facetName, @Nullable Iterable<String> mandatoryValues) {
Map<String, Long> buckets = facets.get(facetName);
if (buckets != null && mandatoryValues != null) {
for (String mandatoryValue : mandatoryValues) {

+ 4
- 12
server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ProjectStatusAction.java ファイルの表示

@@ -19,13 +19,10 @@
*/
package org.sonar.server.qualitygate.ws;

import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nonnull;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.server.ws.Request;
@@ -59,14 +56,9 @@ import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_PROJECT_KEY;

public class ProjectStatusAction implements QualityGatesWsAction {
private static final String QG_STATUSES_ONE_LINE = Joiner.on(", ")
.join(Lists.transform(Arrays.asList(ProjectStatusWsResponse.Status.values()), new Function<ProjectStatusWsResponse.Status, String>() {
@Nonnull
@Override
public String apply(@Nonnull ProjectStatusWsResponse.Status input) {
return input.toString();
}
}));
private static final String QG_STATUSES_ONE_LINE = Arrays.stream(ProjectStatusWsResponse.Status.values())
.map(Enum::toString)
.collect(Collectors.joining(", "));
private static final String MSG_ONE_PARAMETER_ONLY = String.format("One (and only one) of the following parameters must be provided '%s', '%s', '%s'",
PARAM_ANALYSIS_ID, PARAM_PROJECT_ID, PARAM_PROJECT_KEY);


+ 3
- 4
sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java ファイルの表示

@@ -191,7 +191,7 @@ public interface WebService extends Definable<WebService.Context> {
private final Map<String, Action> actions;

private Controller(NewController newController) {
checkState(!newController.actions.isEmpty(), format("At least one action must be declared in the web service '%s'", newController.path));
checkState(!newController.actions.isEmpty(), "At least one action must be declared in the web service '%s'", newController.path);
this.path = newController.path;
this.description = newController.description;
this.since = newController.since;
@@ -327,8 +327,7 @@ public interface WebService extends Definable<WebService.Context> {
}

public NewParam createParam(String paramKey) {
checkState(!newParams.containsKey(paramKey),
format("The parameter '%s' is defined multiple times in the action '%s'", paramKey, key));
checkState(!newParams.containsKey(paramKey), "The parameter '%s' is defined multiple times in the action '%s'", paramKey, key);
NewParam newParam = new NewParam(paramKey);
newParams.put(paramKey, newParam);
return newParam;
@@ -485,7 +484,7 @@ public interface WebService extends Definable<WebService.Context> {
this.responseExample = newAction.responseExample;
this.handler = newAction.handler;

checkState(this.handler != null, "RequestHandler is not set on action " + path);
checkState(this.handler != null, "RequestHandler is not set on action %s", path);
logWarningIf(isNullOrEmpty(this.description), "Description is not set on action " + path);
logWarningIf(isNullOrEmpty(this.since), "Since is not set on action " + path);
logWarningIf(!this.post && this.responseExample == null, "The response example is not set on action " + path);

+ 1
- 1
sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/UpdateEventRequest.java ファイルの表示

@@ -30,7 +30,7 @@ public class UpdateEventRequest {

public UpdateEventRequest(String event, String name) {
this.event = requireNonNull(event, "Event key is required");
this.name = requireNonNull(name, "Name is required");;
this.name = requireNonNull(name, "Name is required");
}

public String getEvent() {

読み込み中…
キャンセル
保存