123456789_123456789_123456789_123456789_123456789_

Module: RuboCop::Cop::RescueNode

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: lib/rubocop/cop/mixin/rescue_node.rb

Overview

Common functionality for checking rescue nodes.

Instance Method Summary

Instance Method Details

#modifier_locations

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/rescue_node.rb', line 7

def modifier_locations
  @modifier_locations ||= processed_source.tokens.select(&:rescue_modifier?).map!(&:pos)
end

#rescue_modifier?(node) ⇒ Boolean (private)

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/rescue_node.rb', line 13

def rescue_modifier?(node)
  return false unless node.respond_to?(:resbody_type?)

  node.resbody_type? && modifier_locations.include?(node.loc.keyword)
end

#rescued_exceptions(resbody) (private)

Deprecated.

Use ResbodyNode#exceptions instead

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/rescue_node.rb', line 20

def rescued_exceptions(resbody)
  warn Rainbow(<<~WARNING).yellow, uplevel: 1
    `rescued_exceptions` is deprecated. Use `ResbodyNode#exceptions` instead.
  WARNING

  rescue_group, = *resbody
  if rescue_group
    rescue_group.values
  else
    []
  end
end