Class: DeepCover::Analyser::PerLine

Inherits:
DeepCover::Analyser show all
Defined in:
lib/deep_cover/analyser/per_line.rb

Instance Attribute Summary

Attributes included from Base

#options, #source

Instance Method Summary collapse

Methods included from OptionallyCovered

#optionally_covered

Methods included from IgnoreUncovered

#initialize, #node_runs

Methods included from Base

#covered_code, #each_node, #initialize, #node_children, #node_runs, #node_runs_map

Instance Method Details

#resultsObject

Returns an array of runs, one per line.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/deep_cover/analyser/per_line.rb', line 6

def results
  disallow_partial = !options.fetch(:allow_partial, true)
  line_hits = Array.new(covered_code.nb_lines + covered_code.lineno - 1)
  each_node do |node|
    next unless (runs = node_runs(node))
    node.executed_locs.each do |loc|
      lineno = loc.line - 1
      if disallow_partial
        line_hits[lineno] = 0 if runs == 0
        next if line_hits[lineno] == 0
      end
      line_hits[lineno] = [line_hits[lineno] || 0, runs].max
    end
  end

  line_hits
end