class RuboCop::Cop::Lint::ItWithoutArgumentsInBlock
Emulates the following Ruby warning in Ruby 3.3.
- source,ruby
$ ruby -e ‘0.times { it }’ -e:1: warning: ‘it` calls without arguments will refer to the first block param in Ruby 3.4; use it() or self.it
‘it` calls without arguments will refer to the first block param in Ruby 3.4. So use `it()` or `self.it` to ensure compatibility.
@example
# bad do_something { it } # good do_something { it() } do_something { self.it }
Constants
- MSG
- RESTRICT_ON_SEND
Public Instance Methods
deprecated_it_method?(node)
click to toggle source
# File lib/rubocop/cop/lint/it_without_arguments_in_block.rb, line 41 def deprecated_it_method?(node) !node.receiver && node.arguments.empty? && !node.parenthesized? && !node.block_literal? end
on_send(node)
click to toggle source
# File lib/rubocop/cop/lint/it_without_arguments_in_block.rb, line 34 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