summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2016-04-06 10:31:09 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2016-04-06 10:31:15 +0200
commitc7662baa5b3c54e0627f88796728e2e0da1f70fb (patch)
treec617fec7dc8da19a21e7003602489f0eb4eef11e /server
parent9e8e346e71b304fcf7aeb4e4f4c9a3c7107e1a53 (diff)
downloadsonarqube-c7662baa5b3c54e0627f88796728e2e0da1f70fb.tar.gz
sonarqube-c7662baa5b3c54e0627f88796728e2e0da1f70fb.zip
Fix quality flaws
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/measure/api/MeasureComputerContextImpl.java17
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/SetTypeAction.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/ws/IssuesWs.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/ws/SetTypeAction.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/NewCustomRule.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/ws/SearchAction.java6
7 files changed, 15 insertions, 20 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/measure/api/MeasureComputerContextImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/measure/api/MeasureComputerContextImpl.java
index 8a0c597be6e..d3112cdd51d 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/measure/api/MeasureComputerContextImpl.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/measure/api/MeasureComputerContextImpl.java
@@ -68,15 +68,6 @@ public class MeasureComputerContextImpl implements MeasureComputerContext {
this.componentIssues = componentIssuesRepository.getIssues(component);
}
- private Component newComponent(org.sonar.server.computation.component.Component component) {
- return new ComponentImpl(
- component.getKey(),
- Component.Type.valueOf(component.getType().name()),
- component.getType() == org.sonar.server.computation.component.Component.Type.FILE ?
- new ComponentImpl.FileAttributesImpl(component.getFileAttributes().getLanguageKey(), component.getFileAttributes().isUnitTest()) :
- null);
- }
-
/**
* Definition needs to be reset each time a new computer is processed.
* Defining it by a setter allows to reduce the number of this class to be created (one per component instead of one per component and per computer).
@@ -191,6 +182,14 @@ public class MeasureComputerContextImpl implements MeasureComputerContext {
return componentIssues;
}
+ private static Component newComponent(org.sonar.server.computation.component.Component component) {
+ return new ComponentImpl(
+ component.getKey(),
+ Component.Type.valueOf(component.getType().name()),
+ component.getType() == org.sonar.server.computation.component.Component.Type.FILE
+ ? new ComponentImpl.FileAttributesImpl(component.getFileAttributes().getLanguageKey(), component.getFileAttributes().isUnitTest()) : null);
+ }
+
private class ComponentToMeasure implements Function<org.sonar.server.computation.component.Component, Optional<org.sonar.server.computation.measure.Measure>> {
private final Metric metric;
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/SetTypeAction.java b/server/sonar-server/src/main/java/org/sonar/server/issue/SetTypeAction.java
index 9a7887cf23c..a1b2fbb1b98 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/SetTypeAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/SetTypeAction.java
@@ -58,7 +58,7 @@ public class SetTypeAction extends Action {
private static String newValue(Map<String, Object> properties) {
String type = (String) properties.get(TYPE_PARAMETER);
Preconditions.checkArgument(!isNullOrEmpty(type), "Missing parameter: '%s'", TYPE_PARAMETER);
- Preconditions.checkArgument(RuleType.ALL_NAMES.contains(type), "Unknown type: %s", type);
+ Preconditions.checkArgument(RuleType.names().contains(type), "Unknown type: %s", type);
return type;
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/IssuesWs.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/IssuesWs.java
index f79064ed211..8b0c4db9f28 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/IssuesWs.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/IssuesWs.java
@@ -164,7 +164,7 @@ public class IssuesWs implements WebService {
action.createParam("set_type.type")
.setDescription("To change the type of the list of issues")
.setExampleValue(RuleType.BUG)
- .setPossibleValues(RuleType.ALL_NAMES)
+ .setPossibleValues(RuleType.names())
.setSince("5.5");
action.createParam("plan.plan")
.setDescription("In 5.5, action plans are dropped. Has no effect. To plan the list of issues to a specific action plan (key), or unlink all the issues from an action plan")
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java
index bef890e4a95..09dfe2cb7db 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java
@@ -361,7 +361,7 @@ public class SearchAction implements IssuesWsAction {
addMandatoryValuesToFacet(facets, RULES, request.getRules());
addMandatoryValuesToFacet(facets, LANGUAGES, request.getLanguages());
addMandatoryValuesToFacet(facets, TAGS, request.getTags());
- addMandatoryValuesToFacet(facets, TYPES, RuleType.ALL_NAMES);
+ addMandatoryValuesToFacet(facets, TYPES, RuleType.names());
List<String> actionPlans = Lists.newArrayList("");
List<String> actionPlansFromRequest = request.getActionPlans();
if (actionPlansFromRequest != null) {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SetTypeAction.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SetTypeAction.java
index af082ffb670..d02b73cadea 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SetTypeAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SetTypeAction.java
@@ -53,7 +53,7 @@ public class SetTypeAction implements IssuesWsAction {
action.createParam("type")
.setDescription("New type")
.setRequired(true)
- .setPossibleValues(RuleType.ALL_NAMES);
+ .setPossibleValues(RuleType.names());
}
@Override
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/NewCustomRule.java b/server/sonar-server/src/main/java/org/sonar/server/rule/NewCustomRule.java
index 15c3314ddd7..f83be6f9511 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/rule/NewCustomRule.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/rule/NewCustomRule.java
@@ -104,10 +104,6 @@ public class NewCustomRule {
return this;
}
- public Map<String, String> parameters() {
- return parameters;
- }
-
@CheckForNull
public String parameter(final String paramKey) {
return parameters.get(paramKey);
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 d931ebf9162..f59dd90752c 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
@@ -434,7 +434,7 @@ public class SearchAction implements RulesWsAction {
addMandatoryFacetValues(results, FACET_SEVERITIES, Severity.ALL);
addMandatoryFacetValues(results, FACET_ACTIVE_SEVERITIES, Severity.ALL);
addMandatoryFacetValues(results, FACET_TAGS, request.getTags());
- addMandatoryFacetValues(results, FACET_TYPES, RuleType.ALL_NAMES);
+ addMandatoryFacetValues(results, FACET_TYPES, RuleType.names());
Common.Facet.Builder facet = Common.Facet.newBuilder();
Common.FacetValue.Builder value = Common.FacetValue.newBuilder();
@@ -478,10 +478,10 @@ public class SearchAction implements RulesWsAction {
}
}
- protected void addMandatoryFacetValues(SearchResult results, String facetName, @Nullable List<String> mandatoryValues) {
+ protected void addMandatoryFacetValues(SearchResult results, String facetName, @Nullable Collection<String> mandatoryValues) {
Map<String, Long> facetValues = results.facets.get(facetName);
if (facetValues != null) {
- List<String> valuesToAdd = mandatoryValues == null ? Lists.<String>newArrayList() : mandatoryValues;
+ Collection<String> valuesToAdd = mandatoryValues == null ? Lists.<String>newArrayList() : mandatoryValues;
for (String item : valuesToAdd) {
if (!facetValues.containsKey(item)) {
facetValues.put(item, 0L);