Class: RuboCop::Gradual::Commands::Autocorrect

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/gradual/commands/autocorrect.rb

Overview

Autocorrect command runs RuboCop autocorrect before running the base command.

Instance Method Summary collapse

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rubocop/gradual/commands/autocorrect.rb', line 11

def call
  runner = RuboCop::CLI::Command::ExecuteRunner.new(
    RuboCop::CLI::Environment.new(
      Configuration.rubocop_options.merge(formatters: [[Formatters::Autocorrect, nil]]),
      Configuration.rubocop_config_store,
      lint_paths
    )
  )
  runner.run
  Base.new.call
end

#lint_pathsObject



23
24
25
26
27
# File 'lib/rubocop/gradual/commands/autocorrect.rb', line 23

def lint_paths
  return Configuration.target_file_paths if Configuration.lint_paths.any?

  changed_or_untracked_files.map(&:path)
end