]> source.dussan.org Git - sonarqube.git/commitdiff
inheritance tree: display the number of overriding rules
authorsimonbrandhof <simon.brandhof@gmail.com>
Thu, 23 Dec 2010 22:37:33 +0000 (22:37 +0000)
committersimonbrandhof <simon.brandhof@gmail.com>
Thu, 23 Dec 2010 22:37:33 +0000 (22:37 +0000)
sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb
sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb
sonar-server/src/main/webapp/stylesheets/style.css

index 2f6a0353a46f9762103154751cd3a9cfdba8f6e5..bfd0fbcb3c166d29a7e4eab55ea9c0351ea45661 100644 (file)
@@ -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
index 1c32e0827041389418dfcb7a76dffd3bc7d8b7d6..e992d1558de1f76037d8188cc17029118d2e55eb 100644 (file)
@@ -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
index 50c95d98ec060b8d0c2cf663a12c25bebcf646bb..c97b7fc1dc6319d488bfc5996f208dbd8264c99b 100644 (file)
@@ -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/>
               ...
index c4ecdee159c42be9d8eb2853c3289bf6d70f97a5..2be561e7ec217c2dbd6ceb086fa2b0963841ed48 100644 (file)
@@ -274,7 +274,9 @@ code {
   font-size: 93%;
   font-weight: normal;
 }
-
+.note img {
+  vertical-align: bottom;
+}
 .crossout {
   text-decoration: line-through;
 }