Module: SimpleCov::Formatter::AIFormatter::MarkdownBuilder::SkipRegions
- Extended by:
- T::Sig
- Defined in:
- lib/simplecov-ai/markdown_builder/skip_regions.rb
Overview
Derives coverage-bypass regions from SimpleCov's own verdicts instead of re-parsing
directives: the lines SimpleCov marked skipped (:nocov: pairs, simplecov:disable
blocks and trailing comments, a custom nocov token) form contiguous regions, and the
branches it skipped outside those regions (a simplecov:disable branch scope) add
their own. Each region is paired with the directive comment that caused it — found on
the region's first line or the nearest line above — so the report quotes the exact
text a maintainer wrote. Whatever SimpleCov did not skip (a directive inside a heredoc,
a simplecov:disable on a SimpleCov that predates it) is not a bypass here either, and
neither is a skipped region made only of comments and blank lines, which takes nothing
out of any figure. (SimpleCov honours a directive wherever it appears in a comment, so
the directives are spelled without their leading # throughout this file.)
Constant Summary collapse
- FALLBACK_REASON =
Reason reported when the directive that produced a region cannot be located.
T.let('coverage skipped by SimpleCov', String)
- NOCOV_TOKEN_READERS =
Readers of the configured nocov token, newest SimpleCov first: the public
nocov_tokenreader warns about its own deprecation on SimpleCov >= 1.0. T.let(%i[current_nocov_token nocov_token].freeze, T::Array[Symbol])
Class Method Summary collapse
Class Method Details
.any?(file) ⇒ Boolean
33 34 35 |
# File 'lib/simplecov-ai/markdown_builder/skip_regions.rb', line 33 def self.any?(file) file.skipped_lines.any? || file.branches.any?(&:skipped?) end |
.of(file, source_lines) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/simplecov-ai/markdown_builder/skip_regions.rb', line 45 def self.of(file, source_lines) line_ranges = skipped_line_ranges(file) branch_ranges = skipped_branch_ranges(file).reject do |branch_range| line_ranges.any? { |line_range| LineSpan.encloses?(line_range, branch_range) } end pattern = directive_pattern (line_ranges + branch_ranges).sort_by(&:begin) .map { |range| [range, reason_for(range, source_lines, pattern)] } end |