Class: RubyLsp::Reek::Runner
- Inherits:
-
Object
- Object
- RubyLsp::Reek::Runner
- 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
-
#initialize ⇒ Runner
constructor
A new instance of Runner.
- #run_diagnostic(uri, document) ⇒ Object
-
#run_formatting(_uri, document) ⇒ String
We are not implementing this method, but it is required by the interface.
Constructor Details
#initialize ⇒ Runner
Returns a new instance of Runner.
12 13 14 |
# File 'lib/ruby_lsp/reek/runner.rb', line 12 def initialize @config = ::Reek::Configuration::AppConfiguration.from_default_path end |
Instance Method Details
#run_diagnostic(uri, document) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ruby_lsp/reek/runner.rb', line 32 def run_diagnostic(uri, document) path = Pathname.new(uri.path) return [] if path_excluded?(path) # We lint the source as it currently stands in the editor, but Reek # resolves directory directives from the origin, so the origin has to # be set explicitly to the file on disk rather than defaulting to # "string". examiner = ::Reek::Examiner.new( ::Reek::Source::SourceCode.from(document.source, origin: path.to_s), configuration: config ) examiner.smells.map { |smell| Diagnostic.from_warning(smell) } end |
#run_formatting(_uri, document) ⇒ String
We are not implementing this method, but it is required by the interface. Reek is a linter, so there is nothing to format and the source is handed back untouched.
:reek:UtilityFunction { enabled: false } - the interface requires an instance method, so it cannot depend on instance state.
26 27 28 |
# File 'lib/ruby_lsp/reek/runner.rb', line 26 def run_formatting(_uri, document) document.source end |