Class: Deprecool::Finders::Rails::V7_1_0::SerializerPositionalClassArgument

Inherits:
Deprecool::Finder
  • Object
show all
Defined in:
lib/deprecool/finders/rails/v7.1.0/serializer_positional_class_argument.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

TODO: add check for the serialize method being called by a Rails model?, like add a on_constant_path_node for ActiveRecord::Base or a class_node with a superclass of ActiveRecord::Base def on_class_node node node end



26
27
28
29
30
31
32
33
# File 'lib/deprecool/finders/rails/v7.1.0/serializer_positional_class_argument.rb', line 26

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

  arguments_array = unwrap_arguments(node.arguments)
  return unless arguments_array && arguments_array[1]

  add_offense(node, confidence: :high) if arguments_array[1].is_a?(Prism::ConstantReadNode)
end