Class: Deprecool::Finders::Ruby::V4_0_0::ObjectSpaceId2ref

Inherits:
Deprecool::Finder show all
Defined in:
lib/deprecool/finders/ruby/v4.0.0/object_space_id2ref.rb

Instance Attribute Summary

Attributes inherited from Deprecool::Finder

#file_path, #source

Instance Method Summary collapse

Methods inherited from Deprecool::Finder

affected_version_range, classname, effort, hook_methods, id, inherited, #initialize

Methods included from PrismHelpers

#unwrap_arguments, #unwrap_array, #unwrap_children, #unwrap_class, #unwrap_parentheses

Constructor Details

This class inherits a constructor from Deprecool::Finder

Instance Method Details

#on_call_node(node) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/deprecool/finders/ruby/v4.0.0/object_space_id2ref.rb', line 22

def on_call_node(node)
  return unless node.name == :_id2ref

  # The method name '_id2ref' is quite unique, and
  # the use case for this is specific enough that
  # I don't think we need much more than this
  # I'm open to be wrong though, maybe lots of people are subclassing
  # ObjectSpace or defining '_id2ref' on custom classes
  confidence = node.receiver.name == :ObjectSpace ? :high : nil

  return unless confidence

  add_offense node, confidence: confidence
end