]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2218 add new coverage measures in tab header
authorsimonbrandhof <simon.brandhof@gmail.com>
Mon, 7 Mar 2011 17:42:05 +0000 (18:42 +0100)
committersimonbrandhof <simon.brandhof@gmail.com>
Mon, 7 Mar 2011 17:42:05 +0000 (18:42 +0100)
sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_coverage.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_source.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/resource/_measure.html.erb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/resource/index.html.erb
sonar-server/src/main/webapp/stylesheets/style.css

index 92d4ca39ee5e51cea144d86154aac25bbc9dfc57..848d6becce18d6377f6ba80e529d70090d6fbac5 100644 (file)
@@ -481,7 +481,7 @@ module ApplicationHelper
   # === Optional parameters
   # * color: true|false. Default is true.
   # * period: integer between 1 and 5. By default the index is defined by the dashboard variation select-box
-  # * style: light|normal. Default is normal (parenthesis + bold)
+  # * style: light|normal|none. Default is normal (parenthesis + bold)
   #
   # === Examples
   # format_variation('ncloc')
@@ -497,6 +497,10 @@ module ApplicationHelper
     if m
       val=variation_value(m, options)
       if val
+        if options[:style]=='none'
+          return m.format_numeric_value(val)
+        end
+
         formatted_val=(val>=0 ? "+" : "") + m.format_numeric_value(val, :variation => true)
         css_class=''
         if options[:color]||true
index 7590306ac0ff228ac6c446b71101e8d3e49dba37..3f58b908b1a1f20266d65011f2c9789ee7edb0b6 100644 (file)
@@ -1,36 +1,64 @@
 <div id="coverage_header" class="tab_header">
-  <table class="col">
+  <table class="metrics">
     <tr>
-      <td class="big"><%= format_measure('coverage', :default => '-') -%></td>
+      <td class="big" rowspan="2"><%= format_measure('coverage', :default => '-') -%></td>
+      <td class="sep"> </td>
+      <%= render :partial => 'measure', :locals => {:measure => measure('line_coverage'), :title => 'Line coverage'} -%>
+
+      <td class="sep"> </td>
+      <%= render :partial => 'measure', :locals => {:measure => measure('branch_coverage'), :title => 'Branch coverage'} -%>
+    </tr>
+    <tr>
+      <td class="sep"> </td>
+      <%= render :partial => 'measure', :locals => {:measure => measure('uncovered_lines'), :title => 'Uncovered lines', :ratio => measure('lines_to_cover')} -%>
+      <td class="sep"> </td>
+      <%= render :partial => 'measure', :locals => {:measure => measure('uncovered_conditions'), :title => 'Uncovered conditions', :ratio => measure('conditions_to_cover')} -%>
     </tr>
-  </table>
 
-  <table class="col">
-    <% if m=measure('line_coverage') %>
-      <tr>
-        <td class="name">Line coverage:</td>
-        <td class="value"><%= format_measure(m) -%></td>
-      </tr>
-    <% end %>
-    <% if m=measure('uncovered_lines') %>
+    <% if @period && measure('new_coverage')
+         new_uncovered_lines=measure('new_uncovered_lines')
+    %>
       <tr>
-        <td class="name">Uncovered lines:</td>
-        <td class="value"><%= format_measure(m) -%> / <%= format_measure('lines_to_cover') -%></td>
+        <td colspan="7"><br/>On new/changed code: </td>
       </tr>
-    <% end %>
-  </table>
 
-  <table class="col">
-    <% if m=measure('branch_coverage') %>
       <tr>
