aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/code_coverage.html.erb16
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java7
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb11
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb32
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb10
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb16
7 files changed, 56 insertions, 38 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 17a7f673f0f..6110cdac682 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
@@ -18,14 +18,14 @@
<% line_coverage=measure(Metric::LINE_COVERAGE)
if line_coverage %>
<p>
- <%= format_measure(line_coverage, :suffix => ' line coverage', :url => url_for_drilldown(Metric::UNCOVERED_LINES, :highlight => Metric::LINE_COVERAGE)) %>
+ <%= format_measure(line_coverage, :suffix => ' line coverage', :url => url_for_drilldown('uncovered_lines', :highlight => 'line_coverage')) %>
<%= dashboard_configuration.selected_period? ? format_variation(line_coverage) : trend_icon(line_coverage) -%>
</p>
<% end %>
<% branch_coverage=measure(Metric::BRANCH_COVERAGE)
if branch_coverage %>
<p>
- <%= format_measure(branch_coverage, :suffix => ' branch coverage', :url => url_for_drilldown(Metric::UNCOVERED_CONDITIONS, :highlight => Metric::BRANCH_COVERAGE)) %>
+ <%= format_measure(branch_coverage, :suffix => ' branch coverage', :url => url_for_drilldown('uncovered_conditions', :highlight => 'branch_coverage')) %>
<%= dashboard_configuration.selected_period? ? format_variation(branch_coverage) : trend_icon(branch_coverage) -%>
</p>
<% end %>
@@ -85,9 +85,15 @@ if dashboard_configuration.selected_period?
%>
<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)) -%>
+ <% if new_coverage %>
+ Coverage: <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><br/>
+ <% end %>
+ <% if new_line_coverage %>
+ Line coverage: <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><br/>
+ <% end %>
+ <% if new_branch_coverage %>
+ Branch coverage: <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>
+ <% end %>
</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 80f9451ec42..f6dac6dbf82 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
@@ -259,6 +259,7 @@ 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)
@@ -293,6 +294,7 @@ public final class CoreMetrics {
.setDescription("New uncovered lines")
.setDirection(Metric.DIRECTION_WORST)
.setDomain(DOMAIN_TESTS)
+ .setHidden(true)
.setFormula(new SumChildValuesFormula(false))
.create();
@@ -313,6 +315,7 @@ public final class CoreMetrics {
.setQualitative(true)
.setWorstValue(0.0)
.setBestValue(100.0)
+ .setHidden(true)
.setDomain(DOMAIN_TESTS)
.create();
@@ -354,6 +357,7 @@ public final class CoreMetrics {
.setDescription("New uncovered conditions")
.setDirection(Metric.DIRECTION_WORST)
.setDomain(DOMAIN_TESTS)
+ .setHidden(true)
.setFormula(new SumChildValuesFormula(false))
.create();
@@ -370,10 +374,11 @@ public final class CoreMetrics {
public static final String NEW_BRANCH_COVERAGE_KEY = "new_branch_coverage";
public static final Metric NEW_BRANCH_COVERAGE = new Metric.Builder(NEW_BRANCH_COVERAGE_KEY, Metric.ValueType.PERCENT)
- .setName("NEw branch coverage")
+ .setName("New branch coverage")
.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/drilldown_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb
index 5462e264960..217766f7591 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
@@ -48,7 +48,10 @@ class DrilldownController < ApplicationController
@characteristic=Characteristic.find(:first, :select => 'id', :include => 'quality_model', :conditions => ['quality_models.name=? AND characteristics.kee=? AND characteristics.enabled=?', params[:model], params[:characteristic], true])
end
options[:characteristic]=@characteristic
-
+ if params[:period]
+ @period=params[:period].to_i
+ options[:period]=@period
+ end
# load data
@drilldown = Drilldown.new(@project, @metric, selected_rids, options)
@@ -66,10 +69,10 @@ class DrilldownController < ApplicationController
# variation measures
if params[:period].blank?
- @period_index=nil
+ @period=nil
metric_prefix = ''
else
- @period_index=params[:period].to_i
+ @period=params[:period].to_i
metric_prefix = 'new_'
end
@@ -93,7 +96,7 @@ class DrilldownController < ApplicationController
# options for Drilldown
- options={:exclude_zero_value => true, :period_index => @period_index}
+ options={:exclude_zero_value => true, :period => @period}
if @rule
params[:rule]=@rule.key # workaround for SONAR-1767 : the javascript hash named "rp" in the HTML source must contain the rule key, but not the rule id
options[:rule_id]=@rule.id
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 630cc6598c4..fe1c0da82f0 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,13 +199,20 @@ 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>:viewer_plugin_key</tt> - the default GWT plugin to be used when clicking on a resource in the drilldown to view it's source
+ # * <tt>:period</tt> - period index
+ # * <tt>:only_periods</tt> - true if only v
#
# === Examples
#
# url_for_drilldown('ncloc')
# url_for_drilldown('ncloc', {:resource => 'org.apache.struts:struts-parent', :highlight => 'lines'})
# url_for_drilldown('ncloc', {:resource => 'org.apache.struts:struts-parent', :viewer_plugin_key => 'org.sonar.plugins.core.violationsviewer.GwtViolationsViewer'})
+ #
def url_for_drilldown(metric_or_measure, options={})
+ if options[:resource].nil? && !@project
+ return ''
+ end
+
if metric_or_measure.is_a? ProjectMeasure
metric_key = metric_or_measure.metric.key
elsif metric_or_measure.is_a? Metric
@@ -214,16 +221,9 @@ module ApplicationHelper
metric_key = metric_or_measure
end
- if options[:resource]
- url_for(:controller => 'drilldown', :action => 'measures', :id => options[:resource], :metric => metric_key,
- :highlight => options[:highlight], :viewer_plugin_key => options[:viewer_plugin_key], :model => options[:model], :characteristic => options[:characteristic])
- elsif @project
- url_for(:controller => 'drilldown', :action => 'measures', :id => @project.id, :metric => metric_key,
- :highlight => options[:highlight], :viewer_plugin_key => options[:viewer_plugin_key],
- :model => options[:model], :characteristic => options[:characteristic])
- else
- ''
- end
+ url_params={:controller => 'drilldown', :action => 'measures', :metric => metric_key, :id => options[:resource]||@project.id}
+
+ url_for(options.merge(url_params))
end
#
@@ -258,7 +258,9 @@ module ApplicationHelper
link_rel=''
show_link= !options[:url].blank?
- if m.metric.val_type==Metric::VALUE_TYPE_LEVEL
+ if options[:period]
+ html=m.format_numeric_value(m.variation(options[:period].to_i))
+ elsif m.metric.val_type==Metric::VALUE_TYPE_LEVEL
html=image_tag("levels/#{m.data.downcase}.png") unless m.data.blank?
else
html=m.formatted_value
@@ -456,7 +458,7 @@ module ApplicationHelper
# === Examples
# variation_value('ncloc')
# variation_value(measure('ncloc'))
- # variation_value('ncloc', :index => 3)
+ # variation_value('ncloc', :period => 3)
#
def variation_value(metric_or_measure, options={})
if metric_or_measure.is_a?(ProjectMeasure)
@@ -465,7 +467,7 @@ module ApplicationHelper
m = @snapshot.measure(metric_or_measure)
end
- index=options[:index]
+ index=options[:period]||options[:index]
if index.nil? && defined?(@dashboard_configuration) && @dashboard_configuration.selected_period?
index = @dashboard_configuration.period_index
end
@@ -480,12 +482,12 @@ module ApplicationHelper
#
# === Optional parameters
# * color: true|false. Default is true.
- # * index: integer between 1 and 5. By default the index is defined by the dashboard variation select-box
+ # * period: integer between 1 and 5. By default the index is defined by the dashboard variation select-box
# * style: light|normal. Default is normal (parenthesis + bold)
#
# === Examples
# format_variation('ncloc')
- # format_variation(measure('ncloc'), :index => 3, :color => true)
+ # format_variation(measure('ncloc'), :period => 3, :color => true)
#
def format_variation(metric_or_measure, options={})
if metric_or_measure.is_a?(ProjectMeasure)
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 ecfa0a7f6b0..5fdeb5562d8 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
@@ -45,7 +45,7 @@ class DrilldownColumn
@scope=scope
@snapshot = snapshot
- value_column = (options[:period_index] ? "variation_value_#{options[:period_index]}" : 'value')
+ value_column = (options[:period] ? "variation_value_#{options[:period]}" : 'value')
order="project_measures.#{value_column}"
if metric.direction<0
order += ' DESC'
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 4ecb2881b59..6698666f014 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
@@ -4,10 +4,12 @@
<div class="dashbox">
<% if @characteristic %>
<h3><%= @highlighted_metric.short_name -%> / <%= h(@characteristic.name(true)) -%></h3>
- <p class="big"><%= html_measure(@snapshot.characteristic_measure(@highlighted_metric, @characteristic), nil, true, nil, '', false) %></p>
+ <p class="big"><%= format_measure(@snapshot.characteristic_measure(@highlighted_metric, @characteristic)) %></p>
<% else %>
<h3><%= @highlighted_metric.short_name -%></h3>
- <p class="big"><%= html_measure(@snapshot.measure(@highlighted_metric.key), nil, true, nil, '', false) %></p>
+ <p class="big">
+ <%= format_measure(@snapshot.measure(@highlighted_metric.key), :period => @period) %>
+ </p>
<% end %>
</div>
&nbsp;<!-- keep &nbsp; for IE6 ! -->
@@ -15,7 +17,7 @@
<table id="drilldown" class="width100">
<% if @highlighted_metric!=@metric %>
<tr>
-<td colspan="<%= @drilldown.columns.size -%>">Drilldown on <b><span id="m_<%= u @metric.key -%>"><%= @snapshot.f_measure(@metric.key) -%><span> <%= @metric.short_name -%></b></h3></td>
+<td colspan="<%= @drilldown.columns.size -%>">Drilldown on <b><span id="m_<%= u @metric.key -%>"><%= @snapshot.f_measure(@metric.key) -%></span> <%= @metric.short_name -%></b></td>
</tr>
<tr>
<% end
@@ -49,7 +51,7 @@
<% end %>
</td>
<td class="right last" >
- <%= format_measure(measure, :skip_span_id => true) -%>
+ <%= format_measure(measure, :skip_span_id => true, :period => @period) -%>
<!--[if IE]> &nbsp; &nbsp; <![endif]-->
</td>
</tr>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb
index 1161f1fbe00..3b84bf7f90b 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb
@@ -20,7 +20,7 @@
</h4>
</div>
-<% if @period_index %>
+<% if @period %>
<div class="warning">This service is experimental. <a target="faq" href="http://docs.codehaus.org/display/SONAR/Frequently+Asked+Questions#FrequentlyAskedQuestions-Iamnotgettingexpectednewviolationsinthedifferentialviewsofdrilldown%3F">More</a>.</div>
<% end %>
@@ -32,9 +32,9 @@
<td align="left" width="1%" nowrap class="column first">
<%
- value_column = (@period_index ? "variation_value_#{@period_index}" : 'value')
+ value_column = (@period ? "variation_value_#{@period}" : 'value')
max = 0
- if @period_index
+ if @period
blocker_violations=@snapshot.measure('new_blocker_violations')
critical_violations=@snapshot.measure('new_critical_violations')
major_violations=@snapshot.measure('new_major_violations')
@@ -67,7 +67,7 @@
<div class="scrollable">
<table class="spacedicon" width="100%" id="col_rules">
<%
- if @period_index
+ if @period
rule_measures=@snapshot.rule_measures(Metric.by_key('new_violations'), @priority_id)
else
rule_measures=@snapshot.rule_measures(Metric.by_key('violations'), @priority_id)
@@ -101,16 +101,16 @@
%>
<tr class="<%= clazz -%>">
<td width="1%" nowrap>
- <a id="<%= "rule#{rule_index}" -%>" title="Click for more on <%= rule.plugin_name -%>: <%= rule.plugin_rule_key -%>" onclick="window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;" href="<%= url_for :controller => 'rules', :action => 'show', :id => rule.key, :layout => 'false' -%>"><img src="<%= ApplicationController.root_context -%>/images/priority/<%= rule_measure.rule_priority -%>.png"></img></a>
+ <a id="<%= "rule#{rule_index}" -%>" title="Click for more on <%= rule.plugin_name -%>: <%= rule.plugin_rule_key -%>" onclick="window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;" href="<%= url_for :controller => 'rules', :action => 'show', :id => rule.key, :layout => 'false' -%>"><img src="<%= ApplicationController.root_context -%>/images/priority/<%= rule_measure.rule_priority -%>.png" /></a>
</td>
<td>
<%= link_to(rule.name, {:overwrite_params => {:rule => rule.key, :sid => nil, :priority => Sonar::RulePriority.to_s(@priority_id)}}, :title => "#{rule.plugin_name}: #{rule.plugin_rule_key}") %>
</td>
<td class="right" nowrap="nowrap">
- <span><%= @period_index ? format_variation(rule_measure, :index => @period_index, :style => 'light') : rule_measure.formatted_value -%></span>
+ <span><%= @period ? format_variation(rule_measure, :period => @period, :style => 'light') : rule_measure.formatted_value -%></span>
</td>
<td class="left last">
- <%= barchart(:width => 70, :percent => (100 * value / max).to_i, :color => (@period_index ? '#cc0000' : '#777')) if max>0 %>
+ <%= barchart(:width => 70, :percent => (100 * value / max).to_i, :color => (@period ? '#cc0000' : '#777')) if max>0 %>
<!--[if IE]> &nbsp; &nbsp; <![endif]-->
</td>
</tr>
@@ -163,7 +163,7 @@
<% end %>
</td>
<td class="right last" nowrap>
- <%= @period_index ? format_variation(measure, :index => @period_index, :style => 'light') : measure.formatted_value -%>
+ <%= @period ? format_variation(measure, :period => @period, :style => 'light') : measure.formatted_value -%>
<!--[if IE]> &nbsp; &nbsp; <![endif]-->
</td>
</tr>