Class: RubyLsp::Requests::RuboCopRequest
- Inherits:
-
RuboCop::Runner
- Object
- RuboCop::Runner
- RubyLsp::Requests::RuboCopRequest
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/ruby_lsp/requests/rubocop_request.rb
Overview
:nodoc:
Direct Known Subclasses
Constant Summary collapse
- COMMON_RUBOCOP_FLAGS =
T.let([ "--stderr", # Print any output to stderr so that our stdout does not get polluted "--format", "RuboCop::Formatter::BaseFormatter", # Suppress any output by using the base formatter ].freeze, T::Array[String])
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(uri, document) ⇒ RuboCopRequest
constructor
A new instance of RuboCopRequest.
- #run ⇒ Object
Constructor Details
#initialize(uri, document) ⇒ RuboCopRequest
Returns a new instance of RuboCopRequest.
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ruby_lsp/requests/rubocop_request.rb', line 29 def initialize(uri, document) @file = T.let(CGI.unescape(URI.parse(uri).path), String) @document = document @text = T.let(document.source, String) @uri = uri = T.let({}, T::Hash[Symbol, T.untyped]) @diagnostics = T.let([], T::Array[Support::RuboCopDiagnostic]) super( ::RuboCop::Options.new.parse(rubocop_flags).first, ::RuboCop::ConfigStore.new ) end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
23 24 25 |
# File 'lib/ruby_lsp/requests/rubocop_request.rb', line 23 def file @file end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
26 27 28 |
# File 'lib/ruby_lsp/requests/rubocop_request.rb', line 26 def text @text end |
Instance Method Details
#run ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/ruby_lsp/requests/rubocop_request.rb', line 44 def run # We communicate with Rubocop via stdin [:stdin] = text # Invoke the actual run method with just this file in `paths` super([file]) end |