diff --git a/CHANGELOG.md b/CHANGELOG.md index 81b2f17ce..a57fedb0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Master (Unreleased) +- Remove `RuboCop::RSpec::Language::NodePattern`. ([@ydah]) - Extract RSpec Rails cops to a separate repository, [`rubocop-rspec_rails`](https://github.com/rubocop/rubocop-rspec_rails). The `rubocop-rspec_rails` repository is a dependency of `rubocop-rspec` and the cops related to rspec-rails are aliased (`RSpec/Rails/Foo` == `RSpecRails/Foo`) until v3.0 is released, so the change will be invisible to users until then. ([@ydah]) ## 2.27.1 (2024-03-03) diff --git a/lib/rubocop-rspec.rb b/lib/rubocop-rspec.rb index fffc0a2a4..b925b1d50 100644 --- a/lib/rubocop-rspec.rb +++ b/lib/rubocop-rspec.rb @@ -9,14 +9,11 @@ require_relative 'rubocop/rspec' require_relative 'rubocop/rspec/inject' -require_relative 'rubocop/rspec/language/node_pattern' +require_relative 'rubocop/rspec/language' require_relative 'rubocop/rspec/node' require_relative 'rubocop/rspec/version' require_relative 'rubocop/rspec/wording' -# Dependent on `RuboCop::RSpec::Language::NodePattern`. -require_relative 'rubocop/rspec/language' - require_relative 'rubocop/cop/rspec/mixin/file_help' require_relative 'rubocop/cop/rspec/mixin/final_end_location' require_relative 'rubocop/cop/rspec/mixin/inside_example_group' diff --git a/lib/rubocop/cop/rspec/base.rb b/lib/rubocop/cop/rspec/base.rb index 93c174a7e..0152f108f 100644 --- a/lib/rubocop/cop/rspec/base.rb +++ b/lib/rubocop/cop/rspec/base.rb @@ -6,7 +6,6 @@ module RSpec # @abstract parent class to RSpec cops class Base < ::RuboCop::Cop::Base include RuboCop::RSpec::Language - extend RuboCop::RSpec::Language::NodePattern exclude_from_registry diff --git a/lib/rubocop/cop/rspec/remove_const.rb b/lib/rubocop/cop/rspec/remove_const.rb index 1adbe9d9f..a2fe1475d 100644 --- a/lib/rubocop/cop/rspec/remove_const.rb +++ b/lib/rubocop/cop/rspec/remove_const.rb @@ -17,7 +17,6 @@ module RSpec # class RemoveConst < Base include RuboCop::RSpec::Language - extend RuboCop::RSpec::Language::NodePattern MSG = 'Do not use remove_const in specs. ' \ 'Consider using e.g. `stub_const`.' diff --git a/lib/rubocop/rspec/concept.rb b/lib/rubocop/rspec/concept.rb index 53790a1ec..037c8835f 100644 --- a/lib/rubocop/rspec/concept.rb +++ b/lib/rubocop/rspec/concept.rb @@ -5,7 +5,6 @@ module RSpec # Wrapper for RSpec DSL methods class Concept extend RuboCop::NodePattern::Macros - extend Language::NodePattern include Language def initialize(node) diff --git a/lib/rubocop/rspec/language.rb b/lib/rubocop/rspec/language.rb index cd7a3e586..dff05435c 100644 --- a/lib/rubocop/rspec/language.rb +++ b/lib/rubocop/rspec/language.rb @@ -13,7 +13,6 @@ module RSpec # using the configured aliases. module Language extend RuboCop::NodePattern::Macros - extend NodePattern class << self attr_accessor :config diff --git a/lib/rubocop/rspec/language/node_pattern.rb b/lib/rubocop/rspec/language/node_pattern.rb deleted file mode 100644 index 064296eaf..000000000 --- a/lib/rubocop/rspec/language/node_pattern.rb +++ /dev/null @@ -1,48 +0,0 @@ -# frozen_string_literal: true - -module RuboCop - module RSpec - module Language - # Helper methods to detect RSpec DSL used with send and block - # @deprecated Prefer using Node Pattern directly - # Use `'(block (send nil? #Example.all ...) ...)'` instead of - # `block_pattern('#Example.all')` - module NodePattern - # @deprecated Prefer using Node Pattern directly - def send_pattern(string) - deprecation_warning __method__ - "(send #rspec? #{string} ...)" - end - - # @deprecated Prefer using Node Pattern directly - def block_pattern(string) - deprecation_warning __method__ - "(block #{send_pattern(string)} ...)" - end - - # @deprecated Prefer using Node Pattern directly - def numblock_pattern(string) - deprecation_warning __method__ - "(numblock #{send_pattern(string)} ...)" - end - - # @deprecated Prefer using Node Pattern directly - def block_or_numblock_pattern(string) - deprecation_warning __method__ - "{#{block_pattern(string)} #{numblock_pattern(string)}}" - end - - private - - def deprecation_warning(method) - # Only warn in derived extensions' specs - return unless defined?(::RSpec) - - Kernel.warn <<~MESSAGE, uplevel: 2 - Usage of #{method} is deprecated. Use node pattern explicitly. - MESSAGE - end - end - end - end -end