]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2218 display coverage of changed code in widget
authorsimonbrandhof <simon.brandhof@gmail.com>
Mon, 28 Feb 2011 17:53:33 +0000 (18:53 +0100)
committersimonbrandhof <simon.brandhof@gmail.com>
Mon, 28 Feb 2011 17:53:33 +0000 (18:53 +0100)
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/NewCoverageWidget.java [deleted file]
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/code_coverage.html.erb
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/new_coverage.html.erb [deleted file]

index c8f802a0e5d0250127d92ad92c487cd7a1f8b72c..e53917bb95e5feab105555f5b88ddb2ae2024524 100644 (file)
@@ -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 (file)
index 8ca5e63..0000000
+++ /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
index afc6602ebaaeb5f6969eefbbf7fd1dd98b313c85..17a7f673f0fc645a78fb49e7983e0375476c326e 100644 (file)
 </tr>
 </table>
 <% 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')
+%>
+    <h3>on changed code (<%= new_lines.to_i -%> new lines to cover)</h3>
+    <p>
+      Coverage: <%= new_coverage.format_numeric_value(variation_value(new_coverage)) -%><br/>
+      Line coverage: <%= new_line_coverage.format_numeric_value(variation_value(new_line_coverage)) -%><br/>
+      Branch coverage: <%= new_branch_coverage.format_numeric_value(variation_value(new_branch_coverage)) -%>
+    </p>
+<%
+    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 (file)
index 102db31..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-<h2>New coverage</h2>
-  <table>
-    <tr>
-      <td>New lines</td>
-      <% m=measure('new_lines_to_cover') %>
-      <% 5.times do |index| %>
-      <td>
-        <%= format_variation(m, :index => index+1) -%>
-      </td>
-      <% end %>
-    </tr>
-    <tr>
-      <td>New uncovered</td>
-      <% m=measure('new_uncovered_lines') %>
-      <% 5.times do |index| %>
-      <td>
-        <%= format_variation(m, :index => index+1) -%>
-      </td>
-      <% end %>
-    </tr>
-    <tr>
-      <td>New conditions</td>
-      <% m=measure('new_conditions_to_cover') %>
-      <% 5.times do |index| %>
-      <td>
-        <%= format_variation(m, :index => index+1) -%>
-      </td>
-      <% end %>
-    </tr>
-    <tr>
-      <td>New uncovered conditions</td>
-      <% m=measure('new_uncovered_conditions') %>
-      <% 5.times do |index| %>
-      <td>
-        <%= format_variation(m, :index => index+1) -%>
-      </td>
-      <% end %>
-    </tr>
-  </table>