Class: RubyLsp::Reek::Addon
- Inherits:
-
Addon
- Object
- Addon
- RubyLsp::Reek::Addon
- Defined in:
- lib/ruby_lsp/reek/addon.rb
Overview
Implements the RubyLsp::Addon interface to provide Reek linter support to Ruby LSP.
Class Method Summary collapse
Instance Method Summary collapse
- #activate(global_state, message_queue) ⇒ Object
- #deactivate ⇒ nil
- #initializer ⇒ Object
-
#name ⇒ String
The name of the addon.
-
#version ⇒ String
The version of the addon.
- #workspace_did_change_watched_files(changes) ⇒ Object
Class Method Details
.register_additional_file_watchers(global_state, message_queue) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ruby_lsp/reek/addon.rb', line 46 def self.register_additional_file_watchers(global_state, ) return unless global_state.supports_watching_files << Request.new( id: "reek-file-watcher", method: "client/registerCapability", params: Interface::RegistrationParams.new( registrations: [ Interface::Registration.new( id: "workspace/didChangeWatchedFilesReek", method: "workspace/didChangeWatchedFiles", register_options: Interface::DidChangeWatchedFilesRegistrationOptions.new( watchers: [ Interface::FileSystemWatcher.new( glob_pattern: "**/.reek.yml", kind: Constant::WatchKind::CREATE | Constant::WatchKind::CHANGE | Constant::WatchKind::DELETE ) ] ) ) ] ) ) end |
Instance Method Details
#activate(global_state, message_queue) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/ruby_lsp/reek/addon.rb', line 31 def activate(global_state, ) warn "Activating Reek Ruby LSP addon v#{::RubyLsp::Reek::VERSION}" @runner = Runner.new global_state.register_formatter("reek", runner) self.class.register_additional_file_watchers(global_state, ) warn "Initialized Reek Ruby LSP addon v#{::RubyLsp::Reek::VERSION}" end |
#deactivate ⇒ nil
40 41 42 |
# File 'lib/ruby_lsp/reek/addon.rb', line 40 def deactivate @runner = nil end |
#initializer ⇒ Object
15 16 17 |
# File 'lib/ruby_lsp/reek/addon.rb', line 15 def initializer @runner = nil end |
#name ⇒ String
Returns The name of the addon.
20 21 22 |
# File 'lib/ruby_lsp/reek/addon.rb', line 20 def name "Reek: Code smell detector for Ruby" end |
#version ⇒ String
Returns The version of the addon.
25 26 27 |
# File 'lib/ruby_lsp/reek/addon.rb', line 25 def version ::RubyLsp::Reek::VERSION end |
#workspace_did_change_watched_files(changes) ⇒ Object
72 73 74 75 76 77 |
# File 'lib/ruby_lsp/reek/addon.rb', line 72 def workspace_did_change_watched_files(changes) return unless changes.any? { |change| change[:uri].end_with?(".reek.yml") } @runner = Runner.new warn "Re-initialized Reek Ruby LSP addon v#{::RubyLsp::Reek::VERSION} due to .reek.yml file change" end |