class RuboCop::Cop::Sorbet::CallbackConditionalsBinding
def on_send(node)
def on_send(node) return unless CALLBACKS.include?(node.method_name) options = node.each_child_node.find(&:hash_type?) return if options.nil? conditional = nil options.each_pair do |keyword, block| next unless keyword.sym_type? if keyword.value == :if || keyword.value == :unless conditional = block break end end return if conditional.nil? || conditional.array_type? || conditional.child_nodes.empty? return unless conditional.arguments.empty? type, _, block = conditional.child_nodes return unless type.lambda_or_proc? || type.block_literal? klass = node.ancestors.find(&:class_type?) expected_class = if klass&.children&.first&.children&.first.nil? node.parent_module_name&.split("::")&.last else klass.identifier.source end return if expected_class.nil? unless block.source.include?("T.bind(self") add_offense( node, message: "Callback conditionals should be bound to the right type. Use T.bind(self, #{expected_class})", ) end end