diff options
7 files changed, 42 insertions, 10 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 dd0a2ed7656..79c0d1787fb 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 @@ -44,20 +44,20 @@ <% 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 diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java index d105ad6fa32..5daca1d7e72 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java @@ -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) diff --git a/sonar-server/src/main/java/org/sonar/server/ui/DefaultPages.java b/sonar-server/src/main/java/org/sonar/server/ui/DefaultPages.java index cc5d24a4f26..c8f33678b7d 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/DefaultPages.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/DefaultPages.java @@ -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 { diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb index 217766f7591..46910f85fb4 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb @@ -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 diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb index c5c63f84d31..92d4ca39ee5 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb @@ -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 # diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb index 5fdeb5562d8..33108f61b8c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb @@ -18,10 +18,11 @@ # 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 diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb index cc6a0287ccb..329dfd64cfb 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb @@ -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> |