class SimpleCov::SourceFile::LineBuilder
‘# :nocov:` block ranges via `skipped!`.
never-counted lines). Applies `# simplecov:disable` /
1-based line number, and the Coverage hit count (or nil for
raw line-coverage array. Each line carries its source text, its
Builds the `SourceFile::Line` objects for a source file from the
def build_lines
every position. The source rows are still useful — e.g. for the
doesn't emit "lines" data, so look up `nil` (never-counted) for
When `:line` coverage is disabled, the Ruby Coverage module
def build_lines line_coverage = @source_file.coverage_data["lines"] || [] @source_file.src.map.with_index(1) do |src, i| SourceFile::Line.new(src, i, line_coverage[i - 1]) end end
def call
def call lines = build_lines mark_skipped(lines, @source_file.skip_chunks_for(:line)) lines end
def initialize(source_file)
def initialize(source_file) @source_file = source_file end
def mark_skipped(lines, chunks)
so each range needs to be shifted down by one to slice into the
numbers in the chunks are 1-based (more understandable elsewhere),
The array the lines are kept in is 0-based whereas the line
def mark_skipped(lines, chunks) chunks.each { |chunk| lines[(chunk.begin - 1)..(chunk.end - 1)].each(&:skipped!) } end