From 4797af9603b3866df947f5c503e23a9e8115aa63 Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Fri, 3 Dec 2010 12:59:56 +0000 Subject: [PATCH] SONAR-249 improve some widgets + display variation of test execution time --- .../core/widgets/code_coverage.html.erb | 6 +++--- .../widgets/comments_duplications.html.erb | 20 +++++++++---------- .../plugins/core/widgets/complexity.html.erb | 3 +-- .../ui/widgets/chidamber_kemerer.html.erb | 9 +++------ .../design/ui/widgets/file_design.html.erb | 9 +++------ .../design/ui/widgets/package_design.html.erb | 10 ++++------ .../WEB-INF/app/models/project_measure.rb | 10 +++++----- 7 files changed, 29 insertions(+), 38 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 85eaf154043..c52463487f6 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 @@ -18,7 +18,7 @@ <% line_coverage=measure(Metric::LINE_COVERAGE) if line_coverage %>

- <%= format_measure(line_coverage, :suffix => ' line coverage', :url => url_for_drilldown(Metric::UNCOVERED_LINES, :highlight => Metric::LINE_COVERAGE)) -%> + <%= format_measure(line_coverage, :suffix => ' line coverage', :url => url_for_drilldown(Metric::UNCOVERED_LINES, :highlight => Metric::LINE_COVERAGE)) %> <%= dashboard_configuration.variation? ? format_variation(line_coverage) : trend_icon(line_coverage) -%>

<% end %> @@ -30,7 +30,7 @@

<% end %>

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

<% skipped_measure=measure(Metric::SKIPPED_TESTS) @@ -42,7 +42,7 @@

<% end %>

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

diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/comments_duplications.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/comments_duplications.html.erb index 1edc9a936b5..ff26313e009 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/comments_duplications.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/comments_duplications.html.erb @@ -18,30 +18,30 @@

Comments

- <%= format_measure(comment_lines_density, :suffix => '', :url => url_for_drilldown(comment_lines_density)) -%> + <%= format_measure(comment_lines_density, :suffix => '', :url => url_for_drilldown(comment_lines_density)) %> <%= dashboard_configuration.variation? ? format_variation(comment_lines_density) : trend_icon(comment_lines_density, :big => true) -%>

- <%= format_measure(comment_lines, :suffix => ' lines', :url => url_for_drilldown(comment_lines)) -%> + <%= format_measure(comment_lines, :suffix => ' lines', :url => url_for_drilldown(comment_lines)) %> <%= dashboard_configuration.variation? ? format_variation(comment_lines) : trend_icon(comment_lines) -%>

<% if comment_blank_lines && comment_blank_lines.value>0 %> -

+<%= format_measure(comment_blank_lines, :suffix => ' blank', :url => url_for_drilldown(comment_blank_lines)) -%> +

+<%= format_measure(comment_blank_lines, :suffix => ' blank', :url => url_for_drilldown(comment_blank_lines)) %> <%= dashboard_configuration.variation? ? format_variation(comment_blank_lines) : trend_icon(comment_blank_lines) -%>

<% end %>

- <%= format_measure(public_documented_api_density, :suffix => ' docu. API', :url => url_for_drilldown(Metric::PUBLIC_UNDOCUMENTED_API, :highlight => Metric::PUBLIC_DOCUMENTED_API_DENSITY)) -%> + <%= format_measure(public_documented_api_density, :suffix => ' docu. API', :url => url_for_drilldown(Metric::PUBLIC_UNDOCUMENTED_API, :highlight => Metric::PUBLIC_DOCUMENTED_API_DENSITY)) %> <%= dashboard_configuration.variation? ? format_variation(public_documented_api_density) : trend_icon(public_documented_api_density) -%>

- <%= format_measure(public_undocumented_api, :suffix => ' undocu. API', :url => url_for_drilldown(public_undocumented_api)) -%> + <%= format_measure(public_undocumented_api, :suffix => ' undocu. API', :url => url_for_drilldown(public_undocumented_api)) %> <%= dashboard_configuration.variation? ? format_variation(public_undocumented_api) : trend_icon(public_undocumented_api) -%>

- <%= format_measure(commented_out_lines, :suffix => ' commented LOCs', :url => url_for_drilldown(commented_out_lines)) -%> + <%= format_measure(commented_out_lines, :suffix => ' commented LOCs', :url => url_for_drilldown(commented_out_lines)) %> <%= dashboard_configuration.variation? ? format_variation(commented_out_lines) : trend_icon(commented_out_lines) -%>

@@ -52,19 +52,19 @@

Duplications

