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

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Includes:
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.



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

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



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

def run(uri, document)
  filename = CGI.unescape(URI.parse(uri).path)

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

  @runner.formatted_source
end