Sha256: c48398f5432d586723b474691f235433059cca92283388646848467fcc268ba8

Contents?: true

Size: 1002 Bytes

Versions: 1

Compression:

Stored size: 1002 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Solidus
      # This cop finds existing_card_id occurrences and suggest using wallet_payment_source_id instead.
      #
      # @example
      #
      #   # bad
      #   {
      #     name: payment_method.name,
      #     existing_card_id: payment_source.id
      #   }
      #
      #   # good
      #   {
      #     name: payment_method.name,
      #     wallet_payment_source_id: payment_source.wallet.wallet_payment_sources.first.id
      #   }
      #
      class ExistingCardIdDeprecated < Base
        include TargetSolidusVersion
        minimum_solidus_version 2.2

        MSG = 'Use `wallet_payment_source_id` instead of `existing_card_id`.'

        def_node_matcher :existing_card_id?, <<~PATTERN
          (send ... :existing_card_id)
        PATTERN

        def on_send(node)
          return unless existing_card_id?(node)

          add_offense(node, severity: :warning)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-solidus-0.2.0 lib/rubocop/cop/solidus/existing_card_id_deprecated.rb