Sha256: 76b8e0ba02aa1e98af75c56dcd23ca9e63c3cddc4bf22260b38c4a7d2ded5827

Contents?: true

Size: 634 Bytes

Versions: 3

Compression:

Stored size: 634 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    # Help methods for working with `Enumerable#dig` in cops.
    # Used by `Style::DigChain` and `Style::SingleArgumentDig`
    module DigHelp
      extend NodePattern::Macros

      # @!method dig?(node)
      def_node_matcher :dig?, <<~PATTERN
        (call _ :dig !{hash block_pass}+)
      PATTERN

      # @!method single_argument_dig?(node)
      def_node_matcher :single_argument_dig?, <<~PATTERN
        (send _ :dig $!splat)
      PATTERN

      private

      def dig_chain_enabled?
        @config.for_cop('Style/DigChain')['Enabled']
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubocop-1.69.2 lib/rubocop/cop/mixin/dig_help.rb
rubocop-1.69.1 lib/rubocop/cop/mixin/dig_help.rb
rubocop-1.69.0 lib/rubocop/cop/mixin/dig_help.rb