diff --git a/lib/spoom/deadcode/indexer.rb b/lib/spoom/deadcode/indexer.rb index 13e8a873..4faabe09 100644 --- a/lib/spoom/deadcode/indexer.rb +++ b/lib/spoom/deadcode/indexer.rb @@ -191,7 +191,7 @@ def visit_send(send) visit(send.recv) @plugins.each do |plugin| - plugin.internal_on_send(self, send) + plugin.on_send(send) end @index.reference_method(send.name, send.location) diff --git a/lib/spoom/deadcode/plugins/action_mailer.rb b/lib/spoom/deadcode/plugins/action_mailer.rb index c6b6552c..4341052b 100644 --- a/lib/spoom/deadcode/plugins/action_mailer.rb +++ b/lib/spoom/deadcode/plugins/action_mailer.rb @@ -7,8 +7,8 @@ module Plugins class ActionMailer < Base extend T::Sig - sig { override.params(indexer: Indexer, send: Send).void } - def on_send(indexer, send) + sig { override.params(send: Send).void } + def on_send(send) return unless send.recv.nil? && ActionPack::CALLBACKS.include?(send.name) send.each_arg(Prism::SymbolNode) do |arg| diff --git a/lib/spoom/deadcode/plugins/actionpack.rb b/lib/spoom/deadcode/plugins/actionpack.rb index fdf775ef..7784f76e 100644 --- a/lib/spoom/deadcode/plugins/actionpack.rb +++ b/lib/spoom/deadcode/plugins/actionpack.rb @@ -35,8 +35,8 @@ def on_define_method(symbol_def, definition) definition.ignored! if ignored_class_name?(owner.name) end - sig { override.params(indexer: Indexer, send: Send).void } - def on_send(indexer, send) + sig { override.params(send: Send).void } + def on_send(send) return unless send.recv.nil? && CALLBACKS.include?(send.name) arg = send.args.first diff --git a/lib/spoom/deadcode/plugins/active_model.rb b/lib/spoom/deadcode/plugins/active_model.rb index 43f2d0e8..de42f59b 100644 --- a/lib/spoom/deadcode/plugins/active_model.rb +++ b/lib/spoom/deadcode/plugins/active_model.rb @@ -10,8 +10,8 @@ class ActiveModel < Base ignore_classes_inheriting_from(/^(::)?ActiveModel::EachValidator$/) ignore_methods_named("validate_each") - sig { override.params(indexer: Indexer, send: Send).void } - def on_send(indexer, send) + sig { override.params(send: Send).void } + def on_send(send) return if send.recv case send.name diff --git a/lib/spoom/deadcode/plugins/active_record.rb b/lib/spoom/deadcode/plugins/active_record.rb index 885c4016..c9916923 100644 --- a/lib/spoom/deadcode/plugins/active_record.rb +++ b/lib/spoom/deadcode/plugins/active_record.rb @@ -70,8 +70,8 @@ class ActiveRecord < Base T::Array[String], ) - sig { override.params(indexer: Indexer, send: Send).void } - def on_send(indexer, send) + sig { override.params(send: Send).void } + def on_send(send) if send.recv.nil? && CALLBACKS.include?(send.name) send.each_arg(Prism::SymbolNode) do |arg| @index.reference_method(arg.unescaped, send.location) diff --git a/lib/spoom/deadcode/plugins/active_support.rb b/lib/spoom/deadcode/plugins/active_support.rb index 2b39e123..477032f8 100644 --- a/lib/spoom/deadcode/plugins/active_support.rb +++ b/lib/spoom/deadcode/plugins/active_support.rb @@ -18,8 +18,8 @@ class ActiveSupport < Base SETUP_AND_TEARDOWN_METHODS = T.let(["setup", "teardown"], T::Array[String]) - sig { override.params(indexer: Indexer, send: Send).void } - def on_send(indexer, send) + sig { override.params(send: Send).void } + def on_send(send) return unless send.recv.nil? && SETUP_AND_TEARDOWN_METHODS.include?(send.name) send.each_arg(Prism::SymbolNode) do |arg| diff --git a/lib/spoom/deadcode/plugins/base.rb b/lib/spoom/deadcode/plugins/base.rb index e8d7f5ff..34293f6d 100644 --- a/lib/spoom/deadcode/plugins/base.rb +++ b/lib/spoom/deadcode/plugins/base.rb @@ -277,17 +277,11 @@ def internal_on_define_module(symbol_def, definition) # end # end # ~~~ - sig { params(indexer: Indexer, send: Send).void } - def on_send(indexer, send) + sig { params(send: Send).void } + def on_send(send) # no-op end - # Do not override this method, use `on_send` instead. - sig { params(indexer: Indexer, send: Send).void } - def internal_on_send(indexer, send) - on_send(indexer, send) - end - private # DSL support diff --git a/lib/spoom/deadcode/plugins/graphql.rb b/lib/spoom/deadcode/plugins/graphql.rb index dc57f877..f331da9f 100644 --- a/lib/spoom/deadcode/plugins/graphql.rb +++ b/lib/spoom/deadcode/plugins/graphql.rb @@ -24,8 +24,8 @@ class GraphQL < Base "unsubscribed", ) - sig { override.params(indexer: Indexer, send: Send).void } - def on_send(indexer, send) + sig { override.params(send: Send).void } + def on_send(send) return unless send.recv.nil? && send.name == "field" arg = send.args.first diff --git a/lib/spoom/deadcode/plugins/ruby.rb b/lib/spoom/deadcode/plugins/ruby.rb index 0374ed39..4daa2edb 100644 --- a/lib/spoom/deadcode/plugins/ruby.rb +++ b/lib/spoom/deadcode/plugins/ruby.rb @@ -20,8 +20,8 @@ class Ruby < Base "to_s", ) - sig { override.params(indexer: Indexer, send: Send).void } - def on_send(indexer, send) + sig { override.params(send: Send).void } + def on_send(send) case send.name when "const_defined?", "const_get", "const_source_location" reference_symbol_as_constant(send, T.must(send.args.first)) diff --git a/test/spoom/deadcode/plugins/base_test.rb b/test/spoom/deadcode/plugins/base_test.rb index 7248c61e..a7e5896e 100644 --- a/test/spoom/deadcode/plugins/base_test.rb +++ b/test/spoom/deadcode/plugins/base_test.rb @@ -99,7 +99,7 @@ module Module2; end def test_on_send plugin = Class.new(Base) do - def on_send(indexer, send) + def on_send(send) return unless send.name == "dsl_method" return if send.args.empty?