summaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-12-23 22:37:33 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-12-23 22:37:33 +0000
commitaf245798693c9bcc3555abbf407e4c647a37b584 (patch)
tree4b0de7404696d2d16957dbd58bbfd540875ffcb7 /sonar-server/src/main
parent6813d3b0d678b0dc2833bcb3ffd808ebe0428499 (diff)
downloadsonarqube-af245798693c9bcc3555abbf407e4c647a37b584.tar.gz
sonarqube-af245798693c9bcc3555abbf407e4c647a37b584.zip
inheritance tree: display the number of overriding rules
Diffstat (limited to 'sonar-server/src/main')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb11
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb7
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb8
-rw-r--r--sonar-server/src/main/webapp/stylesheets/style.css4
4 files changed, 26 insertions, 4 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb
index 2f6a0353a46..bfd0fbcb3c1 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb
@@ -21,4 +21,15 @@ module ProfilesHelper
def languages
controller.java_facade.getLanguages()
end
+
+ def label_for_rules_count(profile)
+ label="#{profile.active_rules.count} rules"
+
+ count_overriding=profile.count_overriding_rules
+ if count_overriding>0
+ label += ", incl. #{count_overriding} overriding"
+ label += image_tag('overrides.png')
+ end
+ label
+ end
end \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb
index 1c32e082704..e992d1558de 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb
@@ -104,6 +104,13 @@ class Profile < ActiveRecord::Base
!provided? && !default_profile? && children.empty?
end
+ def count_overriding_rules
+ @count_overriding_rules||=
+ begin
+ active_rules.count(:conditions => ['inheritance=?', 'OVERRIDES'])
+ end
+ end
+
def inherited?
parent_name.present?
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb
index 50c95d98ec0..c97b7fc1dc6 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb
@@ -8,17 +8,19 @@
<td align="center" valign="top">
<div>
<% @profile.ancestors.reverse.each do |parent| %>
- <a href="<%= url_for :action => 'inheritance', :id => parent.id -%>"><%= parent.name -%></a> <span class="note">(<%= parent.active_rules.size -%> rules)</span><br/>
+ <a href="<%= url_for :action => 'inheritance', :id => parent.id -%>"><%= parent.name -%></a>
+ <span class="note">(<%= label_for_rules_count(parent) -%>)</span><br/>
<%= image_tag 'blue-up.png' -%><br/>
<% end %>
- <b><%= @profile.name -%></b> <span class="note">(<%= @profile.active_rules.size -%> rules)</span><br/>
+ <b><%= @profile.name -%></b> <span class="note">(<%= label_for_rules_count(@profile) -%>)</span><br/>
<% if @profile.children.size>0 %>
<%= image_tag 'blue-up.png' -%><br/>
<% @profile.children.each_with_index do |child,index| %>
<%= ', ' if index>0 -%>
- <a href="<%= url_for :action => 'inheritance', :id => child.id -%>"><%= child.name -%></a> <span class="note">(<%= child.active_rules.size -%> rules)</span>
+ <a href="<%= url_for :action => 'inheritance', :id => child.id -%>"><%= child.name -%></a>
+ <span class="note">(<%= label_for_rules_count(child) -%>)</span>
<% end %>
<br/><%= image_tag 'blue-up.png' -%><br/>
...
diff --git a/sonar-server/src/main/webapp/stylesheets/style.css b/sonar-server/src/main/webapp/stylesheets/style.css
index c4ecdee159c..2be561e7ec2 100644
--- a/sonar-server/src/main/webapp/stylesheets/style.css
+++ b/sonar-server/src/main/webapp/stylesheets/style.css
@@ -274,7 +274,9 @@ code {
font-size: 93%;
font-weight: normal;
}
-
+.note img {
+ vertical-align: bottom;
+}
.crossout {
text-decoration: line-through;
}