diff options
author | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-07-28 10:10:14 +0200 |
---|---|---|
committer | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-07-28 10:10:14 +0200 |
commit | de9982f4fe9a7dfd477491584d6710709583bd0e (patch) | |
tree | 707c9596db26f6c56e653d11562d30d7dcfd25b4 /plugins/sonar-core-plugin | |
parent | b7a997628a5f99d5a38fbd01b5548cc5f9989379 (diff) | |
download | sonarqube-de9982f4fe9a7dfd477491584d6710709583bd0e.tar.gz sonarqube-de9982f4fe9a7dfd477491584d6710709583bd0e.zip |
SONAR-5441 Prevent failure of quality gate widget when one metric is missing
Diffstat (limited to 'plugins/sonar-core-plugin')
-rw-r--r-- | plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/alerts.html.erb | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/alerts.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/alerts.html.erb index 53dfe584b3e..92d11224c7e 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/alerts.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/alerts.html.erb @@ -2,7 +2,16 @@ if m && !m.data.blank? details = JSON.parse m.data m.alert_status = details['level'] - conditions = details['conditions'] + raw_conditions = details['conditions'] + conditions = [] + missing_metric = false + raw_conditions.each do |condition| + if metric(condition['metric']).nil? + missing_metric = true + else + conditions << condition + end + end alert_metric = metric(Metric::ALERT_STATUS) warn_message = message('measure_filter.criteria.alert.warn') @@ -19,7 +28,7 @@ -%><div class="widget <%= css_class -%>" style="color: black !important" id="quality_gate_widget_<%= widget.id -%>"> <div><%= format_measure(measure(Metric::ALERT_STATUS)) -%> <%= label -%></div> <% if conditions.any? {|condition| condition['level'] != 'OK'} || widget_properties['show_ok'] && !conditions.empty? -%> - <% details['conditions'].sort_by {|condition| [ -condition['level'].length, metric(condition['metric']).short_name] }.each do |condition| + <% conditions.sort_by {|condition| [ -condition['level'].length, metric(condition['metric']).short_name] }.each do |condition| level = condition['level'] condition_metric = metric(condition['metric']) @@ -53,7 +62,10 @@ </div> <% end end - end -%> + end + if missing_metric -%> + <div class="warning" style="clear: left"><%= message('widget.alerts.missing_metric') -%></div> + <% end -%> </div> <% else -%> <% m=measure(Metric::ALERT_STATUS) |