Class: SixthSense::AnalysisRunner
- Inherits:
-
Object
- Object
- SixthSense::AnalysisRunner
- Defined in:
- lib/sixth_sense/analysis_runner.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #analyze(paths:, level:) ⇒ Object
- #discover(paths) ⇒ Object
-
#initialize(config: Config.load) ⇒ AnalysisRunner
constructor
A new instance of AnalysisRunner.
Constructor Details
#initialize(config: Config.load) ⇒ AnalysisRunner
Returns a new instance of AnalysisRunner.
17 18 19 |
# File 'lib/sixth_sense/analysis_runner.rb', line 17 def initialize(config: Config.load) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
15 16 17 |
# File 'lib/sixth_sense/analysis_runner.rb', line 15 def config @config end |
Instance Method Details
#analyze(paths:, level:) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/sixth_sense/analysis_runner.rb', line 21 def analyze(paths:, level:) warnings = [] test_files = discover(paths).filter_map do |path| adapter_class = FrameworkAdapter.for_path(path) unless adapter_class warnings << "No framework adapter accepted #{path}." next end apply_configured_mapping(adapter_class.new.parse(path)) rescue Error => error warnings << "#{path}: #{error.class}: #{error.}" nil end coverage_maps = collect_coverage(test_files, level, warnings) checked_maps = collect_checked_coverage(test_files, coverage_maps, level, warnings) kill_matrices = collect_mutation(test_files, level, warnings) context = AnalysisContext.new( config: config.data, coverage_maps: coverage_maps, checked_coverage_maps: checked_maps, kill_matrices: kill_matrices, warnings: warnings ) aggregator = Scoring::Aggregator.new(level: level) test_files.map { |test_file| aggregator.analyze(test_file, context) } end |
#discover(paths) ⇒ Object
50 51 52 53 |
# File 'lib/sixth_sense/analysis_runner.rb', line 50 def discover(paths) selected = paths.empty? ? ["spec"] : paths selected.flat_map { |path| (path) }.uniq.sort end |