From 3f1a93b472a4ed1503714403146ef22b69b1efa6 Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Mon, 7 Mar 2011 15:09:59 +0100 Subject: [PATCH] SONAR-2218 improve rendering of coverage widget --- .../core/widgets/code_coverage.html.erb | 110 ++++++++++-------- 1 file changed, 60 insertions(+), 50 deletions(-) diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/code_coverage.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/code_coverage.html.erb index 6110cdac682..dd0a2ed7656 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/code_coverage.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/code_coverage.html.erb @@ -1,8 +1,8 @@ <% - code_coverage_measure=measure(Metric::COVERAGE) - tests_measure=measure(Metric::TESTS) - execution_time=measure(Metric::TEST_EXECUTION_TIME) - success_percentage=measure(Metric::TEST_SUCCESS_DENSITY) + code_coverage_measure=measure('coverage') + tests_measure=measure('tests') + execution_time=measure('test_execution_time') + success_percentage=measure('test_success_density') if code_coverage_measure || tests_measure %> @@ -12,44 +12,65 @@

Code coverage

- <%= format_measure(code_coverage_measure, :suffix => '', :url => url_for_drilldown(Metric::COVERAGE), :default => '-') %> + <%= format_measure(code_coverage_measure, :suffix => '', :url => url_for_drilldown('coverage'), :default => '-') %> <%= dashboard_configuration.selected_period? ? format_variation(code_coverage_measure) : trend_icon(code_coverage_measure) -%>

- <% line_coverage=measure(Metric::LINE_COVERAGE) + <% line_coverage=measure('line_coverage') if line_coverage %>

<%= format_measure(line_coverage, :suffix => ' line coverage', :url => url_for_drilldown('uncovered_lines', :highlight => 'line_coverage')) %> <%= dashboard_configuration.selected_period? ? format_variation(line_coverage) : trend_icon(line_coverage) -%>

<% end %> - <% branch_coverage=measure(Metric::BRANCH_COVERAGE) + <% branch_coverage=measure('branch_coverage') if branch_coverage %>

<%= format_measure(branch_coverage, :suffix => ' branch coverage', :url => url_for_drilldown('uncovered_conditions', :highlight => 'branch_coverage')) %> <%= dashboard_configuration.selected_period? ? format_variation(branch_coverage) : trend_icon(branch_coverage) -%>

<% end %> -

- <%= format_measure(tests_measure, :suffix => ' tests', :url => url_for_drilldown(Metric::TESTS)) %> - <%= dashboard_configuration.selected_period? ? format_variation(tests_measure) : trend_icon(tests_measure) -%> -

- <% skipped_measure=measure(Metric::SKIPPED_TESTS) - if dashboard_configuration.selected_period? || (skipped_measure && skipped_measure.value && skipped_measure.value>0) + + <% + if dashboard_configuration.selected_period? + new_lines_to_cover_measure=measure('new_lines_to_cover') + if new_lines_to_cover_measure + new_lines=new_lines_to_cover_measure.variation(dashboard_configuration.period_index) + if new_lines + new_coverage=measure('new_coverage') + new_line_coverage=measure('new_line_coverage') + new_branch_coverage=measure('new_branch_coverage') + %>
+

On new/changed code:

+ <% if new_lines.to_i>0 %> + <% if new_coverage %> +

+ <%= new_coverage.format_numeric_value(variation_value(new_coverage))||'-' -%> coverage +

+ <% end %> +

+ <%= new_lines.to_i -%> new lines to cover +

+ <% if new_line_coverage %> +

+ <%= new_line_coverage.format_numeric_value(variation_value(new_line_coverage))||'-' -%> line coverage +

+ <% end %> + <% if new_branch_coverage %> +

+ <%= new_branch_coverage.format_numeric_value(variation_value(new_branch_coverage))||'-' -%> branch coverage +

+ <% + end + end + end + end + end %> -

- +<%= format_measure(skipped_measure, :suffix => ' skipped', :url => url_for_drilldown(Metric::SKIPPED_TESTS), :default => '0') %> - <%= dashboard_configuration.selected_period? ? format_variation(skipped_measure) : trend_icon(skipped_measure) -%> -

- <% end %> -

- <%= format_measure(execution_time, :suffix => '', :url => url_for_drilldown(Metric::TEST_EXECUTION_TIME)) %> - <%= dashboard_configuration.selected_period? ? format_variation(execution_time) : trend_icon(execution_time) -%> -

<% - if success_percentage + if tests_measure %>

Test success

@@ -65,6 +86,22 @@ <%= format_measure(Metric::TEST_ERRORS, :suffix => ' errors', :url => url_for_drilldown(Metric::TEST_ERRORS)) %> <%= dashboard_configuration.selected_period? ? format_variation(Metric::TEST_ERRORS) : trend_icon(Metric::TEST_ERRORS) -%>

+

+ <%= format_measure(tests_measure, :suffix => ' tests', :url => url_for_drilldown('tests')) %> + <%= dashboard_configuration.selected_period? ? format_variation(tests_measure) : trend_icon(tests_measure) -%> +

+ <% skipped_measure=measure(Metric::SKIPPED_TESTS) + if dashboard_configuration.selected_period? || (skipped_measure && skipped_measure.value && skipped_measure.value>0) + %> +

+ +<%= format_measure(skipped_measure, :suffix => ' skipped', :url => url_for_drilldown(Metric::SKIPPED_TESTS), :default => '0') %> + <%= dashboard_configuration.selected_period? ? format_variation(skipped_measure) : trend_icon(skipped_measure) -%> +

+ <% end %> +

+ <%= format_measure(execution_time, :suffix => '', :url => url_for_drilldown('test_execution_time')) %> + <%= dashboard_configuration.selected_period? ? format_variation(execution_time) : trend_icon(execution_time) -%> +

<% end %> @@ -73,30 +110,3 @@ <% end %> -<% -if dashboard_configuration.selected_period? - new_lines_to_cover_measure=measure('new_lines_to_cover') - if new_lines_to_cover_measure - new_lines=new_lines_to_cover_measure.variation(dashboard_configuration.period_index) - if new_lines - new_coverage=measure('new_coverage') - new_line_coverage=measure('new_line_coverage') - new_branch_coverage=measure('new_branch_coverage') -%> -

on changed code (<%= new_lines.to_i -%> new lines to cover)

-

- <% if new_coverage %> - Coverage: <%= new_coverage.format_numeric_value(variation_value(new_coverage)) -%>
- <% end %> - <% if new_line_coverage %> - Line coverage: <%= new_line_coverage.format_numeric_value(variation_value(new_line_coverage)) -%>
- <% end %> - <% if new_branch_coverage %> - Branch coverage: <%= new_branch_coverage.format_numeric_value(variation_value(new_branch_coverage)) -%> - <% end %> -

-<% - end - end -end -%> \ No newline at end of file -- 2.39.5