Method: RuboCop::Cop::RubyLsp::UseLanguageServerAliases#on_new_investigation

Defined in:
lib/rubocop/cop/ruby_lsp/use_language_server_aliases.rb

#on_new_investigationObject


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/rubocop/cop/ruby_lsp/use_language_server_aliases.rb', line 44

def on_new_investigation
  return if processed_source.blank?

  ruby_lsp_modules(processed_source.ast).each do |ruby_lsp_mod|
    lsp_constant_usages(ruby_lsp_mod).each do |node|
      lsp_const = node.children.last

      next unless ALIASED_CONSTANTS.include?(lsp_const)

      add_offense(node, message: format(MSG, constant: lsp_const)) do |corrector|
        corrector.replace(node, lsp_const)
      end
    end
  end
end