lib/spoom/deadcode/plugins/actionpack.rb in spoom-1.3.2 vs lib/spoom/deadcode/plugins/actionpack.rb in spoom-1.3.3
- old
+ new
@@ -5,10 +5,12 @@
module Deadcode
module Plugins
class ActionPack < Base
extend T::Sig
+ ignore_classes_inheriting_from("ApplicationController")
+
CALLBACKS = T.let(
[
"after_action",
"append_after_action",
"append_around_action",
@@ -23,34 +25,35 @@
"skip_before_action",
].freeze,
T::Array[String],
)
- ignore_classes_named(/Controller$/)
+ sig { override.params(definition: Model::Method).void }
+ def on_define_method(definition)
+ owner = definition.owner
+ return unless owner.is_a?(Model::Class)
- sig { override.params(indexer: Indexer, definition: Definition).void }
- def on_define_method(indexer, definition)
- definition.ignored! if ignored_class_name?(indexer.nesting_class_name)
+ @index.ignore(definition) if ignored_subclass?(owner)
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
case arg
when Prism::SymbolNode
- indexer.reference_method(arg.unescaped, send.node)
+ @index.reference_method(arg.unescaped, send.location)
end
send.each_arg_assoc do |key, value|
key = key.slice.delete_suffix(":")
case key
when "if", "unless"
- indexer.reference_method(value.slice.delete_prefix(":"), send.node) if value
+ @index.reference_method(value.slice.delete_prefix(":"), send.location) if value
else
- indexer.reference_constant(camelize(key), send.node)
+ @index.reference_constant(camelize(key), send.location)
end
end
end
end
end