module SimpleCov::SimulateCoverage

def call(absolute_path)

Returns:
  • (Hash) -
def call(absolute_path)
  source_lines = read_lines(absolute_path)
  lines = coverage_stub(absolute_path, source_lines) ||
          LinesClassifier.new.classify(source_lines)
  empty = {"branches" => {}, "methods" => {}} #: Hash[String, Hash[untyped, untyped]]
  synthesized = StaticCoverageExtractor.call(source_lines.join) || empty
  {
    "lines" => lines,
    "branches" => synthesized["branches"],
    "methods" => synthesized["methods"]
  }
end

def coverage_stub(path, source_lines)

(JRuby and TruffleRuby).
or parse the file, or when the runtime doesn't expose `line_stub`
falls back to `LinesClassifier` alone — when `Coverage` can't read
`# simplecov:disable line` ranges). Returns nil — and the caller
with `LinesClassifier` (which knows about `# :nocov:` toggles and
Combine `Coverage.line_stub` (which gets multi-line statements right)
def coverage_stub(path, source_lines)
  return nil unless Coverage.respond_to?(:line_stub)
  stub = Coverage.line_stub(path)
  classifier_output = LinesClassifier.new.classify(source_lines)
  stub.each_index { |idx| stub[idx] = nil if classifier_output[idx].nil? }
  stub
rescue Errno::ENOENT, SyntaxError
  nil
end

def read_lines(path)

def read_lines(path)
  File.readlines(path)
rescue Errno::ENOENT
  []
end