diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d3af2fe1..a2e5a2b60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ * Add `NegatedMatcher` configuration option to `RSpec/ChangeByZero`. ([@ydah][]) * Add new `RSpec/Capybara/SpecificFinders` cop. ([@ydah][]) * Add support for numblocks to `RSpec/AroundBlock`, `RSpec/EmptyLineAfterHook`, `RSpec/ExpectInHook`, `RSpec/HookArgument`, `RSpec/HooksBeforeExamples`, `RSpec/IteratedExpectation`, and `RSpec/NoExpectationExample`. ([@ydah][]) +* Deprecate `IgnoredPatterns` option. ([@ydah][]) ## 2.12.1 (2022-07-03) diff --git a/config/default.yml b/config/default.yml index 8df64c7a6..3db519952 100644 --- a/config/default.yml +++ b/config/default.yml @@ -792,9 +792,10 @@ RSpec/VariableName: SupportedStyles: - snake_case - camelCase + AllowedPatterns: [] IgnoredPatterns: [] VersionAdded: '1.40' - VersionChanged: '1.43' + VersionChanged: '2.13' Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/VariableName RSpec/VerifiedDoubleReference: diff --git a/config/obsoletion.yml b/config/obsoletion.yml new file mode 100644 index 000000000..38f27529a --- /dev/null +++ b/config/obsoletion.yml @@ -0,0 +1,14 @@ +# +# Configuration of obsolete/deprecated cops used by `ConfigObsoletion`. +# +# See: https://docs.rubocop.org/rubocop/extensions.html#config-obsoletions +# + +# Cop parameters that have been changed +# Can be treated as a warning instead of a failure with `severity: warning` +changed_parameters: + - cops: + - RSpec/VariableName + parameters: IgnoredPatterns + alternative: AllowedPatterns + severity: warning diff --git a/docs/modules/ROOT/pages/cops_rspec.adoc b/docs/modules/ROOT/pages/cops_rspec.adoc index 4c4fb8317..5751d6f76 100644 --- a/docs/modules/ROOT/pages/cops_rspec.adoc +++ b/docs/modules/ROOT/pages/cops_rspec.adoc @@ -4504,12 +4504,12 @@ let('user_name') { 'Adam' } | Yes | No | 1.40 -| 1.43 +| 2.13 |=== Checks that memoized helper names use the configured style. -Variables can be excluded from checking using the `IgnoredPatterns` +Variables can be excluded from checking using the `AllowedPatterns` option. === Examples @@ -4540,20 +4540,20 @@ subject(:userName1) { 'Adam' } let(:userName2) { 'Adam' } ---- -==== IgnoredPatterns configuration +==== AllowedPatterns configuration [source,ruby] ---- # rubocop.yml # RSpec/VariableName: # EnforcedStyle: snake_case -# IgnoredPatterns: +# AllowedPatterns: # - ^userFood ---- [source,ruby] ---- -# okay because it matches the `^userFood` regex in `IgnoredPatterns` +# okay because it matches the `^userFood` regex in `AllowedPatterns` subject(:userFood_1) { 'spaghetti' } let(:userFood_2) { 'fettuccine' } ---- @@ -4567,6 +4567,10 @@ let(:userFood_2) { 'fettuccine' } | `snake_case` | `snake_case`, `camelCase` +| AllowedPatterns +| `[]` +| Array + | IgnoredPatterns | `[]` | Array diff --git a/lib/rubocop-rspec.rb b/lib/rubocop-rspec.rb index 58536e7b5..b1ae4329c 100644 --- a/lib/rubocop-rspec.rb +++ b/lib/rubocop-rspec.rb @@ -5,6 +5,7 @@ require 'rubocop' +require_relative 'rubocop/rspec' require_relative 'rubocop/rspec/version' require_relative 'rubocop/rspec/inject' require_relative 'rubocop/rspec/node' diff --git a/lib/rubocop/cop/rspec/variable_name.rb b/lib/rubocop/cop/rspec/variable_name.rb index 652942381..ae5563c1d 100644 --- a/lib/rubocop/cop/rspec/variable_name.rb +++ b/lib/rubocop/cop/rspec/variable_name.rb @@ -5,7 +5,7 @@ module Cop module RSpec # Checks that memoized helper names use the configured style. # - # Variables can be excluded from checking using the `IgnoredPatterns` + # Variables can be excluded from checking using the `AllowedPatterns` # option. # # @example EnforcedStyle: snake_case (default) @@ -26,21 +26,21 @@ module RSpec # subject(:userName1) { 'Adam' } # let(:userName2) { 'Adam' } # - # @example IgnoredPatterns configuration + # @example AllowedPatterns configuration # # rubocop.yml # # RSpec/VariableName: # # EnforcedStyle: snake_case - # # IgnoredPatterns: + # # AllowedPatterns: # # - ^userFood # # @example - # # okay because it matches the `^userFood` regex in `IgnoredPatterns` + # # okay because it matches the `^userFood` regex in `AllowedPatterns` # subject(:userFood_1) { 'spaghetti' } # let(:userFood_2) { 'fettuccine' } # class VariableName < Base include ConfigurableNaming - include IgnoredPattern + include AllowedPattern include Variable MSG = 'Use %