Sha256: 728411c736ea077ddaab9f5d8f92b263ea9c4a79b2747287c22ab845272d3c70

Contents?: true

Size: 728 Bytes

Versions: 2

Compression:

Stored size: 728 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Solidus
      # This cop finds Spree::Calculator::FreeShipping calls.
      # This cop is needed as they have been deprecated in future version.
      #
      # @example
      #
      #   # bad
      #   Spree::Calculator::FreeShipping
      #
      #   # good
      #
      class SpreeCalculatorFreeShippingDeprecated < Base
        MSG = 'Spree::Calculator::FreeShipping is deprecated.'

        def_node_matcher :free_shipping?, <<~PATTERN
          (send (... (... :Calculator) :FreeShipping) $_)
        PATTERN

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

          add_offense(node)
        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_calculator_free_shipping_deprecated.rb
rubocop-solidus-0.1.4 lib/rubocop/cop/solidus/spree_calculator_free_shipping_deprecated.rb