]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2218 add drilldown on new lines to cover + add period select-box on measures...
authorsimonbrandhof <simon.brandhof@gmail.com>
Mon, 7 Mar 2011 15:59:29 +0000 (16:59 +0100)
committersimonbrandhof <simon.brandhof@gmail.com>
Mon, 7 Mar 2011 15:59:29 +0000 (16:59 +0100)
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/code_coverage.html.erb
sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
sonar-server/src/main/java/org/sonar/server/ui/DefaultPages.java
sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb
sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb

index dd0a2ed7656f0db93f40a2ec5ed5d0e436221939..79c0d1787fbb026b39a0854b6683cc0a10d5fe15 100644 (file)
             <% if new_lines.to_i>0 %>
               <% if new_coverage %>
                 <p>
-                  <span class="big"><a href="<%= url_for_drilldown('new_coverage', :period => dashboard_configuration.period_index, :only_periods => true) -%>"><%= new_coverage.format_numeric_value(variation_value(new_coverage))||'-' -%></a></span> coverage
+                  <span class="big"><a href="<%= url_for_drilldown('new_coverage', :period => dashboard_configuration.period_index) -%>"><%= new_coverage.format_numeric_value(variation_value(new_coverage))||'-' -%></a></span> coverage
                 </p>
               <% end %>
               <p>
-                <%= new_lines.to_i -%> new lines to cover
+                <a href="<%= url_for_drilldown('new_lines_to_cover', :period => dashboard_configuration.period_index) -%>"><%= new_lines.to_i -%></a> new lines to cover
               </p>
               <% if new_line_coverage %>
                 <p>
-                  <a href="<%= url_for_drilldown('new_uncovered_lines', :highlight => 'new_line_coverage', :period => dashboard_configuration.period_index, :only_periods => true) -%>"><%= new_line_coverage.format_numeric_value(variation_value(new_line_coverage))||'-' -%></a> line coverage
+                  <a href="<%= url_for_drilldown('new_uncovered_lines', :highlight => 'new_line_coverage', :period => dashboard_configuration.period_index) -%>"><%= new_line_coverage.format_numeric_value(variation_value(new_line_coverage))||'-' -%></a> line coverage
                 </p>
               <% end %>
               <% if new_branch_coverage %>
                 <p>
-                  <a href="<%= url_for_drilldown('new_uncovered_conditions', :highlight => 'new_branch_coverage', :period => dashboard_configuration.period_index, :only_periods => true) -%>"><%= new_branch_coverage.format_numeric_value(variation_value(new_branch_coverage))||'-' -%></a> branch coverage
+                  <a href="<%= url_for_drilldown('new_uncovered_conditions', :highlight => 'new_branch_coverage', :period => dashboard_configuration.period_index) -%>"><%= new_branch_coverage.format_numeric_value(variation_value(new_branch_coverage))||'-' -%></a> branch coverage
                 </p>
               <%
                  end
