end
end
+ if @snapshot.measure('conditions_by_line').nil?
+ deprecated_branches_by_line=load_distribution('branch_coverage_hits_data')
+ deprecated_branches_by_line.each_pair do |line_id,label|
+ line=@lines[line_id-1]
+ if line
+ line.deprecated_conditions_label=label
+ end
+ end
+ end
+
filter_lines_by_date()
render :action => 'index'
end
end
end
- @violations=RuleFailure.find(:all, :include => 'rule', :conditions => [conditions] + values, :order => 'failure_level DESC')
- @violations.each do |violation|
+ RuleFailure.find(:all, :include => 'rule', :conditions => [conditions] + values, :order => 'failure_level DESC').each do |violation|
# sorted by severity => from blocker to info
if violation.line && violation.line>0
@lines[violation.line-1].add_violation(violation)
end
class Line
- attr_accessor :source, :revision, :author, :datetime, :violations, :hits, :conditions, :covered_conditions, :hidden
+ attr_accessor :source, :revision, :author, :datetime, :violations, :hits, :conditions, :covered_conditions, :hidden, :deprecated_conditions_label
def initialize(source)
@source=source
def date
@datetime ? @datetime.to_date : nil
end
+
+ def deprecated_conditions_label=(label)
+ if label
+ @deprecated_conditions_label=label
+ if label=='0%'
+ @conditions=2
+ @covered_conditions=0
+ elsif label=='100%'
+ @conditions=2
+ @covered_conditions=2
+ else
+ @conditions=2
+ @covered_conditions=1
+ end
+ end
+ end
end
rule_counts={}
rules=[]
-
- @violations.each do |violation|
- count=(rule_counts[violation.rule_id]||0) +1
- rule_counts[violation.rule_id]=count
- rules<<violation.rule
+ rule_measures=ProjectMeasure.find(:all, :include => 'rule', :conditions => ['metric_id=? AND snapshot_id=? AND rule_id IS NOT NULL AND characteristic_id IS NULL', Metric.by_key('violations').id, @snapshot.id])
+ rule_measures.each do |rule_measure|
+ rule_counts[rule_measure.rule_id]=rule_measure.value.to_i
+ rules<<rule_measure.rule
end
-
rule_options=[]
rules.uniq.sort_by{|rule| rule.name}.each do |rule|
rule_options<<["#{h rule.name} (#{rule_counts[rule.id]})", rule.key]
<% if @display_coverage %>
<td class="ind <%= hits_status -%>"><%= line.hits -%></td>
- <td class="ind <%= conditions_status -%>"><% if line.conditions && line.conditions>0 %><%= line.covered_conditions -%>/<%= line.conditions -%><% end %></td>
+ <td class="ind <%= conditions_status -%>">
+ <% if line.deprecated_conditions_label -%>
+ <%= line.deprecated_conditions_label -%>
+ <% elsif line.conditions && line.conditions>0 -%>
+ <%= line.covered_conditions -%>/<%= line.conditions -%>
+ <% end %>
+ </td>
<% end %>
<td class="line <%= status -%>"><%= line.source -%></td>
</tr>