Class: RubyLsp::Reek::Runner

Inherits:
Object
  • Object
show all
Includes:
RubyLsp::Requests::Support::Formatter
Defined in:
lib/ruby_lsp/reek/runner.rb

Overview

Implements Ruby LSP Formatter interface: specifically run_diagnostic

Instance Method Summary collapse

Constructor Details

#initializeRunner

Returns a new instance of Runner.



11
12
13
# File 'lib/ruby_lsp/reek/runner.rb', line 11

def initialize
  @config = ::Reek::Configuration::AppConfiguration.from_default_path
end

Instance Method Details

#run_diagnostic(uri, document) ⇒ Object

Parameters:

  • uri (String)

    The URI of the document to run diagnostics on.

  • document (RubyLsp::Interface::TextDocumentItem)

    The document to run diagnostics on.



26
27
28
29
30
31
32
# File 'lib/ruby_lsp/reek/runner.rb', line 26

def run_diagnostic(uri, document)
  path = Pathname.new(uri.path)
  return [] if path_excluded?(path)

  examiner = build_examiner(path, document)
  examiner.smells.map { |smell| warning_to_diagnostic(smell) }
end

#run_formatting(_uri, document) ⇒ String

We are not implementing this method, but it is required by the interface

Parameters:

  • uri (String)

    The URI of the document to format.

  • document (RubyLsp::Interface::TextDocumentItem)

    The document to format.

Returns:

  • (String)

    The formatted document.



20
21
22
# File 'lib/ruby_lsp/reek/runner.rb', line 20

def run_formatting(_uri, document)
  document.source
end