diff --git a/config/default.yml b/config/default.yml index 05d81e1..60cd706 100644 --- a/config/default.yml +++ b/config/default.yml @@ -47,8 +47,3 @@ Solidus/SpreeTDecprecated: Description: 'Checks if Spree.t is being used and replaces it with I18n.t.' Enabled: true VersionAdded: '0.1.2' - -Solidus/TaxCategoryDeprecated: - Description: 'Checks if .tax_category=Instance is being used and suggest to replace it with .tax_categories=' - Enabled: true - VersionAdded: '0.1.3' diff --git a/lib/rubocop/cop/solidus/tax_category_deprecated.rb b/lib/rubocop/cop/solidus/tax_category_deprecated.rb deleted file mode 100644 index 30cfdde..0000000 --- a/lib/rubocop/cop/solidus/tax_category_deprecated.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -module RuboCop - module Cop - module Solidus - # This cop finds tax_category= usages and suggests the usage of tax_categories= instead. - # This cop is needed as tax_category= has been deprecated in future version. - # - # @example EnforcedStyle: - # # bad - # model.tax_category = data - # - # # good - # model.tax_categories = [data] - # - class TaxCategoryDeprecated < Base - MSG = 'tax_category= is deprecated and will be removed from Solidus 3.0. Please use tax_categories= instead.' - - # @!method bad_method?(node) - def_node_matcher :tax_category?, <<~PATTERN - (send (...) :tax_category= (...)) - PATTERN - - def on_send(node) - return unless tax_category?(node) - - add_offense(node) - end - end - end - end -end diff --git a/lib/rubocop/cop/solidus_cops.rb b/lib/rubocop/cop/solidus_cops.rb index 62083cd..818c35a 100644 --- a/lib/rubocop/cop/solidus_cops.rb +++ b/lib/rubocop/cop/solidus_cops.rb @@ -10,4 +10,4 @@ require_relative 'solidus/spree_icon_deprecated' require_relative 'solidus/spree_refund_call_perform' require_relative 'solidus/spree_t_decprecated' -require_relative 'solidus/tax_category_deprecated' + diff --git a/spec/rubocop/cop/solidus/tax_category_deprecated_spec.rb b/spec/rubocop/cop/solidus/tax_category_deprecated_spec.rb deleted file mode 100644 index 698ba0c..0000000 --- a/spec/rubocop/cop/solidus/tax_category_deprecated_spec.rb +++ /dev/null @@ -1,83 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe RuboCop::Cop::Solidus::TaxCategoryDeprecated, :config do - class TaxCategory - # ... sample class - end - - class Tax - # ... sample class - end - - let(:config) { RuboCop::Config.new('Solidus/TaxCategoryDeprecated' => { 'Enabled' => true }) } - let(:tax) { Tax.new } - - context 'when using non-instantiated text' do - it 'registers an offense when using `#.tax_category = `' do - expect_offense(<<~RUBY) - model.tax_category = data - ^^^^^^^^^^^^^^^^^^^^^^^^^ tax_category= is deprecated and will be removed from Solidus 3.0. Please use tax_categories= instead. - RUBY - end - - it 'registers an offense when using `#.tax_category =`' do - expect_offense(<<~RUBY) - model.tax_category =data - ^^^^^^^^^^^^^^^^^^^^^^^^ tax_category= is deprecated and will be removed from Solidus 3.0. Please use tax_categories= instead. - RUBY - end - - it 'registers an offense when using `#.tax_category= `' do - expect_offense(<<~RUBY) - model.tax_category= data - ^^^^^^^^^^^^^^^^^^^^^^^^ tax_category= is deprecated and will be removed from Solidus 3.0. Please use tax_categories= instead. - RUBY - end - end - - context 'when using TaxCategory.new assignment' do - it 'registers an offense when using `#.tax_category = `' do - expect_offense(<<~RUBY) - model.tax_category = TaxCategory.new - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tax_category= is deprecated and will be removed from Solidus 3.0. Please use tax_categories= instead. - RUBY - end - - it 'registers an offense when using `#.tax_category =`' do - expect_offense(<<~RUBY) - model.tax_category =TaxCategory.new - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tax_category= is deprecated and will be removed from Solidus 3.0. Please use tax_categories= instead. - RUBY - end - - it 'registers an offense when using `#.tax_category= `' do - expect_offense(<<~RUBY) - model.tax_category= TaxCategory.new - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tax_category= is deprecated and will be removed from Solidus 3.0. Please use tax_categories= instead. - RUBY - end - end - - context 'when using Tax instance for method call' do - it 'registers an offense when using `#.tax_category = `' do - expect_offense(<<~RUBY) - tax.tax_category = data - ^^^^^^^^^^^^^^^^^^^^^^^ tax_category= is deprecated and will be removed from Solidus 3.0. Please use tax_categories= instead. - RUBY - end - - it 'registers an offense when using `#.tax_category =`' do - expect_offense(<<~RUBY) - tax.tax_category =data - ^^^^^^^^^^^^^^^^^^^^^^ tax_category= is deprecated and will be removed from Solidus 3.0. Please use tax_categories= instead. - RUBY - end - - it 'registers an offense when using `#.tax_category= `' do - expect_offense(<<~RUBY) - tax.tax_category= data - ^^^^^^^^^^^^^^^^^^^^^^ tax_category= is deprecated and will be removed from Solidus 3.0. Please use tax_categories= instead. - RUBY - end - end -end