Class: RubyLsp::Requests::Support::RuboCopDiagnosticsRunner
- Inherits:
-
RuboCop::Runner
- Object
- RuboCop::Runner
- RubyLsp::Requests::Support::RuboCopDiagnosticsRunner
- Extended by:
- T::Sig
- Includes:
- Singleton
- Defined in:
- lib/ruby_lsp/requests/support/rubocop_diagnostics_runner.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize ⇒ RuboCopDiagnosticsRunner
constructor
A new instance of RuboCopDiagnosticsRunner.
- #run(uri, document) ⇒ Object
Constructor Details
#initialize ⇒ RuboCopDiagnosticsRunner
Returns a new instance of RuboCopDiagnosticsRunner.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ruby_lsp/requests/support/rubocop_diagnostics_runner.rb', line 22 def initialize @options = T.let({}, T::Hash[Symbol, T.untyped]) @uri = T.let(nil, T.nilable(String)) @diagnostics = T.let([], T::Array[Support::RuboCopDiagnostic]) 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 ]).first, ::RuboCop::ConfigStore.new ) end |
Instance Method Details
#run(uri, document) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ruby_lsp/requests/support/rubocop_diagnostics_runner.rb', line 39 def run(uri, document) @diagnostics.clear @uri = uri file = CGI.unescape(URI.parse(uri).path) # We communicate with Rubocop via stdin @options[:stdin] = document.source # Invoke RuboCop with just this file in `paths` super([file]) @diagnostics end |