class RuboCop::Cop::Lint::ItWithoutArgumentsInBlock
do_something { self.it }
do_something { it() }
# good
do_something { it }
# bad
@example
So use βit()` or `self.it` to ensure compatibility.
`it` calls without arguments will refer to the first block param in Ruby 3.4.
β-
use it() or self.it
-e:1: warning: `it` calls without arguments will refer to the first block param in Ruby 3.4;
$ ruby -e β0.times { it }β
Emulates the following Ruby warning in Ruby 3.3.
def deprecated_it_method?(node)
def deprecated_it_method?(node) !node.receiver && node.arguments.empty? && !node.parenthesized? && !node.block_literal? end
def on_send(node)
def on_send(node) return unless (block_node = node.each_ancestor(:block).first) return unless block_node.arguments.empty_and_without_delimiters? add_offense(node) if deprecated_it_method?(node) end