-        <td class="name">Branch coverage:</td>
-        <td class="value"><%= format_measure(m) -%></td>
+        <td class="big" rowspan="2"><%= format_variation('new_coverage', :period => @period, :style => 'none') -%></td>
+
+        <td class="sep"> </td>
+        
+        <% if m=measure('new_line_coverage') %>
+          <td class="name">Line coverage:</td>
+          <td class="value"><%= format_variation(m, :period => @period, :style => 'none') -%></td>
+        <% else %>
+          <td colspan="2"></td>
+        <% end %>
+
+        <td class="sep"> </td>
+        <% if m=measure('new_branch_coverage') %>
+          <td class="name">Branch coverage:</td>
+          <td class="value"><%= format_variation(m, :period => @period, :style => 'none') -%></td>
+        <% else %>
+          <td colspan="2"></td>
+        <% end %>
       </tr>
-    <% end %>
-    <% if m=measure('uncovered_conditions') %>
       <tr>
-        <td class="name">Uncovered conditions:</td>
-        <td class="value"><%= format_measure(m) -%> / <%= format_measure('conditions_to_cover') -%></td>
+        <td class="sep"> </td>
+
+        <% if new_uncovered_lines %>
+          <td class="name">Uncovered lines:</td>
+          <td class="value"><%= format_variation(new_uncovered_lines, :period => @period, :style => 'none') -%>/<%= format_variation('new_lines_to_cover', :period => @period, :style => 'none') -%></td>
+        <% else %>
+          <td colspan="2"></td>
+        <% end %>
+
+        <td class="sep"> </td>
+        <% if m=measure('new_uncovered_conditions') %>
+          <td class="name">Uncovered conditions: </td>
+          <td class="value"><%= format_variation(m, :period => @period, :style => 'none') -%>/<%= format_variation('new_conditions_to_cover', :period => @period, :style => 'none') -%></td>
+        <% else %>
+          <td colspan="2"></td>
+        <% end %>
       </tr>
     <% end %>
   </table>
index 2a4d1851f78c354a500fb14d454d810f3fc1a8c4..de5451252c1f66ff145e86369c558ed1967d4aee 100644 (file)
 <div id="source_header" class="tab_header">
