diff options
author | Jenkins CI <ci@sonarsource.com> | 2014-12-08 18:29:24 +0100 |
---|---|---|
committer | Jenkins CI <ci@sonarsource.com> | 2014-12-08 18:29:24 +0100 |
commit | a6320e1ba094d3d42a90e7ec871b1b04a9998a53 (patch) | |
tree | 20fddb3b6e447c28eea8a4ab66874204d6eb9ec9 /server | |
parent | 02ae6ed098db3b4b97cebcf02e727596a467bed4 (diff) | |
parent | 453af2ded25fd525a01f21c14791c32246660171 (diff) | |
download | sonarqube-a6320e1ba094d3d42a90e7ec871b1b04a9998a53.tar.gz sonarqube-a6320e1ba094d3d42a90e7ec871b1b04a9998a53.zip |
Automatic merge from branch-4.5
* origin/branch-4.5:
SSF-24 SQL Injection on Measures page
Revert "SONAR-5844 Profile inheritance is always displaying '0 rules' whatever the content of Profiles"
SONAR-5844 Profile inheritance is always displaying '0 rules' whatever the content of Profiles
SONAR-5902 Fix preserving of planned=false
Update documentation of PostJob extension
Diffstat (limited to 'server')
3 files changed, 19 insertions, 13 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 bb6dcdda810..d572a320bfa 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,22 +155,23 @@ public class MeasureFilterFactory implements ServerComponent { if (alertLevels == null || alertLevels.isEmpty()) { return null; } - MeasureFilterCondition condition = null; - String metricKey = CoreMetrics.ALERT_STATUS_KEY; - String op = "in"; + 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; + } + }); + List<String> alertLevelsUppercase = Lists.transform(alertLevels, new Function<String, String>() { @Override public String apply(@Nullable String input) { - return input != null ? input.toUpperCase() : ""; + return input != null && availableLevels.contains(input.toUpperCase()) ? input.toUpperCase() : null; } }); - 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; + 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); } 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 20cc5872bee..cd2b01ea4a9 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") + "alertLevels", Arrays.asList("error", "warn", "unknown") ); MeasureFilter filter = factory.create(props); diff --git a/server/sonar-web/src/main/js/navigator/filters/action-plan-filters.js b/server/sonar-web/src/main/js/navigator/filters/action-plan-filters.js index 489cb9de39c..b906a62a864 100644 --- a/server/sonar-web/src/main/js/navigator/filters/action-plan-filters.js +++ b/server/sonar-web/src/main/js/navigator/filters/action-plan-filters.js @@ -15,6 +15,11 @@ define([ onChangeProjectFilter: function() { + var that = this; + _.each(that.model.get('choices'), function(v, k) { + that.choices.add(new Backbone.Model({ id: k, text: v })); + }); + var projects = this.projectFilter.get('value'); if (_.isArray(projects) && projects.length === 1) { return this.fetchActionPlans(projects[0]); |