From 98b06f726fb30465113c515e67ea2f6af49398e1 Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Mon, 28 Feb 2011 18:53:33 +0100 Subject: [PATCH] SONAR-2218 display coverage of changed code in widget --- .../org/sonar/plugins/core/CorePlugin.java | 3 +- .../core/widgets/NewCoverageWidget.java | 42 ------------------- .../core/widgets/code_coverage.html.erb | 23 ++++++++++ .../core/widgets/new_coverage.html.erb | 39 ----------------- 4 files changed, 24 insertions(+), 83 deletions(-) delete mode 100644 plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/NewCoverageWidget.java delete mode 100644 plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/new_coverage.html.erb diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java index c8f802a0e5d..e53917bb95e 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java @@ -26,8 +26,8 @@ import org.sonar.api.Properties; import org.sonar.api.Property; import org.sonar.api.checks.NoSonarFilter; import org.sonar.api.resources.Java; -import org.sonar.plugins.core.batch.MavenInitializer; import org.sonar.plugins.core.batch.ExcludedResourceFilter; +import org.sonar.plugins.core.batch.MavenInitializer; import org.sonar.plugins.core.charts.DistributionAreaChart; import org.sonar.plugins.core.charts.DistributionBarChart; import org.sonar.plugins.core.charts.XradarChart; @@ -201,7 +201,6 @@ public class CorePlugin implements Plugin { extensions.add(SizeWidget.class); extensions.add(EventsWidget.class); extensions.add(CustomMeasuresWidget.class); - extensions.add(NewCoverageWidget.class); // chart extensions.add(XradarChart.class); diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/NewCoverageWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/NewCoverageWidget.java deleted file mode 100644 index 8ca5e63cb4e..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/NewCoverageWidget.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.core.widgets; - -import org.sonar.api.web.AbstractRubyTemplate; -import org.sonar.api.web.Description; -import org.sonar.api.web.RubyRailsWidget; -import org.sonar.api.web.WidgetCategory; - -@WidgetCategory({"Tests"}) -@Description("TODO") -public class NewCoverageWidget extends AbstractRubyTemplate implements RubyRailsWidget { - public String getId() { - return "new_coverage"; - } - - public String getTitle() { - return "New coverage"; - } - - @Override - protected String getTemplatePath() { - return "/org/sonar/plugins/core/widgets/new_coverage.html.erb"; - } -} \ No newline at end of file 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 afc6602ebaa..17a7f673f0f 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 @@ -71,3 +71,26 @@ <% 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)

+

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

+<% + end + end +end +%> \ No newline at end of file diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/new_coverage.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/new_coverage.html.erb deleted file mode 100644 index 102db31ca17..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/new_coverage.html.erb +++ /dev/null @@ -1,39 +0,0 @@ -

New coverage

- - - - <% m=measure('new_lines_to_cover') %> - <% 5.times do |index| %> - - <% end %> - - - - <% m=measure('new_uncovered_lines') %> - <% 5.times do |index| %> - - <% end %> - - - - <% m=measure('new_conditions_to_cover') %> - <% 5.times do |index| %> - - <% end %> - - - - <% m=measure('new_uncovered_conditions') %> - <% 5.times do |index| %> - - <% end %> - -
New lines - <%= format_variation(m, :index => index+1) -%> -
New uncovered - <%= format_variation(m, :index => index+1) -%> -
New conditions - <%= format_variation(m, :index => index+1) -%> -
New uncovered conditions - <%= format_variation(m, :index => index+1) -%> -
-- 2.39.5