class RuboCop::Cop::InternalAffairs::NumblockHandler
Checks for missing ‘numblock` handlers. The blocks with numbered arguments introduced in Ruby 2.7 are parsed with a node type of `numblock` instead of block. Cops that define `block` handlers need to define `numblock` handlers or disable this cope for them.
@example
# bad class BlockRelatedCop < Base def on_block(node) end end # good class BlockRelatedCop < Base def on_block(node) end alias on_numblock on_block end class BlockRelatedCop < Base def on_block(node) end alias_method :on_numblock, :on_block end class BlockRelatedCop < Base def on_block(node) end def on_numblock(node) end end
Constants
- MSG
Public Instance Methods
Source
# File lib/rubocop/cop/internal_affairs/numblock_handler.rb, line 44 def on_def(node) return unless block_handler?(node) return unless node.parent add_offense(node) unless numblock_handler?(node.parent) end