Sha256: 1c657fb6aff8655051952fab0731088ecf16211bd6431fc9ff7b6eea57c3837a
Contents?: true
Size: 1.12 KB
Versions: 10
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true module DeepCover class Analyser::Node < Analyser include Analyser::Subset def self.human_name 'Nodes' end 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 def node_runs(node) @cache.fetch(node) do runs = super runs = nil if runs == 0 && should_be_ignored?(node) @cache[node] = runs end end def in_subset?(node, _parent) node.executable? end protected def convert(node, **) Analyser::CoveredCodeSource.new(node) end private def should_be_ignored?(node) @nocov_ranges.include?(node) || @allow_filters.any? { |f| node.public_send(f) } || is_ignored?(node.parent) end def is_ignored?(node) if node == nil false elsif node.executable? node_runs(node).nil? else is_ignored?(node.parent) end end end end
Version data entries
10 entries across 10 versions & 2 rubygems