Class: Testgenai::Scanner::SimplecovScanner

Inherits:
Base
  • Object
show all
Defined in:
lib/testgenai/scanner/simplecov_scanner.rb

Constant Summary collapse

RESULTSET_PATH =
"coverage/.resultset.json"

Instance Attribute Summary

Attributes inherited from Base

#files_scanned

Instance Method Summary collapse

Constructor Details

#initialize(root: Dir.pwd) ⇒ SimplecovScanner

Returns a new instance of SimplecovScanner.



8
9
10
# File 'lib/testgenai/scanner/simplecov_scanner.rb', line 8

def initialize(root: Dir.pwd)
  @root = root
end

Instance Method Details

#scanObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/testgenai/scanner/simplecov_scanner.rb', line 12

def scan
  resultset_path = File.join(@root, RESULTSET_PATH)
  unless File.exist?(resultset_path)
    warn "Warning: #{RESULTSET_PATH} not found"
    return []
  end
  coverage = merged_coverage
  source_coverage = coverage.reject { |file, _| test_file?(file) || !File.exist?(file) }
  @files_scanned = source_coverage.size
  source_coverage.flat_map { |file, lines| extract_untested_methods(file, lines) }
end