Sha256: 2167d363c4dd246aa1c41870b306613f9406653a8edc6af5cf3eecf8bde1ed58

Contents?: true

Size: 654 Bytes

Versions: 59

Compression:

Stored size: 654 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)
        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

59 entries across 53 versions & 7 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/cop/mixin/rescue_node.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/cop/mixin/rescue_node.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/cop/mixin/rescue_node.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-1.31.2/lib/rubocop/cop/mixin/rescue_node.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-1.36.0/lib/rubocop/cop/mixin/rescue_node.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-1.35.1/lib/rubocop/cop/mixin/rescue_node.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-1.26.0/lib/rubocop/cop/mixin/rescue_node.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.35.1/lib/rubocop/cop/mixin/rescue_node.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.26.0/lib/rubocop/cop/mixin/rescue_node.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.36.0/lib/rubocop/cop/mixin/rescue_node.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.31.2/lib/rubocop/cop/mixin/rescue_node.rb
rubocop-1.36.0 lib/rubocop/cop/mixin/rescue_node.rb
rubocop-1.35.1 lib/rubocop/cop/mixin/rescue_node.rb
rubocop-1.35.0 lib/rubocop/cop/mixin/rescue_node.rb
rubocop-1.34.1 lib/rubocop/cop/mixin/rescue_node.rb
rubocop-1.34.0 lib/rubocop/cop/mixin/rescue_node.rb
rubocop-1.33.0 lib/rubocop/cop/mixin/rescue_node.rb
rubocop-1.32.0 lib/rubocop/cop/mixin/rescue_node.rb
rubocop-1.31.2 lib/rubocop/cop/mixin/rescue_node.rb
rubocop-1.31.1 lib/rubocop/cop/mixin/rescue_node.rb