Sha256: a9757f6133962e7e0f7b6ce0ee0120929f66128a3a7767029203ce8d4403016e
Contents?: true
Size: 1 KB
Versions: 2
Compression:
Stored size: 1 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module Solidus # This cop finds Spree::Calculator::PercentPerItem calls. # This cop is needed as they have been deprecated in future version. # # @example # # # bad # Spree::Calculator::PercentPerItem # # # good # Spree::Calculator::PercentOnLineItem # class SpreeCalculatorPercentPerItemDeprecated < Base extend AutoCorrector MSG = 'Spree::Calculator::PercentPerItem is deprecated. Use Spree::Calculator::PercentOnLineItem instead.' def_node_matcher :percent_per_item?, <<~PATTERN (send (... (... :Calculator) :PercentPerItem) $_) PATTERN def on_send(node) percent_per_item?(node) do |method_used| add_offense(node, message: MSG) do |corrector| corrector.replace(node, "Spree::Calculator::PercentOnLineItem.#{method_used}") end end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems