From ee47277536e2efb0242cd1b8897c88d583f06a03 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Mon, 5 Sep 2016 15:20:09 +0200 Subject: [PATCH] fix quality flaws --- .../permission/ws/TemplateGroupsAction.java | 2 +- .../sonar/server/rule/ws/SearchAction.java | 37 +++++++++++-------- .../sonar/server/setting/ws/ValuesAction.java | 2 +- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/TemplateGroupsAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/TemplateGroupsAction.java index 8b5f70be6e0..db72eaf405d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/TemplateGroupsAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/TemplateGroupsAction.java @@ -74,7 +74,7 @@ public class TemplateGroupsAction implements PermissionsWsAction { .setResponseExample(getClass().getResource("template_groups-example.json")) .setHandler(this); - action.createParam(WebService.Param.TEXT_QUERY) + action.createParam(TEXT_QUERY) .setDescription("Limit search to group names that contain the supplied string. Must have at least %d characters.
" + "When this parameter is not set, only group having at least one permission are returned.", SEARCH_QUERY_MIN_LENGTH) .setExampleValue("eri"); diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/SearchAction.java index b74efc088bf..ae7a0b8600d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/SearchAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/SearchAction.java @@ -46,7 +46,6 @@ import org.sonar.api.rules.RuleType; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; -import org.sonar.api.server.ws.WebService.Param; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.rule.RuleDto; @@ -63,6 +62,14 @@ import org.sonarqube.ws.Rules.SearchResponse; import org.sonarqube.ws.client.rule.SearchWsRequest; import static com.google.common.collect.FluentIterable.from; +import static org.sonar.api.server.ws.WebService.Param.ASCENDING; +import static org.sonar.api.server.ws.WebService.Param.FACETS; +import static org.sonar.api.server.ws.WebService.Param.FIELDS; +import static org.sonar.api.server.ws.WebService.Param.PAGE; +import static org.sonar.api.server.ws.WebService.Param.PAGE_SIZE; +import static org.sonar.api.server.ws.WebService.Param.SORT; +import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY; +import static org.sonar.server.es.SearchOptions.MAX_LIMIT; import static org.sonar.server.rule.index.RuleIndex.ALL_STATUSES_EXCEPT_REMOVED; import static org.sonar.server.rule.index.RuleIndex.FACET_ACTIVE_SEVERITIES; import static org.sonar.server.rule.index.RuleIndex.FACET_LANGUAGES; @@ -114,11 +121,11 @@ public class SearchAction implements RulesWsAction { @Override public void define(WebService.NewController controller) { WebService.NewAction action = controller.createAction(ACTION) - .addPagingParams(100, org.sonar.server.es.SearchOptions.MAX_LIMIT) + .addPagingParams(100, MAX_LIMIT) .setHandler(this); Collection possibleFacets = possibleFacets(); - WebService.NewParam paramFacets = action.createParam(Param.FACETS) + WebService.NewParam paramFacets = action.createParam(FACETS) .setDescription("Comma-separated list of the facets to be computed. No facet is computed by default.") .setPossibleValues(possibleFacets); if (possibleFacets != null && possibleFacets.size() > 1) { @@ -126,7 +133,7 @@ public class SearchAction implements RulesWsAction { paramFacets.setExampleValue(String.format("%s,%s", it.next(), it.next())); } - WebService.NewParam paramFields = action.createParam(Param.FIELDS) + WebService.NewParam paramFields = action.createParam(FIELDS) .setDescription("Comma-separated list of the fields to be returned in response. All the fields are returned by default, except actives." + "Since 5.5, following fields have been deprecated :" + "