index d105ad6fa32690a3316cb86b64b43d021858a9c1..5daca1d7e72914a45e8ca462ef0d1fe6fd6a1217 100644 (file)
@@ -264,7 +264,8 @@ public final class CoreMetrics {
   public static final String NEW_LINES_TO_COVER_KEY = "new_lines_to_cover";
   public static final Metric NEW_LINES_TO_COVER = new Metric.Builder(NEW_LINES_TO_COVER_KEY, "New lines to cover", Metric.ValueType.INT)
       .setDescription("New lines to cover")
-      .setDirection(Metric.DIRECTION_BETTER)
+      .setDirection(Metric.DIRECTION_WORST)
+      .setQualitative(false)
       .setDomain(DOMAIN_TESTS)
       .setFormula(new SumChildValuesFormula(false))
       .setHidden(true)
index cc5d24a4f26e7b7401f5d7352e4640a8b8560761..c8f33678b7dd8bf7e1bde1a300499b99dba280df 100644 (file)
@@ -61,7 +61,7 @@ public final class DefaultPages {
   @DefaultTab(metrics = {CoreMetrics.COVERAGE_KEY, CoreMetrics.LINES_TO_COVER_KEY, CoreMetrics.UNCOVERED_LINES_KEY, CoreMetrics.LINE_COVERAGE_KEY,
       CoreMetrics.CONDITIONS_TO_COVER_KEY, CoreMetrics.UNCOVERED_CONDITIONS_KEY, CoreMetrics.BRANCH_COVERAGE_KEY,
       CoreMetrics.NEW_COVERAGE_KEY, CoreMetrics.NEW_UNCOVERED_LINES_KEY, CoreMetrics.NEW_LINE_COVERAGE_KEY,
-      CoreMetrics.NEW_LINES_TO_COVER_KEY, CoreMetrics.NEW_BRANCH_COVERAGE_KEY, CoreMetrics.NEW_CONDITIONS_TO_COVER_KEY
+      CoreMetrics.NEW_LINES_TO_COVER_KEY, CoreMetrics.NEW_BRANCH_COVERAGE_KEY, CoreMetrics.NEW_CONDITIONS_TO_COVER_KEY, CoreMetrics.NEW_UNCOVERED_CONDITIONS_KEY
   })
   @UserRole(UserRole.CODEVIEWER)
   private static final class CoverageTab implements RubyRailsPage {
index 217766f759168cf794e283b755b04ba5628586c6..46910f85fb440868ca8b16aaf06c7a188b10ee66 100644 (file)
@@ -25,7 +25,7 @@ class DrilldownController < ApplicationController
   SECTION=Navigation::SECTION_RESOURCE
 
   def measures
-    @metric = select_metric(params[:metric], Metric::NCLOC)
+    @metric = select_metric(params[:metric], 'ncloc')
     @highlighted_metric = Metric.by_key(params[:highlight]) || @metric
 
     # selected resources
@@ -120,7 +120,6 @@ class DrilldownController < ApplicationController
     @project = project_key ? Project.by_key(project_key) : nil
     if @project.nil?
       render :text => "Project [#{project_key}] not found", :status => 404
-      return
     end
   end
 
index c5c63f84d31d809e5929be98cc3cc4c9fd30deea..92d4ca39ee5e51cea144d86154aac25bbc9dfc57 100644 (file)
@@ -199,7 +199,6 @@ module ApplicationHelper
   # * <tt>:resource</tt> - id or key of the selected resource
   # * <tt>:highlight</tt> - key of the metric to highlight, different than the metric to drilldown.
   # * <tt>:period</tt> - period index
-  # * <tt>:only_periods</tt> - true if only v
   #
   # === Examples
   #
index 5fdeb5562d8a4bf50565a9a7c7d9ed18e9d06472..33108f61b8cbf24efa6548023db4ab887e32c7e2 100644 (file)
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
 #
 class Drilldown
-  attr_reader :snapshot, :columns
+  attr_reader :snapshot, :columns, :metric
 
   def initialize(resource, metric, selected_resource_ids, options={})
     @snapshot=Snapshot.find(:first, :conditions => {:islast => true, :project_id => resource.id}, :include => [:project])
+    @metric=metric
     @columns=[]
 
     column=nil
@@ -36,6 +37,14 @@ class Drilldown
   def highlighted_resource
     @highlighted_resource
   end
+
+  def display_value?
+    ProjectMeasure.exists?(["snapshot_id=? and metric_id=? and value is not null", @snapshot.id, @metric.id])
+  end
+
+  def display_period?(period_index)
+    ProjectMeasure.exists?(["snapshot_id=? and metric_id=? and variation_value_#{period_index.to_i} is not null", @snapshot.id, @metric.id])
+  end
 end
 
 class DrilldownColumn
index cc6a0287ccbef3a940aaabe94fafe87458d048c2..329dfd64cfb2e6ff169545759f853e68987882b4 100644 (file)
@@ -1,5 +1,29 @@
 <%= render :partial => 'header' -%>
 
+
+
+<% if params[:period] && @snapshot.project_snapshot.periods? %>
+<div id="snapshot_title" class="page_title">
+  <h4>
+    <form method="GET" action="<%= url_for :action => 'measures' -%>" style="display: inline">
+      <input type="hidden" name="metric" value="<%= params[:metric] -%>" />
+
+      <select id="select-comparison" name="period" onchange="submit()" class="small">
+        <% if @drilldown.display_value? %>
+        <option value="">Time changes...</option>
+        <% end %>
+        <% for period_index in 1..5 do %>
+          <%= period_select_options(@snapshot, 1) if @drilldown.display_period?(period_index) -%>
+        <% end %>
+    </select>
+    </form>
+  </h4>
+</div>
+<% end %>
+
+
+
+
 <div class="dashbox">
   <% if @characteristic %>
     <h3><%= @highlighted_metric.short_name -%> / <%= h(@characteristic.name(true)) -%></h3>