class SolargraphTestCoverage::Branch

Adapted from SimpleCov - Small class that turns branch coverage data into something easier to work with

Attributes

coverage[R]
end_line[R]
start_line[R]
type[R]

Public Class Methods

build_from(results) click to toggle source
# File lib/solargraph_test_coverage/branch.rb, line 6
def self.build_from(results)
  results.fetch(:branches, {}).flat_map do |condition, branches|
    _condition_type, _condition_id, condition_start_line, * = condition

    branches.map do |branch_data, hit_count|
      type, _id, start_line, _start_col, end_line, _end_col = branch_data

      new(start_line: start_line, end_line: end_line, coverage: hit_count,
          inline: start_line == condition_start_line, type: type)
    end
  end
end
new(start_line:, end_line:, coverage:, inline:, type:) click to toggle source
# File lib/solargraph_test_coverage/branch.rb, line 21
def initialize(start_line:, end_line:, coverage:, inline:, type:)
  @start_line = start_line
  @end_line   = end_line
  @coverage   = coverage
  @inline     = inline
  @type       = type
end

Public Instance Methods

covered?() click to toggle source
# File lib/solargraph_test_coverage/branch.rb, line 33
def covered?
  coverage.positive?
end
inline?() click to toggle source
# File lib/solargraph_test_coverage/branch.rb, line 29
def inline?
  @inline
end
report() click to toggle source
# File lib/solargraph_test_coverage/branch.rb, line 41
def report
  { type: type, line: report_line }
end
report_line() click to toggle source
# File lib/solargraph_test_coverage/branch.rb, line 37
def report_line
  inline? ? start_line : start_line - 1
end