From 2b110947560917854887876ab202468fccaebdd2 Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Wed, 16 Mar 2011 17:29:57 +0100 Subject: [PATCH] Add new_coverage metrics to filters --- .../src/main/java/org/sonar/api/measures/CoreMetrics.java | 7 ------- .../webapp/WEB-INF/app/controllers/resource_controller.rb | 2 ++ .../WEB-INF/app/controllers/timemachine_controller.rb | 2 +- .../main/webapp/WEB-INF/app/helpers/application_helper.rb | 1 + .../webapp/WEB-INF/app/views/drilldown/measures.html.erb | 2 +- .../main/webapp/WEB-INF/app/views/resource/index.html.erb | 6 ++++++ 6 files changed, 11 insertions(+), 9 deletions(-) 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 4cef9962936..7b6163bd396 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 @@ -251,7 +251,6 @@ public final class CoreMetrics { .setDescription("Coverage of new/changed code") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) - .setHidden(true) .setDomain(DOMAIN_TESTS) .setWorstValue(0.0) .setBestValue(100.0) @@ -274,7 +273,6 @@ public final class CoreMetrics { .setQualitative(false) .setDomain(DOMAIN_TESTS) .setFormula(new SumChildValuesFormula(false)) - .setHidden(true) .create(); public static final String UNCOVERED_LINES_KEY = "uncovered_lines"; @@ -290,7 +288,6 @@ public final class CoreMetrics { .setDescription("New uncovered lines") .setDirection(Metric.DIRECTION_WORST) .setDomain(DOMAIN_TESTS) - .setHidden(true) .setFormula(new SumChildValuesFormula(false)) .create(); @@ -309,7 +306,6 @@ public final class CoreMetrics { .setQualitative(true) .setWorstValue(0.0) .setBestValue(100.0) - .setHidden(true) .setDomain(DOMAIN_TESTS) .create(); @@ -331,7 +327,6 @@ public final class CoreMetrics { .setDescription("New conditions to cover") .setDomain(DOMAIN_TESTS) .setFormula(new SumChildValuesFormula(false)) - .setHidden(true) .create(); public static final String UNCOVERED_CONDITIONS_KEY = "uncovered_conditions"; @@ -347,7 +342,6 @@ public final class CoreMetrics { .setDescription("New uncovered conditions") .setDirection(Metric.DIRECTION_WORST) .setDomain(DOMAIN_TESTS) - .setHidden(true) .setFormula(new SumChildValuesFormula(false)) .create(); @@ -366,7 +360,6 @@ public final class CoreMetrics { .setDescription("Branch coverage of new/changed code") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) - .setHidden(true) .setDomain(DOMAIN_TESTS) .setWorstValue(0.0) .setBestValue(100.0) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb index 0ebc8b8be8f..672eb3683a4 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb @@ -146,6 +146,7 @@ class ResourceController < ApplicationController @display_violations=true @global_violations=[] @expandable=(@lines!=nil) + @filtered=!@expanded conditions='snapshot_id=?' values=[@snapshot.id] @@ -206,6 +207,7 @@ class ResourceController < ApplicationController def filter_lines_by_date if @period + @filtered=true to=@snapshot.period_datetime(@period) if to @lines.each do |line| diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb index febcdd9127d..82b677a33e6 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb @@ -61,7 +61,7 @@ class TimemachineController < ApplicationController measures.each do |measure| next unless measure.metric - if measure.metric.timemachine? + if measure.metric.timemachine? && measure.value row=rows_by_metric_id[measure.metric_id] unless row row=Sonar::TimemachineRow.new(measure.metric) 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 44232d80298..af3bb857f53 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 @@ -232,6 +232,7 @@ module ApplicationHelper # * :url - add an url on the measure. # * :prefix - add a prefix. Default is ''. # * :suffix - add a suffix. Default is ''. + # * :period - period index, from 1 to 5. Optional. Default is nil. # * :default - text to return if metric or measure not found. Default is blank string. # # === Examples 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 6da915f8c1b..dccb0e81d9d 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 @@ -40,7 +40,7 @@ <% if @highlighted_metric!=@metric %> - + <% end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/index.html.erb index 1f51b7c26c7..bb9383f2b17 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/index.html.erb @@ -22,11 +22,13 @@ colspan+=2 if @display_coverage previous_hidden=false first_section=true + has_displayed_lines=false @lines.each_with_index do |line, index| if line.hidden previous_hidden=true next end + has_displayed_lines=true if previous_hidden && !first_section current_revision=nil @@ -93,4 +95,8 @@ <% end %>
Drilldown on <%= @snapshot.f_measure(@metric.key) -%> <%= @metric.short_name -%>Drilldown on <%= format_measure(@metric.key, :period => @period) -%> <%= @metric.short_name -%>
+ + <% if @filtered && !has_displayed_lines %> +

No lines match your filter criteria.

+ <% end %> <% end %> \ No newline at end of file -- 2.39.5