- <%= format_measure(duplicated_lines_density, :suffix => '', :url => url_for_drilldown(Metric::DUPLICATED_LINES, :highlight => 'duplicated_lines_density')) -%> + <%= format_measure(duplicated_lines_density, :suffix => '', :url => url_for_drilldown(Metric::DUPLICATED_LINES, :highlight => 'duplicated_lines_density')) %> <%= dashboard_configuration.variation? ? format_variation(duplicated_lines_density) : trend_icon(duplicated_lines_density, :big => true) -%>

- <%= format_measure(duplicated_lines, :suffix => ' lines', :url => url_for_drilldown(duplicated_lines)) -%> + <%= format_measure(duplicated_lines, :suffix => ' lines', :url => url_for_drilldown(duplicated_lines)) %> <%= dashboard_configuration.variation? ? format_variation(duplicated_lines) : trend_icon(duplicated_lines) -%>

- <%= format_measure(duplicated_blocks, :suffix => ' blocks', :url => url_for_drilldown(duplicated_blocks)) -%> + <%= format_measure(duplicated_blocks, :suffix => ' blocks', :url => url_for_drilldown(duplicated_blocks)) %> <%= dashboard_configuration.variation? ? format_variation(duplicated_blocks) : trend_icon(duplicated_blocks) -%>

- <%= format_measure(duplicated_files, :suffix => ' files', :url => url_for_drilldown(duplicated_files)) -%> + <%= format_measure(duplicated_files, :suffix => ' files', :url => url_for_drilldown(duplicated_files)) %> <%= dashboard_configuration.variation? ? format_variation(duplicated_files) : trend_icon(duplicated_files) -%>

diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/complexity.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/complexity.html.erb index c62b359b07e..c4ca576fe3a 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/complexity.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/complexity.html.erb @@ -40,8 +40,7 @@ complexity=measure('complexity') <% end %> <% if complexity %>

- Total: <%= format_measure(complexity, :url => url_for_drilldown(complexity)) -%> - <%= dashboard_configuration.variation? ? format_variation(complexity) : trend_icon(complexity) -%> + Total: <%= format_measure(complexity, :url => url_for_drilldown(complexity)) -%> <%= dashboard_configuration.variation? ? format_variation(complexity) : trend_icon(complexity) -%>

<% end %> diff --git a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/chidamber_kemerer.html.erb b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/chidamber_kemerer.html.erb index 14db73663a6..d1582f9d3c6 100644 --- a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/chidamber_kemerer.html.erb +++ b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/chidamber_kemerer.html.erb @@ -14,12 +14,10 @@ if lcom || rfc

LCOM4

- <%= format_measure(lcom, :suffix => '', :default => '-', :url => url_for_drilldown('lcom4')) -%> /class - <%= dashboard_configuration.variation? ? format_variation(lcom) : trend_icon(lcom, :big => true) -%> + <%= format_measure(lcom, :suffix => '', :default => '-', :url => url_for_drilldown('lcom4')) -%> /class <%= dashboard_configuration.variation? ? format_variation(lcom) : trend_icon(lcom, :big => true) -%>

- <%= format_measure(suspect_lcom4_density, :suffix => ' files having LCOM4>1', :url => url_for_drilldown('lcom4')) -%> - <%= dashboard_configuration.variation? ? format_variation(suspect_lcom4_density) : trend_icon(suspect_lcom4_density) -%> + <%= format_measure(suspect_lcom4_density, :suffix => ' files having LCOM4>1', :url => url_for_drilldown('lcom4')) %> <%= dashboard_configuration.variation? ? format_variation(suspect_lcom4_density) : trend_icon(suspect_lcom4_density) -%>

@@ -29,8 +27,7 @@ if lcom || rfc

RFC

- <%= format_measure(rfc, :suffix => '', :default => '-', :url => url_for_drilldown('rfc')) -%> /class - <%= dashboard_configuration.variation? ? format_variation(rfc) : trend_icon(rfc, :big => true) -%> + <%= format_measure(rfc, :suffix => '', :default => '-', :url => url_for_drilldown('rfc')) -%> /class <%= dashboard_configuration.variation? ? format_variation(rfc) : trend_icon(rfc, :big => true) -%>

diff --git a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/file_design.html.erb b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/file_design.html.erb index 22e5b28f956..fd30f977a44 100644 --- a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/file_design.html.erb +++ b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/file_design.html.erb @@ -11,13 +11,11 @@

File tangle index

- <%= format_measure(file_tangle_index, :suffix => '', :default => '-', :url => url_for_drilldown('file_tangle_index')) -%> - <%= dashboard_configuration.variation? ? format_variation(file_tangle_index) : trend_icon(file_tangle_index, :big => true) -%> + <%= format_measure(file_tangle_index, :suffix => '', :default => '-', :url => url_for_drilldown('file_tangle_index')) -%> <%= dashboard_configuration.variation? ? format_variation(file_tangle_index) : trend_icon(file_tangle_index, :big => true) -%>

