aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb11
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb16
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb6
3 files changed, 26 insertions, 7 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb
index 3d509b54640..e838034a1bc 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb
@@ -78,14 +78,17 @@ class DrilldownController < ApplicationController
# options
- options={}
+ @rule=Rule.by_key_or_id(params[:rule])
@priority_id = (params[:priority] ? Sonar::RulePriority.id(params[:priority]) : nil)
@categ_id = (params[:categ_id] ? params[:categ_id].to_i : nil)
- @rule_id = Rule.to_i(params[:rule])
- options[:rule_id]=@rule_id
+
+ options={}
options[:rule_category_id]=@categ_id
options[:rule_priority_id]=@priority_id
-
+ if @rule
+ params[:rule]=@rule.key # workaround for SONAR-1767 : the javascript hash named "rp" in the HTML source must contain the rule key, but not the rule id
+ options[:rule_id]=@rule.id
+ end
# load data
@drilldown = Drilldown.new(@project, @metric, @selected_rids, options)
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb
index be405edcc95..b2013b6f28d 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb
@@ -86,6 +86,22 @@ class Rule < ActiveRecord::Base
id>0 ? id : nil
end
+ def self.by_key_or_id(key_or_id)
+ rule=nil
+ if key_or_id.present?
+ id=key_or_id.to_i
+ if id<=0
+ parts=key_or_id.split(':')
+ if parts.size==2
+ rule=Rule.find(:first, :conditions => {:plugin_name => parts[0], :plugin_rule_key => parts[1]})
+ end
+ else
+ rule=Rule.find(id)
+ end
+ end
+ rule
+ end
+
def to_hash_json(profile)
json = {'title' => name, 'key' => key, 'category' => rules_category.name, 'plugin' => plugin_name}
json['description'] = description
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 e61204eb596..b7e501c889a 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
@@ -88,7 +88,7 @@
next if rule_measure.value==0
rule=rules_hash[rule_measure.rule_id]
clazz = cycle('even', 'odd', :name => 'rules')
- clazz = clazz + ' selected' if @rule_id and @rule_id==rule_measure.rule_id
+ clazz = clazz + ' selected' if @rule && @rule.id==rule_measure.rule_id
rule_index+=1
%>
<tr class="<%= clazz -%>">
@@ -177,8 +177,8 @@
<% else %>
Any <%= @filter %>
<% end %>&nbsp;&raquo;&nbsp;
-<% if @rule_id %>
-<%= h Rule.find(@rule_id).name %> <%= link_to 'clear', {:overwrite_params => {:rule => nil}} %>
+<% if @rule %>
+<%= h @rule.name %> <%= link_to 'clear', {:overwrite_params => {:rule => nil}} %>
<% else %>
Any rule
<% end %>&nbsp;&raquo;&nbsp;