Class: Templatecop::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/templatecop/runner.rb

Overview

Run investigation and auto-correction.

Instance Method Summary collapse

Constructor Details

#initialize(autocorrect:, file_paths:, formatter:, rubocop_config:, ruby_extractor:, debug: false) ⇒ Runner

Returns a new instance of Runner.

Parameters:

  • autocorrect (Boolean)
  • debug (Boolean) (defaults to: false)
  • file_paths (Array<String>)
  • formatter (Object)
  • rubocop_config (RuboCop::Config)
  • ruby_extractor (#call)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/templatecop/runner.rb', line 15

def initialize(
  autocorrect:,
  file_paths:,
  formatter:,
  rubocop_config:,
  ruby_extractor:,
  debug: false
)
  @autocorrect = autocorrect
  @debug = debug
  @file_paths = file_paths
  @formatter = formatter
  @rubocop_config = rubocop_config
  @ruby_extractor = ruby_extractor
end

Instance Method Details

#callArray<RuboCop::Cop::Offense>

Returns:

  • (Array<RuboCop::Cop::Offense>)


32
33
34
35
36
37
38
39
# File 'lib/templatecop/runner.rb', line 32

def call
  on_started
  result = run_in_parallel
  on_finished(result)
  result.flat_map do |(_, offenses)|
    offenses
  end
end