Sha256: cdd31190180211c028032b60800eb85088b5f98c66846000fbfb3782b10616a3
Contents?: true
Size: 1.28 KB
Versions: 2
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module Solidus # This cop finds Spree::Gateway::Bogus calls and replaces them with the Spree::PaymentMethod::BogusCreditCard. # This cop is needed as the Spree::Gateway::Bogus has been deprecated in future version. # # @example # # bad # Spree::Gateway::Bogus.new # Spree::Gateway::Bogus.create # Spree::Gateway::Bogus.create! # # # good # Spree::PaymentMethod::BogusCreditCard.new # Spree::PaymentMethod::BogusCreditCard.create # Spree::PaymentMethod::BogusCreditCard.create! # class SpreeGatewayBogusDeprecated < Base extend AutoCorrector include TargetSolidusVersion minimum_solidus_version 2.10 MSG = 'Spree::Gateway::Bogus is deprecated. Please use Spree::PaymentMethod::BogusCreditCard instead.' def_node_matcher :bad_class?, <<~PATTERN (send (... (... :Gateway) :Bogus) $_) PATTERN def on_send(node) bad_class?(node) do |method_used| add_offense(node, message: MSG) do |corrector| corrector.replace(node, "Spree::PaymentMethod::BogusCreditCard.#{method_used}") end end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-solidus-0.2.0 | lib/rubocop/cop/solidus/spree_gateway_bogus_deprecated.rb |
rubocop-solidus-0.1.4 | lib/rubocop/cop/solidus/spree_gateway_bogus_deprecated.rb |