Class: RubyLsp::Requests::Support::RuboCopFormattingRunner

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Includes:
FormatterRunner, Singleton
Defined in:
lib/ruby_lsp/requests/support/rubocop_formatting_runner.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initializeRuboCopFormattingRunner

Returns a new instance of RuboCopFormattingRunner.



18
19
20
21
# File 'lib/ruby_lsp/requests/support/rubocop_formatting_runner.rb', line 18

def initialize
  # -a is for "--auto-correct" (or "--autocorrect" on newer versions of RuboCop)
  @runner = T.let(RuboCopRunner.new("-a"), RuboCopRunner)
end

Instance Method Details

#run(uri, document) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/ruby_lsp/requests/support/rubocop_formatting_runner.rb', line 24

def run(uri, document)
  filename = T.must(uri.to_standardized_path || uri.opaque)

  # Invoke RuboCop with just this file in `paths`
  @runner.run(filename, document.source)

  @runner.formatted_source
end