class RubyLsp::Requests::Support::RuboCopFormatter
Public Class Methods
new()
# File lib/ruby_lsp/requests/support/rubocop_formatter.rb, line 14definitialize@diagnostic_runner = T.let(RuboCopRunner.new, RuboCopRunner)
# -a is for "--auto-correct" (or "--autocorrect" on newer versions of RuboCop)@format_runner = T.let(RuboCopRunner.new("-a"), RuboCopRunner)
end
Public Instance Methods
run_diagnostic(uri, document)
# File lib/ruby_lsp/requests/support/rubocop_formatter.rb, line 35defrun_diagnostic(uri, document)
filename = T.must(uri.to_standardized_path||uri.opaque)
# Invoke RuboCop with just this file in `paths`@diagnostic_runner.run(filename, document.source)
@diagnostic_runner.offenses.mapdo|offense|Support::RuboCopDiagnostic.new(document, offense, uri).to_lsp_diagnosticendend
run_formatting(uri, document)
# File lib/ruby_lsp/requests/support/rubocop_formatter.rb, line 21defrun_formatting(uri, document)
filename = T.must(uri.to_standardized_path||uri.opaque)
# Invoke RuboCop with just this file in `paths`@format_runner.run(filename, document.source)
@format_runner.formatted_sourceend