lib/spoom/deadcode/plugins/namespaces.rb in spoom-1.3.2 vs lib/spoom/deadcode/plugins/namespaces.rb in spoom-1.3.3
- old
+ new
@@ -5,27 +5,24 @@
module Deadcode
module Plugins
class Namespaces < Base
extend T::Sig
- sig { override.params(indexer: Indexer, definition: Definition).void }
- def on_define_class(indexer, definition)
- definition.ignored! if used_as_namespace?(indexer)
+ sig { override.params(definition: Model::Class).void }
+ def on_define_class(definition)
+ @index.ignore(definition) if used_as_namespace?(definition)
end
- sig { override.params(indexer: Indexer, definition: Definition).void }
- def on_define_module(indexer, definition)
- definition.ignored! if used_as_namespace?(indexer)
+ sig { override.params(definition: Model::Module).void }
+ def on_define_module(definition)
+ @index.ignore(definition) if used_as_namespace?(definition)
end
private
- sig { params(indexer: Indexer).returns(T::Boolean) }
- def used_as_namespace?(indexer)
- node = indexer.current_node
- return false unless node.is_a?(Prism::ClassNode) || node.is_a?(Prism::ModuleNode)
-
- !!node.body
+ sig { params(symbol_def: Model::Namespace).returns(T::Boolean) }
+ def used_as_namespace?(symbol_def)
+ symbol_def.children.any?
end
end
end
end
end