Class: Spoom::Deadcode::Plugins::Sorbet

Inherits:
Base
  • Object
show all
Defined in:
lib/spoom/deadcode/plugins/sorbet.rb

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_module, #on_send

Constructor Details

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

Instance Method Details

#on_define_constant(definition) ⇒ Object

: (Model::Constant definition) -> void



10
11
12
# File 'lib/spoom/deadcode/plugins/sorbet.rb', line 10

def on_define_constant(definition)
  @index.ignore(definition) if sorbet_type_member?(definition) || sorbet_enum_constant?(definition)
end

#on_define_method(definition) ⇒ Object

: (Model::Method definition) -> void



16
17
18
19
20
21
22
23
24
# File 'lib/spoom/deadcode/plugins/sorbet.rb', line 16

def on_define_method(definition)
  # Ignore signatures containing `override` or `overridable`, like `sig { override.void }`
  @index.ignore(definition) if definition.sigs.any? { |sig| sig.string =~ /(override|overridable)/ }

  # Ignore comments `@override` and `@overridable`
  @index.ignore(definition) if definition.comments.any? do |comment|
    comment.string == "@override" || comment.string == "@overridable"
  end
end