From 7e1d68eee4434464b032b0663741228a92b0ce7d Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Thu, 11 Jul 2024 03:27:23 +0900 Subject: [PATCH] Suppress deprecation warning for some cops Resolves https://github.com/rubocop/rubocop/pull/13032#issuecomment-2220942111. Starting from RuboCop 1.65, using `ConfigurableMax` module API, which is deprecated, will trigger deprecation warnings. This PR suppresses these warnings by using `exclude_limit` instead of the deprecated API. Related PR: https://github.com/rubocop/rubocop/pull/9471 --- CHANGELOG.md | 1 + lib/rubocop/cop/rspec/multiple_expectations.rb | 4 ++-- lib/rubocop/cop/rspec/multiple_memoized_helpers.rb | 3 ++- lib/rubocop/cop/rspec/nested_groups.rb | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80b038f06..66fa709c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Master (Unreleased) - Add support for Unicode RIGHT SINGLE QUOTATION MARK in `RSpec/ExampleWording`. ([@jdufresne]) +- Suppress deprecation warning for `RSpec/MultipleExpectations`, `RSpec/MultipleMemoizedHelpers`, and `RSpec/NestedGroups` cops. ([@koic]) ## 3.0.2 (2024-07-02) diff --git a/lib/rubocop/cop/rspec/multiple_expectations.rb b/lib/rubocop/cop/rspec/multiple_expectations.rb index 2d51f218d..bb1a32297 100644 --- a/lib/rubocop/cop/rspec/multiple_expectations.rb +++ b/lib/rubocop/cop/rspec/multiple_expectations.rb @@ -67,13 +67,13 @@ module RSpec # end # class MultipleExpectations < Base - include ConfigurableMax - MSG = 'Example has too many expectations [%d/%d].' ANYTHING = ->(_node) { true } TRUE_NODE = lambda(&:true_type?) + exclude_limit 'Max' + # @!method aggregate_failures?(node) def_node_matcher :aggregate_failures?, <<~PATTERN (block { diff --git a/lib/rubocop/cop/rspec/multiple_memoized_helpers.rb b/lib/rubocop/cop/rspec/multiple_memoized_helpers.rb index e386c5c68..b15dba208 100644 --- a/lib/rubocop/cop/rspec/multiple_memoized_helpers.rb +++ b/lib/rubocop/cop/rspec/multiple_memoized_helpers.rb @@ -82,11 +82,12 @@ module RSpec # end # class MultipleMemoizedHelpers < Base - include ConfigurableMax include Variable MSG = 'Example group has too many memoized helpers [%d/%d]' + exclude_limit 'Max' + def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler return unless spec_group?(node) diff --git a/lib/rubocop/cop/rspec/nested_groups.rb b/lib/rubocop/cop/rspec/nested_groups.rb index 2529621ac..40e5aa2d8 100644 --- a/lib/rubocop/cop/rspec/nested_groups.rb +++ b/lib/rubocop/cop/rspec/nested_groups.rb @@ -92,7 +92,6 @@ module RSpec # end # class NestedGroups < Base - include ConfigurableMax include TopLevelGroup MSG = 'Maximum example group nesting exceeded [%d/%d].' @@ -103,6 +102,8 @@ class NestedGroups < Base "Configuration key `#{DEPRECATED_MAX_KEY}` for #{cop_name} is " \ 'deprecated in favor of `Max`. Please use that instead.' + exclude_limit 'Max' + def on_top_level_group(node) find_nested_example_groups(node) do |example_group, nesting| self.max = nesting