<% 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 %>
%>
<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
.setDescription("Coverage of new/changed code")
.setDirection(Metric.DIRECTION_BETTER)
.setQualitative(true)
+ .setHidden(true)
.setDomain(DOMAIN_TESTS)
.setWorstValue(0.0)
.setBestValue(100.0)
.setDescription("New uncovered lines")
.setDirection(Metric.DIRECTION_WORST)
.setDomain(DOMAIN_TESTS)
+ .setHidden(true)
.setFormula(new SumChildValuesFormula(false))
.create();
.setQualitative(true)
.setWorstValue(0.0)
.setBestValue(100.0)
+ .setHidden(true)
.setDomain(DOMAIN_TESTS)
.create();
.setDescription("New uncovered conditions")
.setDirection(Metric.DIRECTION_WORST)
.setDomain(DOMAIN_TESTS)
+ .setHidden(true)
.setFormula(new SumChildValuesFormula(false))
.create();
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)
@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)
# 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
# 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
# * <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
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
#
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
# === 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)
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
#
# === 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)
@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'
<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>
<!-- keep for IE6 ! -->
<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
<% end %>
</td>
<td class="right last" >
- <%= format_measure(measure, :skip_span_id => true) -%>
+ <%= format_measure(measure, :skip_span_id => true, :period => @period) -%>
<!--[if IE]> <![endif]-->
</td>
</tr>
</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 %>
<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')
<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)
%>
<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]> <![endif]-->
</td>
</tr>
<% 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]> <![endif]-->
</td>
</tr>