class DiagnosticCollector

Constants

RUBOCOP_FLAGS

Attributes

diagnostics[R]
file[R]
formatted_text[R]
text[R]
uri[R]

Public Class Methods

new(uri:, text:) click to toggle source
Calls superclass method
# 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

Public Instance Methods

file_finished(_file, offenses) click to toggle source
# File lib/rubocop/lsp/diagnostic_collector.rb, line 41
def file_finished(_file, offenses)
  @diagnostics = Model::DiagnosticCollection.new(uri, offenses)
end
run() click to toggle source
Calls superclass method
# 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