Sha256: 233076caab4b57b1ba324dc5dc09d10817a80ad33ba2b2492e8eb67f3e96e035

Contents?: true

Size: 642 Bytes

Versions: 4

Compression:

Stored size: 642 Bytes

Contents

# frozen_string_literal: true

require 'memoist'

module SimpleCov::Formatter::Terminal::BranchCoverage
  extend Memoist

  private

  memoize \
  def uncovered_branches(sourcefile)
    sourcefile.branches.
      reject(&:covered?).
      reject do |branch|
        line = sourcefile.lines[branch.start_line - 1]
        source_code = line.src
        line.coverage == 0 || source_code.match?(/# :nocov-(#{branch.type}):/)
      end
  end

  def missed_branch_info(line, sourcefile)
    uncovered_branches(sourcefile).
      select { _1.start_line == line.line_number }.
      map { _1.type.to_s }.
      join(', ').
      presence
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
simple_cov-formatter-terminal-0.2.2 lib/simple_cov/formatter/terminal/branch_coverage.rb
simple_cov-formatter-terminal-0.2.1 lib/simple_cov/formatter/terminal/branch_coverage.rb
simple_cov-formatter-terminal-0.2.0 lib/simple_cov/formatter/terminal/branch_coverage.rb
simple_cov-formatter-terminal-0.1.0 lib/simple_cov/formatter/terminal/branch_coverage.rb