Class: RuboBot::RuboCop::AutoCorrect

Inherits:
Object
  • Object
show all
Defined in:
lib/rubobot/rubocop/auto_correct.rb

Overview

Run rubocop to auto-correct a cop

Defined Under Namespace

Classes: NotAutoCorrectableError

Instance Method Summary collapse

Constructor Details

#initialize(cop, paths) ⇒ AutoCorrect

Returns a new instance of AutoCorrect.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rubobot/rubocop/auto_correct.rb', line 11

def initialize(cop, paths)
  @cop = cop
  @paths = paths

  formatter = 'RuboBot::RuboCop::Formatter::ClangStyleFormatter'
  options = { safe_auto_correct: true,
              auto_correct: true,
              format: formatter,
              formatters: [[formatter]],
              only: [cop.name] }

  @runner = ::RuboCop::Runner.new(options, ::RuboCop::ConfigStore.new)
end

Instance Method Details

#commit_messageObject



33
34
35
36
# File 'lib/rubobot/rubocop/auto_correct.rb', line 33

def commit_message
  raise NotAutoCorrectableError unless autocorrect?
  Git::CommitMessage.new(cop.name, command, stdout_str)
end

#files_changed?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/rubobot/rubocop/auto_correct.rb', line 29

def files_changed?
  status
end

#runObject



25
26
27
# File 'lib/rubobot/rubocop/auto_correct.rb', line 25

def run
  files_changed?
end