Sha256: 7fa714805edc3642c014fd5ec23733446068deceabd374c6ccf12fcc07a1621d

Contents?: true

Size: 806 Bytes

Versions: 10

Compression:

Stored size: 806 Bytes

Contents

# frozen_string_literal: true

require 'memo_wise'

module SimpleCov::Formatter::Terminal::BranchCoverage
  prepend MemoWise

  private

  memo_wise \
  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

  memo_wise \
  def line_numbers_with_missing_branches(sourcefile)
    uncovered_branches(sourcefile).
      map(&:start_line).
      uniq.
      sort
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
simple_cov-formatter-terminal-1.7.0 lib/simple_cov/formatter/terminal/branch_coverage.rb
simple_cov-formatter-terminal-1.6.0 lib/simple_cov/formatter/terminal/branch_coverage.rb
simple_cov-formatter-terminal-1.5.0 lib/simple_cov/formatter/terminal/branch_coverage.rb
simple_cov-formatter-terminal-1.4.0 lib/simple_cov/formatter/terminal/branch_coverage.rb
simple_cov-formatter-terminal-1.3.0 lib/simple_cov/formatter/terminal/branch_coverage.rb
simple_cov-formatter-terminal-1.2.0 lib/simple_cov/formatter/terminal/branch_coverage.rb
simple_cov-formatter-terminal-1.1.0 lib/simple_cov/formatter/terminal/branch_coverage.rb
simple_cov-formatter-terminal-1.0.0 lib/simple_cov/formatter/terminal/branch_coverage.rb
simple_cov-formatter-terminal-0.3.1 lib/simple_cov/formatter/terminal/branch_coverage.rb
simple_cov-formatter-terminal-0.3.0 lib/simple_cov/formatter/terminal/branch_coverage.rb