Module: SimpleCov::CLI::Uncovered::Misses

Extended by:
Misses
Included in:
Misses
Defined in:
lib/simplecov/cli/uncovered/misses.rb

Instance Method Summary collapse

Instance Method Details

#annotate(stdout, files) ⇒ Object

GitHub workflow commands, one ::warning per contiguous missed range, so a plain workflow gets inline diff annotations with no upload step and no code-scanning permissions.



26
27
28
29
30
31
32
33
# File 'lib/simplecov/cli/uncovered/misses.rb', line 26

def annotate(stdout, files)
  files.each do |fname, _pct, _covered, _total, missed|
    path = fname.delete_prefix("#{File.expand_path(SimpleCov.root)}/")
    missed.slice_when { |previous, current| current > previous + 1 }.each do |run|
      stdout.puts("::warning file=#{path},line=#{run.first},endLine=#{run.last}::Not covered by tests")
    end
  end
end

#collect(items) ⇒ Object



17
18
19
20
21
# File 'lib/simplecov/cli/uncovered/misses.rb', line 17

def collect(items)
  missed = [] #: Array[Integer]
  Show::Annotator.each_missed(items) { |line| missed << line }
  missed.uniq.sort
end

#missed_for(payload, criterion) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/simplecov/cli/uncovered/misses.rb', line 9

def missed_for(payload, criterion)
  case criterion
  when :line then payload["lines"].instance_of?(Array) ? Show::Annotator.missed_lines(payload) : []
  when :branch then collect(payload["branches"])
  else collect(payload["methods"])
  end
end