-  <table class="col">
-    <% if m=measure('lines') %>
-      <tr>
-        <td class="name">Lines:</td>
-        <td class="value"><%= format_measure(m) -%></td>
-      </tr>
-    <% end %>
-    <% if m=measure('ncloc') %>
-      <tr>
-        <td class="name">Lines of code:</td>
-        <td class="value"><%= format_measure(m) -%></td>
-      </tr>
-    <% end %>
-    <% if m=measure('functions') %>
-      <tr>
-        <td class="name">Methods:</td>
-        <td class="value"><%= format_measure(m) -%></td>
-      </tr>
-    <% end %>
-    <% if m=measure('accessors') %>
-      <tr>
-        <td class="name">Accessors:</td>
-        <td class="value"><%= format_measure(m) -%></td>
-      </tr>
-    <% end %>
-    <% if m=measure('paragraphs') %>
-      <tr>
-        <td class="name">Paragraphs:</td>
-        <td class="value"><%= format_measure(m) -%></td>
-      </tr>
-    <% end %>
+  <table width="100%">
+    <tr>
+      <td class="col">
+      <table class="metrics">
+        <% if m=measure('lines') %>
+          <tr>
+            <td class="name">Lines:</td>
+            <td class="value"><%= format_measure(m) -%></td>
+          </tr>
+        <% end %>
+        <% if m=measure('ncloc') %>
+          <tr>
+            <td class="name">Lines of code:</td>
+            <td class="value"><%= format_measure(m) -%></td>
+          </tr>
+        <% end %>
+        <% if m=measure('functions') %>
+          <tr>
+            <td class="name">Methods:</td>
+            <td class="value"><%= format_measure(m) -%></td>
+          </tr>
+        <% end %>
+        <% if m=measure('accessors') %>
+          <tr>
+            <td class="name">Accessors:</td>
+            <td class="value"><%= format_measure(m) -%></td>
+          </tr>
+        <% end %>
+        <% if m=measure('paragraphs') %>
+          <tr>
+            <td class="name">Paragraphs:</td>
+            <td class="value"><%= format_measure(m) -%></td>
+          </tr>
+        <% end %>
+      </table>
+      </td>
+      <td class="col">
+      <table class="metrics">
+        <% if m=measure('statements') %>
+          <tr>
+            <td class="name">Statements:</td>
+            <td class="value"><%= format_measure(m) -%></td>
+          </tr>
+        <% end %>
+        <% if m=measure('complexity') %>
+          <tr>
+            <td class="name">Complexity:</td>
+            <td class="value"><%= format_measure(m) -%></td>
+          </tr>
+        <% end %>
+        <% if m=measure('function_complexity') %>
+          <tr>
+            <td class="name">Complexity/method:</td>
+            <td class="value"><%= format_measure(m) -%></td>
+          </tr>
+        <% end %>
+        <% if m=measure('paragraph_complexity') %>
+          <tr>
+            <td class="name">Complexity/paragraph:</td>
+            <td class="value"><%= format_measure(m) -%></td>
+          </tr>
+        <% end %>
+      </table>
+    </td>
+      <td class="col">
+      <table class="metrics">
+        <% if m=measure('comment_lines_density') %>
+          <tr>
+            <td class="name">Comments:</td>
+            <td class="value"><%= format_measure(m) -%></td>
+          </tr>
+        <% end %>
+        <% if m=measure('comment_lines') %>
+          <tr>
+            <td class="name">Comment lines:</td>
+            <td class="value"><%= format_measure(m) -%></td>
+          </tr>
+        <% end %>
+        <% if m=measure('commented_out_code_lines') %>
+          <tr>
+            <td class="name">Commented-out LOC:</td>
+            <td class="value"><%= format_measure(m) -%></td>
+          </tr>
+        <% end %>
+        <% if m=measure('comment_blank_lines') %>
+          <tr>
+            <td class="name">Blank comments:</td>
+            <td class="value"><%= format_measure(m) -%></td>
+          </tr>
+        <% end %>
+      </table>
+    </td>
+      <td class="col">
+      <table class="metrics">
+        <% if m=measure('public_documented_api_density') %>
+          <tr>
+            <td class="name">Public documented API:</td>
+            <td class="value"><%= format_measure(m) -%></td>
+          </tr>
+        <% end %>
+        <% if m=measure('public_undocumented_api') %>
+          <tr>
+            <td class="name">Public undocumented API:</td>
+            <td class="value"><%= format_measure(m) -%></td>
+          </tr>
+        <% end %>
+        <% if m=measure('public_api') %>
+          <tr>
+            <td class="name">Public API:</td>
+            <td class="value"><%= format_measure(m) -%></td>
+          </tr>
+        <% end %>
+      </table>
+    </td>
+      <td class="col">
+      <table class="metrics">
+        <% if m=measure('classes') %>
+          <tr>
+            <td class="name">Classes:</td>
+            <td class="value"><%= format_measure(m) -%></td>
+          </tr>
+        <% end %>
+        <% if m=measure('noc') %>
+          <tr>
+            <td class="name">Number of Children:</td>
+            <td class="value"><%= format_measure(m) -%></td>
+          </tr>
+        <% end %>
+        <% if m=measure('dit') %>
+          <tr>
+            <td class="name">Depth in Tree:</td>
+            <td class="value"><%= format_measure(m) -%></td>
+          </tr>
+        <% end %>
+        <% if m=measure('rfc') %>
+          <tr>
+            <td class="name">Response for Class (RFC):</td>
+            <td class="value"><%= format_measure(m) -%></td>
+          </tr>
+        <% end %>
+      </table>
+      </td>
+    </tr>
   </table>
