Class: DeepCover::Analyser::Node

Inherits:
DeepCover::Analyser show all
Includes:
Subset
Defined in:
lib/deep_cover/analyser/node.rb

Instance Attribute Summary

Attributes included from Base

#options, #source

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Subset

#node_children

Methods included from Base

#covered_code, #each_node, #node_children, #node_covered?, #node_runs_map, #node_stat_contributions, #node_stat_type, #results, #stats

Methods included from Tools::Covered

#covered?

Constructor Details

#initialize(source, ignore_uncovered: [], **options) ⇒ Node

Returns a new instance of Node.



11
12
13
14
15
16
# File 'lib/deep_cover/analyser/node.rb', line 11

def initialize(source, ignore_uncovered: [], **options)
  @cache = {}.compare_by_identity
  super
  @allow_filters = Array(ignore_uncovered).map { |kind| Node.filter_to_method_name(kind) }
  @nocov_ranges = FlagCommentAssociator.new(covered_code)
end

Class Method Details

.human_nameObject



7
8
9
# File 'lib/deep_cover/analyser/node.rb', line 7

def self.human_name
  'Nodes'
end

Instance Method Details

#in_subset?(node, _parent) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/deep_cover/analyser/node.rb', line 26

def in_subset?(node, _parent)
  node.executable?
end

#node_runs(node) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/deep_cover/analyser/node.rb', line 18

def node_runs(node)
  @cache.fetch(node) do
    runs = super
    runs = nil if runs == 0 && should_be_ignored?(node)
    @cache[node] = runs
  end
end