diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-03-07 18:42:05 +0100 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-03-07 18:42:05 +0100 |
commit | 5bdc1b1caf2b566d9613806fec394548691f33b0 (patch) | |
tree | 1404928c802a3b93992fc72684c0137e191f6d49 /sonar-server | |
parent | 6166547c9aed424caea662a7208cbd6a5c265151 (diff) | |
download | sonarqube-5bdc1b1caf2b566d9613806fec394548691f33b0.tar.gz sonarqube-5bdc1b1caf2b566d9613806fec394548691f33b0.zip |
SONAR-2218 add new coverage measures in tab header
Diffstat (limited to 'sonar-server')
7 files changed, 239 insertions, 186 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb index 92d4ca39ee5..848d6becce1 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb @@ -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 diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_coverage.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_coverage.html.erb index 7590306ac0f..3f58b908b1a 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_coverage.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_coverage.html.erb @@ -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> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_source.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_source.html.erb index 2a4d1851f78..de5451252c1 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_source.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_source.html.erb @@ -1,139 +1,148 @@ <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 index 00000000000..ba75aeb993d --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_measure.html.erb @@ -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 diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb index c3feeb1f0b4..341ef262011 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb @@ -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 diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/index.html.erb index ff260ccf00d..e4eb4bc335e 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/index.html.erb @@ -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 @@ -72,18 +71,6 @@ <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 %> @@ -96,7 +83,14 @@ <% 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> diff --git a/sonar-server/src/main/webapp/stylesheets/style.css b/sonar-server/src/main/webapp/stylesheets/style.css index f0bfa6d8daf..d418289baf0 100644 --- a/sonar-server/src/main/webapp/stylesheets/style.css +++ b/sonar-server/src/main/webapp/stylesheets/style.css @@ -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; |