From 5bdc1b1caf2b566d9613806fec394548691f33b0 Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Mon, 7 Mar 2011 18:42:05 +0100 Subject: [PATCH] SONAR-2218 add new coverage measures in tab header --- .../WEB-INF/app/helpers/application_helper.rb | 6 +- .../views/resource/_header_coverage.html.erb | 74 +++-- .../views/resource/_header_source.html.erb | 277 +++++++++--------- .../app/views/resource/_measure.html.erb | 11 + .../app/views/resource/_violation.html.erb | 4 +- .../WEB-INF/app/views/resource/index.html.erb | 22 +- .../src/main/webapp/stylesheets/style.css | 31 +- 7 files changed, 239 insertions(+), 186 deletions(-) create mode 100644 sonar-server/src/main/webapp/WEB-INF/app/views/resource/_measure.html.erb 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 @@
- +
- + + + <%= render :partial => 'measure', :locals => {:measure => measure('line_coverage'), :title => 'Line coverage'} -%> + + + <%= render :partial => 'measure', :locals => {:measure => measure('branch_coverage'), :title => 'Branch coverage'} -%> + + + + <%= render :partial => 'measure', :locals => {:measure => measure('uncovered_lines'), :title => 'Uncovered lines', :ratio => measure('lines_to_cover')} -%> + + <%= render :partial => 'measure', :locals => {:measure => measure('uncovered_conditions'), :title => 'Uncovered conditions', :ratio => measure('conditions_to_cover')} -%> -
<%= format_measure('coverage', :default => '-') -%><%= format_measure('coverage', :default => '-') -%>
- - <% if m=measure('line_coverage') %> - - - - - <% end %> - <% if m=measure('uncovered_lines') %> + <% if @period && measure('new_coverage') + new_uncovered_lines=measure('new_uncovered_lines') + %> - - + - <% end %> -
Line coverage:<%= format_measure(m) -%>
Uncovered lines:<%= format_measure(m) -%> / <%= format_measure('lines_to_cover') -%>
On new/changed code:
- - <% if m=measure('branch_coverage') %> - - + + + + + <% if m=measure('new_line_coverage') %> + + + <% else %> + + <% end %> + + + <% if m=measure('new_branch_coverage') %> + + + <% else %> + + <% end %> - <% end %> - <% if m=measure('uncovered_conditions') %> - - + + + <% if new_uncovered_lines %> + + + <% else %> + + <% end %> + + + <% if m=measure('new_uncovered_conditions') %> + + + <% else %> + + <% end %> <% end %>
Branch coverage:<%= format_measure(m) -%><%= format_variation('new_coverage', :period => @period, :style => 'none') -%> Line coverage:<%= format_variation(m, :period => @period, :style => 'none') -%> Branch coverage:<%= format_variation(m, :period => @period, :style => 'none') -%>
Uncovered conditions:<%= format_measure(m) -%> / <%= format_measure('conditions_to_cover') -%> Uncovered lines:<%= format_variation(new_uncovered_lines, :period => @period, :style => 'none') -%>/<%= format_variation('new_lines_to_cover', :period => @period, :style => 'none') -%> Uncovered conditions: <%= format_variation(m, :period => @period, :style => 'none') -%>/<%= format_variation('new_conditions_to_cover', :period => @period, :style => 'none') -%>
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 @@
- - <% if m=measure('lines') %> - - - - - <% end %> - <% if m=measure('ncloc') %> - - - - - <% end %> - <% if m=measure('functions') %> - - - - - <% end %> - <% if m=measure('accessors') %> - - - - - <% end %> - <% if m=measure('paragraphs') %> - - - - - <% end %> +
Lines:<%= format_measure(m) -%>
Lines of code:<%= format_measure(m) -%>
Methods:<%= format_measure(m) -%>
Accessors:<%= format_measure(m) -%>
Paragraphs:<%= format_measure(m) -%>
+ + + + + + +
+ + <% if m=measure('lines') %> + + + + + <% end %> + <% if m=measure('ncloc') %> + + + + + <% end %> + <% if m=measure('functions') %> + + + + + <% end %> + <% if m=measure('accessors') %> + + + + + <% end %> + <% if m=measure('paragraphs') %> + + + + + <% end %> +
Lines:<%= format_measure(m) -%>
Lines of code:<%= format_measure(m) -%>
Methods:<%= format_measure(m) -%>
Accessors:<%= format_measure(m) -%>
Paragraphs:<%= format_measure(m) -%>
+
+ + <% if m=measure('statements') %> + + + + + <% end %> + <% if m=measure('complexity') %> + + + + + <% end %> + <% if m=measure('function_complexity') %> + + + + + <% end %> + <% if m=measure('paragraph_complexity') %> + + + + + <% end %> +
Statements:<%= format_measure(m) -%>
Complexity:<%= format_measure(m) -%>
Complexity/method:<%= format_measure(m) -%>
Complexity/paragraph:<%= format_measure(m) -%>
+
+ + <% if m=measure('comment_lines_density') %> + + + + + <% end %> + <% if m=measure('comment_lines') %> + + + + + <% end %> + <% if m=measure('commented_out_code_lines') %> + + + + + <% end %> + <% if m=measure('comment_blank_lines') %> + + + + + <% end %> +
Comments:<%= format_measure(m) -%>
Comment lines:<%= format_measure(m) -%>
Commented-out LOC:<%= format_measure(m) -%>
Blank comments:<%= format_measure(m) -%>
+
+ + <% if m=measure('public_documented_api_density') %> + + + + + <% end %> + <% if m=measure('public_undocumented_api') %> + + + + + <% end %> + <% if m=measure('public_api') %> + + + + + <% end %> +
Public documented API:<%= format_measure(m) -%>
Public undocumented API:<%= format_measure(m) -%>
Public API:<%= format_measure(m) -%>
+
+ + <% if m=measure('classes') %> + + + + + <% end %> + <% if m=measure('noc') %> + + + + + <% end %> + <% if m=measure('dit') %> + + + + + <% end %> + <% if m=measure('rfc') %> + + + + + <% end %> +
Classes:<%= format_measure(m) -%>
Number of Children:<%= format_measure(m) -%>
Depth in Tree:<%= format_measure(m) -%>
Response for Class (RFC):<%= format_measure(m) -%>
+
- - - <% if m=measure('statements') %> - - - - - <% end %> - <% if m=measure('complexity') %> - - - - - <% end %> - <% if m=measure('function_complexity') %> - - - - - <% end %> - <% if m=measure('paragraph_complexity') %> - - - - - <% end %> -
Statements:<%= format_measure(m) -%>
Complexity:<%= format_measure(m) -%>
Complexity/method:<%= format_measure(m) -%>
Complexity/paragraph:<%= format_measure(m) -%>
- - - <% if m=measure('comment_lines_density') %> - - - - - <% end %> - <% if m=measure('comment_lines') %> - - - - - <% end %> - <% if m=measure('commented_out_code_lines') %> - - - - - <% end %> - <% if m=measure('comment_blank_lines') %> - - - - - <% end %> -
Comments:<%= format_measure(m) -%>
Comment lines:<%= format_measure(m) -%>
Commented-out LOC:<%= format_measure(m) -%>
Blank comments:<%= format_measure(m) -%>
- - - <% if m=measure('public_documented_api_density') %> - - - - - <% end %> - <% if m=measure('public_undocumented_api') %> - - - - - <% end %> - <% if m=measure('public_api') %> - - - - - <% end %> -
Public documented API:<%= format_measure(m) -%>
Public undocumented API:<%= format_measure(m) -%>
Public API:<%= format_measure(m) -%>
- - - <% if m=measure('classes') %> - - - - - <% end %> - <% if m=measure('noc') %> - - - - - <% end %> - <% if m=measure('dit') %> - - - - - <% end %> - <% if m=measure('rfc') %> - - - - - <% end %> -
Classes:<%= format_measure(m) -%>
Number of Children:<%= format_measure(m) -%>
Depth in Tree:<%= format_measure(m) -%>
Response for Class (RFC):<%= format_measure(m) -%>
- <%= render :partial => 'options' -%>
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 %> + <%= h(title) -%>: + + <%= format_measure(measure) -%> + <% if defined?(ratio) && ratio %> + /<%= format_measure(ratio) -%> + <% end %> + +<% else %> + +<% 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 @@ +
<%= h(violation.rule.name) -%> @@ -9,4 +10,5 @@ %> <%= duration==0 ? 'today' : "#{duration} days ago" -%> -<% end %> \ No newline at end of file +<% end %> +
\ 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 @@ <% end end %> - <% if @display_violations %> - - <% if line.violations? - line.violations.each_with_index do |violation, violation_index| %> - <%= '
' if violation_index>0 %> - <%= render :partial => 'violation', :locals => {:violation => violation} -%> - <% - end - end - %> - - <% end %> <%= index + 1 -%> <% if @display_coverage %> @@ -96,7 +83,14 @@ <% end %> <% end %> -
<%= line.source -%>
+ +
<%= line.source -%>
+ <% if @display_violations && line.violations? %> + <% line.violations.each do |violation| %> + <%= render :partial => 'violation', :locals => {:violation => violation} -%> + <% end %> + <% end %> + <% end %> 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; -- 2.39.5