diff options
author | David Festal <david.festal@serli.com> | 2011-07-19 16:26:50 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2011-07-25 14:36:50 +0200 |
commit | c0f4a90f64549f94922d526463e7a9c4f0c8263a (patch) | |
tree | 997b9da7b51fbf41f5e978ceffcadd512df9f715 | |
parent | 86a26e9056ce9b629926f8422592eb8a2fdae71b (diff) | |
download | sonarqube-c0f4a90f64549f94922d526463e7a9c4f0c8263a.tar.gz sonarqube-c0f4a90f64549f94922d526463e7a9c4f0c8263a.zip |
SONAR-75 add rule severities (thanks to David Festal's patch)
4 files changed, 44 insertions, 15 deletions
diff --git a/plugins/sonar-i18n-en-plugin/src/main/resources/org/sonar/i18n/core.properties b/plugins/sonar-i18n-en-plugin/src/main/resources/org/sonar/i18n/core.properties index af97a14fad7..6606e70133d 100644 --- a/plugins/sonar-i18n-en-plugin/src/main/resources/org/sonar/i18n/core.properties +++ b/plugins/sonar-i18n-en-plugin/src/main/resources/org/sonar/i18n/core.properties @@ -678,6 +678,18 @@ maintenance.more_information=<p>Whilst waiting, you might want to check <a href= #------------------------------------------------------------------------------ # +# RULE SEVERITIES +# +#------------------------------------------------------------------------------ + +severity.BLOCKER=Blocker +severity.CRITICAL=Critical +severity.MAJOR=Major +severity.MINOR=Minor +severity.INFO=Info + +#------------------------------------------------------------------------------ +# # METRIC DOMAINS # #------------------------------------------------------------------------------ diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/rule_priority.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/rule_priority.rb index 4cda2d6c6db..b2767214303 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/rule_priority.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/rule_priority.rb @@ -35,8 +35,8 @@ class Sonar::RulePriority PRIORITY_CRITICAL = Java::OrgSonarApiRules::RulePriority::CRITICAL.ordinal() PRIORITY_BLOCKER = Java::OrgSonarApiRules::RulePriority::BLOCKER.ordinal() - def self.to_s(failure_level) - case failure_level + def self.to_s(failure_level, translate=false) + text = case failure_level when Java::OrgSonarApiRules::RulePriority::BLOCKER.ordinal() Java::OrgSonarApiRules::RulePriority::BLOCKER.to_s when Java::OrgSonarApiRules::RulePriority::CRITICAL.ordinal() @@ -48,6 +48,12 @@ class Sonar::RulePriority when Java::OrgSonarApiRules::RulePriority::INFO.ordinal() Java::OrgSonarApiRules::RulePriority::INFO.to_s end + + return text unless translate + + i18n_key = 'severity.' + text + result = Java::OrgSonarServerUi::JRubyFacade.getInstance().getI18nMessage(I18n.locale, i18n_key, as_text_map[text], [].to_java) + result end def self.id(priority) @@ -89,15 +95,26 @@ class Sonar::RulePriority priority==PRIORITY_BLOCKER end + @@priority_text_map={} + + def self.as_text_map + return @@priority_text_map if @@priority_text_map.size > 0 + @@priority_text_map[to_s(PRIORITY_INFO)]='Info' + @@priority_text_map[to_s(PRIORITY_MINOR)]='Minor' + @@priority_text_map[to_s(PRIORITY_MAJOR)]='Major' + @@priority_text_map[to_s(PRIORITY_CRITICAL)]='Critical' + @@priority_text_map[to_s(PRIORITY_BLOCKER)]='Blocker' + @@priority_text_map + end + def self.as_options @@priority_options ||= [] return @@priority_options if @@priority_options.size > 0 - @@priority_options << ['Info', to_s(PRIORITY_INFO)] - @@priority_options << ['Minor', to_s(PRIORITY_MINOR)] - @@priority_options << ['Major', to_s(PRIORITY_MAJOR)] - @@priority_options << ['Critical', to_s(PRIORITY_CRITICAL)] - @@priority_options << ['Blocker', to_s(PRIORITY_BLOCKER)] + @@priority_options << [as_text_map[to_s(PRIORITY_INFO)], to_s(PRIORITY_INFO)] + @@priority_options << [as_text_map[to_s(PRIORITY_MINOR)], to_s(PRIORITY_MINOR)] + @@priority_options << [as_text_map[to_s(PRIORITY_MAJOR)], to_s(PRIORITY_MAJOR)] + @@priority_options << [as_text_map[to_s(PRIORITY_CRITICAL)], to_s(PRIORITY_CRITICAL)] + @@priority_options << [as_text_map[to_s(PRIORITY_BLOCKER)], to_s(PRIORITY_BLOCKER)] @@priority_options end - end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_rule_priority.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_rule_priority.erb index 14c91ad345a..56eae8f5b59 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_rule_priority.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_rule_priority.erb @@ -1,6 +1,6 @@ <tr class="<%= css -%> <%= 'selected' if Sonar::RulePriority.to_s(priority_id)==params[:priority] -%>"> <td><%= image_tag "priority/#{priority_id}.png" %></td> - <td><%= link_to label, {:controller => 'drilldown', :action => 'violations', :id => @project.id, :priority => Sonar::RulePriority.to_s(priority_id), :period => @period} %></td> + <td><%= link_to Sonar::RulePriority.to_s(priority_id, true), {:controller => 'drilldown', :action => 'violations', :id => @project.id, :priority => Sonar::RulePriority.to_s(priority_id), :period => @period} %></td> <td style="padding-left: 10px;" align="right"> <%= @period ? format_variation(measure, :index => @period, :style => 'light') : format_measure(measure) -%> </td> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb index 88b27e98560..85e8db0f41a 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb @@ -50,11 +50,11 @@ %> <h3><%= message('severity') -%></h3> <table class="spacedicon" style="border: 1px solid #ccc;"> - <%= render :partial => 'rule_priority', :locals => {:label => message('blocker'), :css => 'even', :priority_id => Sonar::RulePriority::PRIORITY_BLOCKER, :max => max, :measure => blocker_violations }%> - <%= render :partial => 'rule_priority', :locals => {:label => message('critical'), :css => 'odd', :priority_id => Sonar::RulePriority::PRIORITY_CRITICAL, :max => max, :measure => critical_violations }%> - <%= render :partial => 'rule_priority', :locals => {:label => message('major'), :css => 'even', :priority_id => Sonar::RulePriority::PRIORITY_MAJOR, :max => max, :measure => major_violations }%> - <%= render :partial => 'rule_priority', :locals => {:label => message('minor'), :css => 'odd', :priority_id => Sonar::RulePriority::PRIORITY_MINOR, :max => max, :measure => minor_violations }%> - <%= render :partial => 'rule_priority', :locals => {:label => message('info'), :css => 'even', :priority_id => Sonar::RulePriority::PRIORITY_INFO, :max => max, :measure => info_violations }%> + <%= render :partial => 'rule_priority', :locals => {:css => 'even', :priority_id => Sonar::RulePriority::PRIORITY_BLOCKER, :max => max, :measure => blocker_violations }%> + <%= render :partial => 'rule_priority', :locals => {:css => 'odd', :priority_id => Sonar::RulePriority::PRIORITY_CRITICAL, :max => max, :measure => critical_violations }%> + <%= render :partial => 'rule_priority', :locals => {:css => 'even', :priority_id => Sonar::RulePriority::PRIORITY_MAJOR, :max => max, :measure => major_violations }%> + <%= render :partial => 'rule_priority', :locals => {:css => 'odd', :priority_id => Sonar::RulePriority::PRIORITY_MINOR, :max => max, :measure => minor_violations }%> + <%= render :partial => 'rule_priority', :locals => {:css => 'even', :priority_id => Sonar::RulePriority::PRIORITY_INFO, :max => max, :measure => info_violations }%> </table> </td> <td class="column" align="left" style="white-space: normal;"> @@ -175,7 +175,7 @@ <div style="font-size: 85%;background-color: #eee;color: #777;padding: 4px 5px;border: 1px solid #ddd;margin-bottom: 20px;"> <b><%= message('path') -%>:</b> <% if @priority_id %> -<%= Sonar::RulePriority.to_s(@priority_id) %> <%= link_to message('clear_verb'), {:overwrite_params => {:priority => nil}} %> +<%= Sonar::RulePriority.to_s(@priority_id, true) %> <%= link_to message('clear_verb'), {:overwrite_params => {:priority => nil}} %> <% else %> <%= message('drilldown.any_severity') -%> <% end %> » |