Class: Rucoa::Rubocop::Autocorrector

Inherits:
RuboCop::Runner
  • Object
show all
Defined in:
lib/rucoa/rubocop/autocorrector.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source:) ⇒ Autocorrector

Returns a new instance of Autocorrector.

Parameters:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rucoa/rubocop/autocorrector.rb', line 17

def initialize(source:)
  @source = source
  super(
    ::RuboCop::Options.new.parse(
      %w[
        --stderr
        --force-exclusion
        --format RuboCop::Formatter::BaseFormatter
        -A
      ]
    ).first,
    ::RuboCop::ConfigStore.new
  )
end

Class Method Details

.call(source:) ⇒ String

Parameters:

Returns:

  • (String)


11
12
13
# File 'lib/rucoa/rubocop/autocorrector.rb', line 11

def call(source:)
  new(source: source).call
end

Instance Method Details

#callString

Returns:

  • (String)


33
34
35
36
37
# File 'lib/rucoa/rubocop/autocorrector.rb', line 33

def call
  @options[:stdin] = @source.content
  run([path])
  @options[:stdin]
end