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.
- #workspace_did_change_watched_files(changes) ⇒ Object
Class Method Details
.register_additional_file_watchers(global_state, message_queue) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ruby_lsp/reek/addon.rb', line 42 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
27 28 29 30 31 32 33 |
# File 'lib/ruby_lsp/reek/addon.rb', line 27 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
36 37 38 |
# File 'lib/ruby_lsp/reek/addon.rb', line 36 def deactivate @runner = nil end |
#initializer ⇒ Object
16 17 18 |
# File 'lib/ruby_lsp/reek/addon.rb', line 16 def initializer @runner = nil end |
#name ⇒ String
Returns The name of the addon.
21 22 23 |
# File 'lib/ruby_lsp/reek/addon.rb', line 21 def name "Reek: Code smell detector for Ruby" end |
#workspace_did_change_watched_files(changes) ⇒ Object
68 69 70 71 72 73 |
# File 'lib/ruby_lsp/reek/addon.rb', line 68 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 |