Module: RuboCop::Cop::RescueNode

Included in:
Lint::RescueType, Lint::ShadowedException, Style::ParallelAssignment, Style::RescueModifier
Defined in:
lib/rubocop/cop/mixin/rescue_node.rb

Overview

Common functionality for checking ‘rescue` nodes.

Instance Method Summary collapse

Instance Method Details

#investigate(processed_source) ⇒ Object



7
8
9
10
11
12
# File 'lib/rubocop/cop/mixin/rescue_node.rb', line 7

def investigate(processed_source)
  @modifier_locations = processed_source
                        .tokens
                        .select { |t| t.type == :kRESCUE_MOD }
                        .map(&:pos)
end

#rescue_modifier?(node) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/rubocop/cop/mixin/rescue_node.rb', line 14

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