<% if file_cycles %>

- > <%= format_measure(file_cycles, :suffix => ' cycles', :url => url_for_drilldown('file_cycles')) -%> - <%= dashboard_configuration.variation? ? format_variation(file_cycles) : trend_icon(file_cycles) -%> + > <%= format_measure(file_cycles, :suffix => ' cycles', :url => url_for_drilldown('file_cycles')) %> <%= dashboard_configuration.variation? ? format_variation(file_cycles) : trend_icon(file_cycles) -%>

<% end %>
@@ -27,8 +25,7 @@

Suspect file dependencies

- <%= format_measure(file_feedback_edges, :url => url_for_drilldown('file_feedback_edges')) -%> - <%= dashboard_configuration.variation? ? format_variation(file_feedback_edges) : trend_icon(file_feedback_edges, :big => true) -%> + <%= format_measure(file_feedback_edges, :url => url_for_drilldown('file_feedback_edges')) -%> <%= dashboard_configuration.variation? ? format_variation(file_feedback_edges) : trend_icon(file_feedback_edges, :big => true) -%>

<% end %> diff --git a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/package_design.html.erb b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/package_design.html.erb index ed783ddc40f..10380f4f8cf 100644 --- a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/package_design.html.erb +++ b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/package_design.html.erb @@ -15,13 +15,11 @@

Package tangle index

- <%= format_measure(package_tangle_index, :suffix => '', :default => '-', :url => url_for_drilldown('package_tangle_index')) -%> - <%= dashboard_configuration.variation? ? format_variation(package_tangle_index) : trend_icon(package_tangle_index, :big => true) -%> + <%= format_measure(package_tangle_index, :suffix => '', :default => '-', :url => url_for_drilldown('package_tangle_index')) -%> <%= dashboard_configuration.variation? ? format_variation(package_tangle_index) : trend_icon(package_tangle_index, :big => true) -%>

<% if package_cycles %>

- > <%= format_measure(package_cycles, :suffix => ' cycles', :url => url_for_drilldown('package_cycles')) -%> - <%= dashboard_configuration.variation? ? format_variation(package_cycles) : trend_icon(package_cycles) -%> + > <%= format_measure(package_cycles, :suffix => ' cycles', :url => url_for_drilldown('package_cycles')) %> <%= dashboard_configuration.variation? ? format_variation(package_cycles) : trend_icon(package_cycles) -%>

<% end %>
@@ -31,11 +29,11 @@

Dependencies to cut

- <%= format_measure(package_feedback_edges, :suffix => ' between packages', :url => url_for_drilldown('package_feedback_edges')) -%> + <%= format_measure(package_feedback_edges, :suffix => ' between packages', :url => url_for_drilldown('package_feedback_edges')) %> <%= dashboard_configuration.variation? ? format_variation(package_feedback_edges) : trend_icon(package_feedback_edges) -%>

- <%= format_measure(package_tangles, :suffix => ' between files', :url => url_for_drilldown('package_tangles')) -%> + <%= format_measure(package_tangles, :suffix => ' between files', :url => url_for_drilldown('package_tangles')) %> <%= dashboard_configuration.variation? ? format_variation(package_tangles) : trend_icon(package_tangles) -%>

diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb index e249ed87b6c..8e08ab98147 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb @@ -101,7 +101,7 @@ class ProjectMeasure < ActiveRecord::Base when Metric::VALUE_TYPE_PERCENT number_to_percentage(val, {:precision => 1}) when Metric::VALUE_TYPE_MILLISEC - millisecs_formatted_value( val ) + millisecs_formatted_value(val) else val.to_s end @@ -122,18 +122,18 @@ class ProjectMeasure < ActiveRecord::Base def millisecs_formatted_value( value ) # bugfix with jruby 1.0 release does not support % for BigDecimal - value = value.to_i if value.kind_of? BigDecimal - if value >= HOUR + value = value.to_i + if value.abs >= HOUR hours = ( value / HOUR ).to_i mins = ( value % HOUR / MIN ).to_i secs = ( value % MIN / SEC ).to_i return hours.to_s + ":" + leading_zero( mins ) + ":" + leading_zero( secs ) + " h" - elsif value >= MIN + elsif value.abs >= MIN mins = ( value / MIN ).to_i secs = ( value % MIN / SEC ).to_i millisecs = ( value % MIN % SEC ).to_i return mins.to_s + ":" + leading_zero( secs ) + " min" - elsif value >= SEC + elsif value.abs >= SEC secs = ( value / SEC ).to_i millisecs = ( value % SEC ).to_i return secs.to_s + "." + millisecs.to_s[0, 1] + " sec" if millisecs != 0 -- 2.39.5