class SimpleCov::SourceFile::MethodBuilder
‘# simplecov:disable` / `# :nocov:` chunks as skipped.
`ignore_methods :eval_generated` filter and marks methods inside
the raw method-coverage data. Applies the
Builds the `SourceFile::Method` objects for a source file from
def call
def call methods = @source_file.coverage_data.fetch("methods", {}).filter_map do |info, hit_count| info = RubyDataParser.call(info) next if eval_generated_to_ignore?(info) SourceFile::Method.new(@source_file, info, hit_count) end process_skipped(methods) end
def eval_generated_to_ignore?(info)
when the user has opted in via
from the real-source `def` set is eval-generated. Only consulted
line and name, so a method whose `(name, start_line)` is absent
rationale. Coverage reports an eval'd `def` at the eval caller's
See `BranchBuilder#eval_generated_condition_to_ignore?` for the
def eval_generated_to_ignore?(info) return false unless SimpleCov.ignored_method?(:eval_generated) positions = @source_file.real_source_positions # simplecov:disable branch — nil branch fires only when Prism is unavailable return false unless positions # simplecov:enable branch _class_name, name, start_line, * = info !positions[:methods].include?([name, start_line]) end
def initialize(source_file)
def initialize(source_file) @source_file = source_file end
def process_skipped(methods)
def process_skipped(methods) chunks = @source_file.skip_chunks_for(:method) return methods if chunks.empty? methods.each do |method| method.skipped! if chunks.any? { |chunk| method.overlaps_with?(chunk) } end methods end