class RubyLsp::Requests::Support::RuboCopFormatter

def initialize

: -> void
def initialize
  @diagnostic_runner = RuboCopRunner.new #: RuboCopRunner
  # -a is for "--auto-correct" (or "--autocorrect" on newer versions of RuboCop)
  @format_runner = RuboCopRunner.new("-a") #: RuboCopRunner
end

def run_diagnostic(uri, document)

: (URI::Generic uri, RubyDocument document) -> Array[Interface::Diagnostic]?
@override
def run_diagnostic(uri, document)
  filename = uri.to_standardized_path || uri.opaque #: as !nil
  # Invoke RuboCop with just this file in `paths`
  @diagnostic_runner.run(filename, document.source)
  @diagnostic_runner.offenses.map do |offense|
    Support::RuboCopDiagnostic.new(
      document,
      offense,
      uri,
    ).to_lsp_diagnostic(@diagnostic_runner.config_for_working_directory)
  end
end

def run_formatting(uri, document)

: (URI::Generic uri, RubyDocument document) -> String?
@override
def run_formatting(uri, document)
  filename = uri.to_standardized_path || uri.opaque #: as !nil
  # Invoke RuboCop with just this file in `paths`
  @format_runner.run(filename, document.source)
  @format_runner.formatted_source
end

def run_range_formatting(uri, source, base_indentation)

: (URI::Generic uri, String source, Integer base_indentation) -> String?
@override
RuboCop does not support range formatting
def run_range_formatting(uri, source, base_indentation)
  nil
end