Module: SimpleCov::UselessResultsRemover

Defined in:
lib/simplecov/useless_results_remover.rb

Overview

Drops coverage entries whose paths live outside SimpleCov.root, so vendored gems, stdlib files, and anything else touched during the run never make it into the formatted result.

Class Method Summary collapse

Class Method Details

.call(coverage_result) ⇒ Object



8
9
10
# File 'lib/simplecov/useless_results_remover.rb', line 8

def self.call(coverage_result)
  coverage_result.select { |path, _coverage| path.match?(root_regex) }
end

.root_regexObject

The /i flag covers case-insensitive matches on Windows and macOS-HFS+, where the on-disk path's case can differ from SimpleCov.root's.



14
15
16
17
18
19
20
# File 'lib/simplecov/useless_results_remover.rb', line 14

def self.root_regex
  root = SimpleCov.root
  return @root_regex if root.eql?(@root_regex_root)

  @root_regex_root = root
  @root_regex = /\A#{Regexp.escape(root.chomp(File::SEPARATOR) + File::SEPARATOR)}/i
end

.root_regxObject



22
23
24
25
26
# File 'lib/simplecov/useless_results_remover.rb', line 22

def self.root_regx
  Deprecation.warn("`SimpleCov::UselessResultsRemover.root_regx` is deprecated. " \
                   "Replace with `root_regex`.")
  root_regex
end