-
-  <table class="col">
-    <% if m=measure('statements') %>
-      <tr>
-        <td class="name">Statements:</td>
-        <td class="value"><%= format_measure(m) -%></td>
-      </tr>
-    <% end %>
-    <% if m=measure('complexity') %>
-      <tr>
-        <td class="name">Complexity:</td>
-        <td class="value"><%= format_measure(m) -%></td>
-      </tr>
-    <% end %>
-    <% if m=measure('function_complexity') %>
-      <tr>
-        <td class="name">Complexity/method:</td>
-        <td class="value"><%= format_measure(m) -%></td>
-      </tr>
-    <% end %>
-    <% if m=measure('paragraph_complexity') %>
-      <tr>
-        <td class="name">Complexity/paragraph:</td>
-        <td class="value"><%= format_measure(m) -%></td>
-      </tr>
-    <% end %>
-  </table>
-
-  <table class="col">
-    <% if m=measure('comment_lines_density') %>
-      <tr>
-        <td class="name">Comments:</td>
-        <td class="value"><%= format_measure(m) -%></td>
-      </tr>
-    <% end %>
-    <% if m=measure('comment_lines') %>
-      <tr>
-        <td class="name">Comment lines:</td>
-        <td class="value"><%= format_measure(m) -%></td>
-      </tr>
-    <% end %>
-    <% if m=measure('commented_out_code_lines') %>
-      <tr>
-        <td class="name">Commented-out LOC:</td>
-        <td class="value"><%= format_measure(m) -%></td>
-      </tr>
-    <% end %>
-    <% if m=measure('comment_blank_lines') %>
-      <tr>
-        <td class="name">Blank comments:</td>
-        <td class="value"><%= format_measure(m) -%></td>
-      </tr>
-    <% end %>
-  </table>
-
-  <table class="col">
-    <% if m=measure('public_documented_api_density') %>
-      <tr>
-        <td class="name">Public documented API:</td>
-        <td class="value"><%= format_measure(m) -%></td>
-      </tr>
-    <% end %>
-    <% if m=measure('public_undocumented_api') %>
-      <tr>
-        <td class="name">Public undocumented API:</td>
-        <td class="value"><%= format_measure(m) -%></td>
-      </tr>
-    <% end %>
-    <% if m=measure('public_api') %>
-      <tr>
-        <td class="name">Public API:</td>
-        <td class="value"><%= format_measure(m) -%></td>
-      </tr>
-    <% end %>
-  </table>
-
-  <table class="col">
-    <% if m=measure('classes') %>
-      <tr>
-        <td class="name">Classes:</td>
-        <td class="value"><%= format_measure(m) -%></td>
-      </tr>
-    <% end %>
-    <% if m=measure('noc') %>
-      <tr>
-        <td class="name">Number of Children:</td>
-        <td class="value"><%= format_measure(m) -%></td>
-      </tr>
-    <% end %>
-    <% if m=measure('dit') %>
-      <tr>
-        <td class="name">Depth in Tree:</td>
-        <td class="value"><%= format_measure(m) -%></td>
-      </tr>
-    <% end %>
-    <% if m=measure('rfc') %>
-      <tr>
-        <td class="name">Response for Class (RFC):</td>
-        <td class="value"><%= format_measure(m) -%></td>
-      </tr>
-    <% end %>
-  </table>
-
   <%= render :partial => 'options' -%>
 </div>
 
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_measure.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_measure.html.erb
new file mode 100644 (file)
index 0000000..ba75aeb
--- /dev/null
@@ -0,0 +1,11 @@
+<% if measure %>
+  <td class="name"><%= h(title) -%>: </td>
+  <td class="value">
+    <%= format_measure(measure) -%>
+    <% if defined?(ratio) && ratio %>
+    /<%= format_measure(ratio) -%>
+    <% end %>
+  </td>
+<% else %>
+  <td colspan="2"></td>
+<% end %>
\ No newline at end of file
index c3feeb1f0b4af54eb8122da6c4a2b6cac4f250a5..341ef262011488ff63f312983ef66d310bb8f88d 100644 (file)
@@ -1,3 +1,4 @@
+<div class="violation">
 <img src="<%= ApplicationController.root_context -%>/images/priority/<%=violation.failure_level-%>.png"/>
 
 <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></span>
@@ -9,4 +10,5 @@
 
 %>
   <span class="violation_date"><%= duration==0 ? 'today' : "#{duration} days ago" -%></span>
