Class: RubyLsp::Requests::Support::RuboCopFormattingRunner
- Inherits:
-
RuboCop::Runner
- Object
- RuboCop::Runner
- RubyLsp::Requests::Support::RuboCopFormattingRunner
- Extended by:
- T::Sig
- Includes:
- Singleton
- Defined in:
- lib/ruby_lsp/requests/support/rubocop_formatting_runner.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize ⇒ RuboCopFormattingRunner
constructor
A new instance of RuboCopFormattingRunner.
- #run(uri, document) ⇒ Object
Constructor Details
#initialize ⇒ RuboCopFormattingRunner
Returns a new instance of RuboCopFormattingRunner.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ruby_lsp/requests/support/rubocop_formatting_runner.rb', line 22 def initialize = T.let({}, T::Hash[Symbol, T.untyped]) super( ::RuboCop::Options.new.parse([ "--stderr", # Print any output to stderr so that our stdout does not get polluted "--force-exclusion", "--format", "RuboCop::Formatter::BaseFormatter", # Suppress any output by using the base formatter "-a", # --auto-correct ]).first, ::RuboCop::ConfigStore.new ) end |
Instance Method Details
#run(uri, document) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/ruby_lsp/requests/support/rubocop_formatting_runner.rb', line 38 def run(uri, document) file = CGI.unescape(URI.parse(uri).path) # We communicate with Rubocop via stdin [:stdin] = document.source # Invoke RuboCop with just this file in `paths` super([file]) [:stdin] end |