aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-server
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-12-08 18:26:00 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-12-08 18:26:00 +0100
commit3b1f36e32ba88d4e815869cb91aed6901cf102e3 (patch)
tree1dfd40397ce4e4bab68cb326ee1ca6572b57d11e /server/sonar-server
parenta060b930acec945a80cbecbba92db66e5f859a91 (diff)
downloadsonarqube-3b1f36e32ba88d4e815869cb91aed6901cf102e3.tar.gz
sonarqube-3b1f36e32ba88d4e815869cb91aed6901cf102e3.zip
Revert "SONAR-5844 Profile inheritance is always displaying '0 rules' whatever the content of Profiles"
This reverts commit a060b930acec945a80cbecbba92db66e5f859a91.
Diffstat (limited to 'server/sonar-server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterFactory.java25
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/measure/MeasureFilterFactoryTest.java2
2 files changed, 13 insertions, 14 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterFactory.java b/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterFactory.java
index d572a320bfa..bb6dcdda810 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterFactory.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterFactory.java
@@ -123,7 +123,7 @@ public class MeasureFilterFactory implements ServerComponent {
}
}
- private List<String> sortFieldLabels() {
+ private List<String> sortFieldLabels(){
return newArrayList(Iterables.transform(Arrays.asList(MeasureFilterSort.Field.values()), new Function<MeasureFilterSort.Field, String>() {
@Override
public String apply(@Nullable MeasureFilterSort.Field input) {
@@ -155,23 +155,22 @@ public class MeasureFilterFactory implements ServerComponent {
if (alertLevels == null || alertLevels.isEmpty()) {
return null;
}
- final List<String> availableLevels = Lists.transform(Arrays.asList(Metric.Level.values()), new Function<Metric.Level, String>() {
- @Override
- public String apply(@Nullable Metric.Level input) {
- return input != null ? input.name() : null;
- }
- });
-
+ MeasureFilterCondition condition = null;
+ String metricKey = CoreMetrics.ALERT_STATUS_KEY;
+ String op = "in";
List<String> alertLevelsUppercase = Lists.transform(alertLevels, new Function<String, String>() {
@Override
public String apply(@Nullable String input) {
- return input != null && availableLevels.contains(input.toUpperCase()) ? input.toUpperCase() : null;
+ return input != null ? input.toUpperCase() : "";
}
});
- String val = "('" + Joiner.on("', '").skipNulls().join(alertLevelsUppercase) + "')";
- Metric metric = metricFinder.findByKey(CoreMetrics.ALERT_STATUS_KEY);
- MeasureFilterCondition.Operator operator = MeasureFilterCondition.Operator.fromCode("in");
- return new MeasureFilterCondition(metric, operator, val);
+ String val = "('" + Joiner.on("', '").join(alertLevelsUppercase) + "')";
+ if (!Strings.isNullOrEmpty(metricKey) && !Strings.isNullOrEmpty(op) && !Strings.isNullOrEmpty(val)) {
+ Metric metric = metricFinder.findByKey(metricKey);
+ MeasureFilterCondition.Operator operator = MeasureFilterCondition.Operator.fromCode(op);
+ condition = new MeasureFilterCondition(metric, operator, val);
+ }
+ return condition;
}
private List<String> toList(@Nullable Object obj) {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/MeasureFilterFactoryTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/MeasureFilterFactoryTest.java
index cd2b01ea4a9..20cc5872bee 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/measure/MeasureFilterFactoryTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/measure/MeasureFilterFactoryTest.java
@@ -195,7 +195,7 @@ public class MeasureFilterFactoryTest {
public void alert_level_condition() {
MeasureFilterFactory factory = new MeasureFilterFactory(newMetricFinder(), system);
Map<String, Object> props = ImmutableMap.<String, Object>of(
- "alertLevels", Arrays.asList("error", "warn", "unknown")
+ "alertLevels", Arrays.asList("error", "warn")
);
MeasureFilter filter = factory.create(props);