Sha256: a059d2f01cee858f0d7f858f1c59af10ebcc90868ea90fa214eca7490c433fef

Contents?: true

Size: 628 Bytes

Versions: 1

Compression:

Stored size: 628 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.cop_enabled?('Style/DigChain')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-1.70.0 lib/rubocop/cop/mixin/dig_help.rb