]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-1492 Allow notes per quality rule
authorFabrice Bellingard <bellingard@gmail.com>
Mon, 23 Jan 2012 18:20:47 +0000 (19:20 +0100)
committerFabrice Bellingard <bellingard@gmail.com>
Mon, 23 Jan 2012 18:23:18 +0000 (19:23 +0100)
=> Improve the display of rules with notes and parameters

plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/rules/show.html.erb
sonar-server/src/main/webapp/stylesheets/style.css

index 6be2ee69ff809994d3e9a94fbfa33f7e51ce5d21..3dc7db530317c421fbcb8c029a7f137f3d3e171c 100644 (file)
@@ -998,6 +998,16 @@ rules_configuration.rule_identification=Identification
 rules_configuration.rule_parameters=Parameters
 
 
+#------------------------------------------------------------------------------
+#
+# RULES DOCUMENTATION PAGE
+#
+#------------------------------------------------------------------------------
+rules.description=Description
+rules.rule_activated_on_profile_x=Rule activated on profile "{0}"
+rules.parameters=Parameters:
+
+
 #------------------------------------------------------------------------------
 #
 # EMAIL CONFIGURATION
index 3d3e68506253675c28480968e5110069f0ec5c76..22a1fae82a9aede9b9768acef0a7d5d9e2f9ddc6 100644 (file)
@@ -30,6 +30,12 @@ class RulesController < ApplicationController
       @rule=Rule.find(key)
     end
     @page_title=@rule.name
+    
+    if params[:resource_id]
+      resource = Project.find(params[:resource_id])
+      @profile = resource.root_project.profile
+      @active_rule = @profile.active_by_rule_id(@rule.id)
+    end
   end
 
 end
index f8bbcfa67104585c58b7708c90a56214952891b4..cc4854d90b90b8920dbb088200c14142a45657a1 100644 (file)
@@ -18,7 +18,7 @@
       <img src="<%= ApplicationController.root_context -%>/images/sep12.png">
       &nbsp;
       <span class="rulename">
-        <a onclick="window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;" href="<%= url_for :controller => 'rules', :action => 'show', :id => violation.rule.key, :layout => 'false' -%>"><%= h(violation.rule.name) -%></a>
+        <a onclick="window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;" href="<%= url_for :controller => 'rules', :action => 'show', :id => violation.rule.key, :resource_id => @resource.id, :layout => 'false' -%>"><%= h(violation.rule.name) -%></a>
       </span>
       &nbsp;
       <img src="<%= ApplicationController.root_context -%>/images/sep12.png">
index c7850424fdfe92a52a261fcf157ecebe332129dd..4f601111b85d88e5416b63069e297f3ad358696f 100644 (file)
@@ -1,7 +1,48 @@
 <h1><%= @rule.name %></h1>
 <div class="subtitle">
 Plugin: <%= @rule.plugin_name -%>&nbsp;&nbsp;&nbsp;
-Key: <%= @rule.plugin_rule_key %></div>
+Key: <%= @rule.plugin_rule_key %>
+</div>
+
 <div class="doc">
+  <h2><%= message('rules.description') -%></h2>
   <p><%= @rule.description %></p>
-</div>
\ No newline at end of file
+  
+  <% if @rule.note %>
+    <p><%= sanitize(@rule.note.text) -%></p>
+  <% end %>
+  
+  <% if @profile %>
+    <h2><%= message('rules.rule_activated_on_profile_x', :params => @profile.name) -%></h2>
+    
+    <% if @active_rule %>
+      <p><%= sanitize(@active_rule.note.text) if @active_rule.note %></p>
+      
+      <h3><%= message('rules.parameters') -%></h3>
+      <table>
+        <% @rule.parameters.each do |parameter|
+          active_parameter = @active_rule.active_param_by_param_id(parameter.id)
+        %>
+          <tbody>
+            <tr>
+              <td width="10%" nowrap class="left">
+                <%= parameter.name %>: &nbsp;
+              </td>
+              <td width="90%" nowrap class="left">
+                <%= active_parameter.value unless active_parameter.value.blank? -%>
+              </td>
+            </tr>
+            <tr>
+              <td></td>
+              <td style="padding-bottom:5px;">
+                <span class="note" style="white-space: normal"><%= h parameter.description -%></span>
+              </td>
+            </tr>
+          </tbody>
+        <% end %>
+      </table>
+    <% end %>
+  <% end %>
+  
+  
+</div>
index b2438ffdec525df69ff68e5638d0faa618354a08..2ad72396f36bab2b261624e78169a50165af50c0 100644 (file)
@@ -533,6 +533,14 @@ h4, .h4 {
 }
 
 /* ------------------- DOCUMENTATION --------------------- */
+.doc {
+  margin: 0px 10px;
+}
+
+.doc h2 {
+  margin-top: 10px;
+}
+
 .doc p {
   margin: 10px 0;
 }