From c3d53d9f99bcd74df3a3da1357842c0509cad3f7 Mon Sep 17 00:00:00 2001 From: ydah <13041216+ydah@users.noreply.github.com> Date: Sat, 23 Sep 2023 10:41:36 +0900 Subject: [PATCH] Fix an error when using `RSpec/FilePath` and revert to enabled by default --- .rubocop.yml | 3 +++ CHANGELOG.md | 4 +++- config/default.yml | 2 +- config/obsoletion.yml | 6 ------ docs/modules/ROOT/pages/cops_rspec.adoc | 8 +++++++- lib/rubocop/cop/rspec/file_path.rb | 6 ++++++ 6 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 45f747410..1412e6432 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -98,6 +98,9 @@ RSpec/ExampleLength: - heredoc Max: 11 +RSpec/FilePath: + Enabled: false + RSpec/DescribeClass: Exclude: - spec/project/**/*.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index ae7fd53a8..550ab9706 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,11 @@ ## Master (Unreleased) +- Fix an error when using `RSpec/FilePath` and revert to enabled by default. If you have already moved to `RSpec/SpecFilePathSuffix` and `RSpec/SpecFilePathFormat`, disable `RSpec/FilePath` explicitly as `Enabled: false`. The `RSpec/FilePath` before migration and the `RSpec/SpecFilePathSuffix` and `RSpec/SpecFilePathFormat` as the target are available respectively. ([@ydah]) + ## 2.24.0 (2023-09-08) -- Split `RSpec/FilePath` into `RSpec/SpecFilePathSuffix` and `RSpec/SpecFilePathFormat`. `RSpec/FilePath` cop is enabled by default, the two new cops are pending and need to be enabled explicitly. ([@ydah]) +- Split `RSpec/FilePath` into `RSpec/SpecFilePathSuffix` and `RSpec/SpecFilePathFormat`. `RSpec/FilePath` cop is disabled by default and the two new cops are pending and need to be enabled explicitly. ([@ydah]) - Add new `RSpec/Eq` cop. ([@ydah]) - Add `RSpec/MetadataStyle` and `RSpec/EmptyMetadata` cops. ([@r7kamura]) - Add support `RSpec/Rails/HttpStatus` when `have_http_status` with string argument. ([@ydah]) diff --git a/config/default.yml b/config/default.yml index c64854586..f5e731437 100644 --- a/config/default.yml +++ b/config/default.yml @@ -448,7 +448,7 @@ RSpec/ExpectOutput: RSpec/FilePath: Description: Checks that spec file paths are consistent and well-formed. - Enabled: false + Enabled: true Include: - "**/*_spec*rb*" - "**/spec/**/*" diff --git a/config/obsoletion.yml b/config/obsoletion.yml index 0a5a771fd..d38b0a973 100644 --- a/config/obsoletion.yml +++ b/config/obsoletion.yml @@ -27,9 +27,3 @@ renamed: RSpec/FactoryBot/FactoryClassName: FactoryBot/FactoryClassName RSpec/FactoryBot/FactoryNameStyle: FactoryBot/FactoryNameStyle RSpec/FactoryBot/SyntaxMethods: FactoryBot/SyntaxMethods - -split: - RSpec/FilePath: - alternatives: - - RSpec/SpecFilePathFormat - - RSpec/SpecFilePathSuffix diff --git a/docs/modules/ROOT/pages/cops_rspec.adoc b/docs/modules/ROOT/pages/cops_rspec.adoc index 58de73def..567123a5b 100644 --- a/docs/modules/ROOT/pages/cops_rspec.adoc +++ b/docs/modules/ROOT/pages/cops_rspec.adoc @@ -2003,7 +2003,7 @@ expect { my_app.print_report }.to output('Hello World').to_stdout |=== | Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed -| Disabled +| Enabled | Yes | No | 1.2 @@ -2012,6 +2012,12 @@ expect { my_app.print_report }.to output('Hello World').to_stdout Checks that spec file paths are consistent and well-formed. +This cop is deprecated. +We plan to remove it in the next major version update to 3.0. +The migration targets are `RSpec/SpecFilePathSuffix` +and `RSpec/SpecFilePathFormat`. +If you are using this cop, please plan for migration. + By default, this checks that spec file paths are consistent with the test subject and enforces that it reflects the described class/module and its optionally called out method. diff --git a/lib/rubocop/cop/rspec/file_path.rb b/lib/rubocop/cop/rspec/file_path.rb index c8c104fb1..f66e22b34 100644 --- a/lib/rubocop/cop/rspec/file_path.rb +++ b/lib/rubocop/cop/rspec/file_path.rb @@ -5,6 +5,12 @@ module Cop module RSpec # Checks that spec file paths are consistent and well-formed. # + # This cop is deprecated. + # We plan to remove it in the next major version update to 3.0. + # The migration targets are `RSpec/SpecFilePathSuffix` + # and `RSpec/SpecFilePathFormat`. + # If you are using this cop, please plan for migration. + # # By default, this checks that spec file paths are consistent with the # test subject and enforces that it reflects the described # class/module and its optionally called out method.