Sha256: 10b8c13bdbed4c30c9aafcbcf0c36877ac17d2a46026d00f94fe33a303980a87

Contents?: true

Size: 715 Bytes

Versions: 5

Compression:

Stored size: 715 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    # Common functionality for checking `rescue` nodes.
    module RescueNode
      def on_new_investigation
        @modifier_locations = processed_source.tokens.select(&:rescue_modifier?).map(&:pos)
      end

      private

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

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

      # @deprecated Use ResbodyNode#exceptions instead
      def rescued_exceptions(resbody)
        rescue_group, = *resbody
        if rescue_group
          rescue_group.values
        else
          []
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubocop-1.40.0 lib/rubocop/cop/mixin/rescue_node.rb
rubocop-1.39.0 lib/rubocop/cop/mixin/rescue_node.rb
rubocop-1.38.0 lib/rubocop/cop/mixin/rescue_node.rb
rubocop-1.37.1 lib/rubocop/cop/mixin/rescue_node.rb
rubocop-1.37.0 lib/rubocop/cop/mixin/rescue_node.rb