-<% end %>
\ No newline at end of file
+<% end %>
+  </div>
\ No newline at end of file
index ff260ccf00dec0474b2815b5281a251c89041a6f..e4eb4bc335e9452e914c37bfe6061c475d624633 100644 (file)
@@ -19,7 +19,6 @@
     current_revision=nil
     colspan=2
     colspan+=1 if @display_scm
-    colspan+=1 if @display_violations
     colspan+=2 if @display_coverage
     previous_hidden=false
     first_section=true
             <td class="scm"></td>
     <%   end
        end %>
-    <% if @display_violations %>
-      <td class="rule <%= 'violations section' if line.violations? -%>">
-        <% if line.violations?
-             line.violations.each_with_index do |violation, violation_index| %>
-               <%= '<br/>' if violation_index>0 %>
-               <%= render :partial => 'violation', :locals => {:violation => violation} -%>
-        <%
-             end
-           end
-        %>
-      </td>
-    <% end %>
     <td class="lid <%= ' section' if line.violations? -%>" id="L<%= index+1 -%>"><a name="L<%= index+1 -%>" href="#L<%= index+1 -%>"><%= index + 1 -%></a></td>
 
     <% if @display_coverage  %>
         <% end %>
       </td>
     <% end %>
-    <td class="line <%= status -%>"><pre><%= line.source -%></pre></td>
+    <td class="line <%= status -%>">
+      <pre><%= line.source -%></pre>
+      <% if @display_violations && line.violations? %>
+        <% line.violations.each do |violation| %>
+          <%= render :partial => 'violation', :locals => {:violation => violation} -%>
+        <% end %>
+      <% end %>
+    </td>
   </tr>
   <% end %>
 </table>
index f0bfa6d8daf1eb17d0c6351191f5731957a84154..d418289baf049ef5a91044d56600d6bf8c510d6d 100644 (file)
@@ -656,13 +656,11 @@ ul.operations li a {
 .sources2 span.author, .sources2 span.author a {
   font-size: 85%;
 }
-.sources2 td.rule {
-  padding: 1px 0.5em;
-  border-left: 1px solid #DDDDDD;
-}
-.sources2 td.violations {
-  background-color: #ECECEC;
-  min-width: 450px;
+.sources2 div.violation {
+  padding: 3px 0.5em;
+  border: 1px solid #DDDDDD;
+  background-color: #EFEFEF;
+  margin: 5px 10px;
 }
 span.rulename, span.rulename a {
   color: #4183C4;
@@ -675,15 +673,17 @@ span.violation_date {
 span.rulename a:hover {
   text-decoration: underline;
 }
-.sources2 td.violations img {
+.sources2 div.violation img {
   vertical-align: sub;
 }
 .sources2 td.line {
-  padding-left: 1em;
   width: 100%;
+  border-right: 1px solid #DDD;
+}
+.sources2 td.line pre {
   font-size: 12px;
   font-family: monospace;
-  border-right: 1px solid #DDD;
+  margin-left: 1em;
 }
 .sources2 td.section {
   border-top: 1px solid #DDD;
@@ -748,8 +748,11 @@ span.rulename a:hover {
   margin-bottom: 10px;
   color: #444;
 }
-.tab_header table.col {
-  margin-right: 20px;
+.tab_header .col {
+  vertical-align:top;
+}
+.tab_header table.metrics {
+  margin-right: 10px;
   display: inline-block;
   vertical-align: top;
 }
@@ -758,15 +761,17 @@ span.rulename a:hover {
   display: inline-block;
   vertical-align: bottom;
 }
-.tab_header table.col td, .tab_header table.bottomcol td {
+.tab_header table.metrics td, .tab_header table.bottomcol td {
   padding-right: 7px;
 }
 .tab_header td.name {
   font-weight: bold;
   text-align: left;
+  white-space: nowrap;
 }
 .tab_header td.value {
   text-align: right;
+  white-space: nowrap;
 }
 #source_options {
   margin-top: 5px;