diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-03-02 15:19:32 +0100 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-03-02 15:19:32 +0100 |
commit | 4fe456fb3bfa1baa156d719e31033304fc10b755 (patch) | |
tree | 9ac874166a54ef716fbf542f3e05c71a3f3231f6 | |
parent | 3635c6c5f851ebbc6ca3e3a11f4f687570884d6e (diff) | |
download | sonarqube-4fe456fb3bfa1baa156d719e31033304fc10b755.tar.gz sonarqube-4fe456fb3bfa1baa156d719e31033304fc10b755.zip |
SONAR-2218 fix rule filter in violations tab
3 files changed, 39 insertions, 10 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/browse_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/browse_controller.rb index bacf6c73325..4a1642a57ea 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/browse_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/browse_controller.rb @@ -125,6 +125,16 @@ class BrowseController < ApplicationController end end + if @snapshot.measure('conditions_by_line').nil? + deprecated_branches_by_line=load_distribution('branch_coverage_hits_data') + deprecated_branches_by_line.each_pair do |line_id,label| + line=@lines[line_id-1] + if line + line.deprecated_conditions_label=label + end + end + end + filter_lines_by_date() render :action => 'index' end @@ -161,8 +171,7 @@ class BrowseController < ApplicationController end end - @violations=RuleFailure.find(:all, :include => 'rule', :conditions => [conditions] + values, :order => 'failure_level DESC') - @violations.each do |violation| + RuleFailure.find(:all, :include => 'rule', :conditions => [conditions] + values, :order => 'failure_level DESC').each do |violation| # sorted by severity => from blocker to info if violation.line && violation.line>0 @lines[violation.line-1].add_violation(violation) @@ -207,7 +216,7 @@ class BrowseController < ApplicationController end class Line - attr_accessor :source, :revision, :author, :datetime, :violations, :hits, :conditions, :covered_conditions, :hidden + attr_accessor :source, :revision, :author, :datetime, :violations, :hits, :conditions, :covered_conditions, :hidden, :deprecated_conditions_label def initialize(source) @source=source @@ -234,6 +243,22 @@ class BrowseController < ApplicationController def date @datetime ? @datetime.to_date : nil end + + def deprecated_conditions_label=(label) + if label + @deprecated_conditions_label=label + if label=='0%' + @conditions=2 + @covered_conditions=0 + elsif label=='100%' + @conditions=2 + @covered_conditions=2 + else + @conditions=2 + @covered_conditions=1 + end + end + end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/browse/_rules_filter.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/browse/_rules_filter.html.erb index cd37ea4255e..ea36a4da8d1 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/browse/_rules_filter.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/browse/_rules_filter.html.erb @@ -7,14 +7,12 @@ rule_counts={} rules=[] - - @violations.each do |violation| - count=(rule_counts[violation.rule_id]||0) +1 - rule_counts[violation.rule_id]=count - rules<<violation.rule + rule_measures=ProjectMeasure.find(:all, :include => 'rule', :conditions => ['metric_id=? AND snapshot_id=? AND rule_id IS NOT NULL AND characteristic_id IS NULL', Metric.by_key('violations').id, @snapshot.id]) + rule_measures.each do |rule_measure| + rule_counts[rule_measure.rule_id]=rule_measure.value.to_i + rules<<rule_measure.rule end - rule_options=[] rules.uniq.sort_by{|rule| rule.name}.each do |rule| rule_options<<["#{h rule.name} (#{rule_counts[rule.id]})", rule.key] diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/browse/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/browse/index.html.erb index da557c0651c..d4b5f7db905 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/browse/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/browse/index.html.erb @@ -116,7 +116,13 @@ <% if @display_coverage %> <td class="ind <%= hits_status -%>"><%= line.hits -%></td> - <td class="ind <%= conditions_status -%>"><% if line.conditions && line.conditions>0 %><%= line.covered_conditions -%>/<%= line.conditions -%><% end %></td> + <td class="ind <%= conditions_status -%>"> + <% if line.deprecated_conditions_label -%> + <%= line.deprecated_conditions_label -%> + <% elsif line.conditions && line.conditions>0 -%> + <%= line.covered_conditions -%>/<%= line.conditions -%> + <% end %> + </td> <% end %> <td class="line <%= status -%>"><%= line.source -%></td> </tr> |