lib/spoom/deadcode/plugins/rubocop.rb in spoom-1.3.2 vs lib/spoom/deadcode/plugins/rubocop.rb in spoom-1.3.3

- old
+ new

@@ -8,33 +8,29 @@ extend T::Sig RUBOCOP_CONSTANTS = T.let(["MSG", "RESTRICT_ON_SEND"].to_set.freeze, T::Set[String]) ignore_classes_inheriting_from( - /^(::)?RuboCop::Cop::Cop$/, - /^(::)?RuboCop::Cop::Base$/, + "RuboCop::Cop::Cop", + "RuboCop::Cop::Base", ) - sig { override.params(indexer: Indexer, definition: Definition).void } - def on_define_constant(indexer, definition) - definition.ignored! if rubocop_constant?(indexer, definition) - end + sig { override.params(definition: Model::Constant).void } + def on_define_constant(definition) + owner = definition.owner + return false unless owner.is_a?(Model::Class) - sig { override.params(indexer: Indexer, definition: Definition).void } - def on_define_method(indexer, definition) - definition.ignored! if rubocop_method?(indexer, definition) + @index.ignore(definition) if ignored_subclass?(owner) && RUBOCOP_CONSTANTS.include?(definition.name) end - private + sig { override.params(definition: Model::Method).void } + def on_define_method(definition) + return unless definition.name == "on_send" - sig { params(indexer: Indexer, definition: Definition).returns(T::Boolean) } - def rubocop_constant?(indexer, definition) - ignored_subclass?(indexer.nesting_class_superclass_name) && RUBOCOP_CONSTANTS.include?(definition.name) - end + owner = definition.owner + return unless owner.is_a?(Model::Class) - sig { params(indexer: Indexer, definition: Definition).returns(T::Boolean) } - def rubocop_method?(indexer, definition) - ignored_subclass?(indexer.nesting_class_superclass_name) && definition.name == "on_send" + @index.ignore(definition) if ignored_subclass?(owner) end end end end end