Class: DiagnosticCollector
- Inherits:
-
RuboCop::Runner
- Object
- RuboCop::Runner
- DiagnosticCollector
- Defined in:
- lib/rubocop/lsp/diagnostic_collector.rb
Constant Summary collapse
- RUBOCOP_FLAGS =
[ "--stderr", # Print any output to stderr so that our stdout does not get polluted "--format", "quiet", # Supress any progress output by setting the formatter to `quiet` "--auto-correct", # Apply the autocorrects on the supplied buffer ]
Instance Attribute Summary collapse
-
#diagnostics ⇒ Object
readonly
Returns the value of attribute diagnostics.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#formatted_text ⇒ Object
readonly
Returns the value of attribute formatted_text.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #file_finished(_file, offenses) ⇒ Object
-
#initialize(uri:, text:) ⇒ DiagnosticCollector
constructor
A new instance of DiagnosticCollector.
- #run ⇒ Object
Constructor Details
#initialize(uri:, text:) ⇒ DiagnosticCollector
Returns a new instance of DiagnosticCollector.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rubocop/lsp/diagnostic_collector.rb', line 15 def initialize(uri:, text:) @uri = uri @file = CGI.unescape(URI.parse(uri).path) @text = text @formatted_text = nil super( ::RuboCop::Options.new.parse(RUBOCOP_FLAGS).first, ::RuboCop::ConfigStore.new ) end |
Instance Attribute Details
#diagnostics ⇒ Object (readonly)
Returns the value of attribute diagnostics.
13 14 15 |
# File 'lib/rubocop/lsp/diagnostic_collector.rb', line 13 def diagnostics @diagnostics end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
13 14 15 |
# File 'lib/rubocop/lsp/diagnostic_collector.rb', line 13 def file @file end |
#formatted_text ⇒ Object (readonly)
Returns the value of attribute formatted_text.
13 14 15 |
# File 'lib/rubocop/lsp/diagnostic_collector.rb', line 13 def formatted_text @formatted_text end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
13 14 15 |
# File 'lib/rubocop/lsp/diagnostic_collector.rb', line 13 def text @text end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
13 14 15 |
# File 'lib/rubocop/lsp/diagnostic_collector.rb', line 13 def uri @uri end |
Instance Method Details
#file_finished(_file, offenses) ⇒ Object
41 42 43 |
# File 'lib/rubocop/lsp/diagnostic_collector.rb', line 41 def file_finished(_file, offenses) @diagnostics = Model::DiagnosticCollection.new(uri, offenses) end |
#run ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rubocop/lsp/diagnostic_collector.rb', line 27 def run # Send text via "stdin". # RuboCop reads all of stdin into the "stdin" option, when `--stdin` # flag is supplied @options[:stdin] = text # Invoke the actual run method with just this file in `paths` super([file]) # RuboCop applies autocorrections to the "stdin" option, # so read that into the formatted text attribute @formatted_text = @options[:stdin] end |