Class: Spoom::Deadcode::Plugins::Minitest

Inherits:
Base
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/spoom/deadcode/plugins/minitest.rb

Constant Summary collapse

MINITEST_METHODS =
T.let(
  Set.new([
    "after_all",
    "around",
    "around_all",
    "before_all",
    "setup",
    "teardown",
  ]),
  T::Set[String],
)

Instance Attribute Summary

Attributes inherited from Base

#index

Instance Method Summary collapse

Methods inherited from Base

ignore_classes_inheriting_from, ignore_classes_named, ignore_constants_named, ignore_methods_named, ignore_modules_named, #initialize, #internal_on_define_accessor, #internal_on_define_class, #internal_on_define_constant, #internal_on_define_method, #internal_on_define_module, #on_define_accessor, #on_define_class, #on_define_constant, #on_define_module

Constructor Details

This class inherits a constructor from Spoom::Deadcode::Plugins::Base

Instance Method Details

#on_define_method(definition) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/spoom/deadcode/plugins/minitest.rb', line 25

def on_define_method(definition)
  return unless definition.name.start_with?("test_") || MINITEST_METHODS.include?(definition.name)

  owner = definition.owner
  return unless owner.is_a?(Model::Class)

  @index.ignore(definition) if ignored_subclass?(owner)
end

#on_send(send) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/spoom/deadcode/plugins/minitest.rb', line 35

def on_send(send)
  case send.name
  when "assert_predicate", "refute_predicate"
    name = send.args[1]&.slice
    return unless name

    @index.reference_method(name.delete_prefix(":"), send.location)
  end
end