-
-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split RSpec/FilePath
into RSpec/SpecFilePathSuffix
and RSpec/SpecFilePathFormat
#1698
Conversation
3c37bb7
to
4b8cfed
Compare
return unless top_level_groups.one? | ||
|
||
example_group_arguments(node) do |class_name, arguments| | ||
next if !class_name.const_type? || ignore_metadata?(arguments) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to the PR. It seems we’re completely ignoring class names in the string format.
RSpec.describe ‘MyClass’ do
Also, Would ‘const_type?’ return true for cbase?
add_global_offense(format(MSG, suffix: suffix)) | ||
end | ||
|
||
def ignore_metadata?(arguments) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to the PR.
I think it might be possible to use a trmplated node pattern instead of the two nested loops.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thank you so much!
Just one cosmetic note regarding parameter naming, and a few notes that we can turn into issues to work on in the future.
fc3d2d5
to
2ecf181
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thank you!
CHANGELOG.md
Outdated
@@ -3,6 +3,7 @@ | |||
## Master (Unreleased) | |||
|
|||
- Fix an infinite loop error when `RSpec/ExcessiveDocstringSpacing` finds a description with non-ASCII leading/trailing whitespace. ([@bcgraham]) | |||
- Split `RSpec/FilePath` into `RSpec/SpecFilePathSuffix` and `RSpec/SpecFilePathFormat`. ([@ydah]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remind people here that while the old RSpec/FilePath
cop was enabled by default, the two new cops are pending
and need to be explicitly enabled?
21507cf
to
6dd86e0
Compare
6dd86e0
to
e355885
Compare
…cFilePathFormat`
e355885
to
0bc0995
Compare
@bquorning Sorry for the delay. I updated this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thank you.
@@ -442,7 +442,7 @@ RSpec/ExpectOutput: | |||
|
|||
RSpec/FilePath: | |||
Description: Checks that spec file paths are consistent and well-formed. | |||
Enabled: true | |||
Enabled: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: The changelog reads that RSpec/FilePath
is "enabled by default" but it seems it isn't anymore.
Currently, users are forced to replace RSpec/FilePath
with their alternatives when upgrading a minor release from 2.23.0 to 2.24.0. Is this expected or do we consider this a breaking change? 🤔
Refs https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles/-/merge_requests/195
/cc @ydah @bquorning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can open an issue to continue the discussion if needed ❤️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please open an issue. I am not sure what is the preferred course of action – should we add the old cop back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ydah @bquorning I've moved the discussion to #1717.
`RSpec/SpecFilePath` was split into `RSpec/SpecFilePathFormat` and `RSpec/SpecFilePathSuffix` in `rubocop-rspec` 2.24.0. rubocop/rubocop-rspec#1698 The old cop was enabled by default but the new ones are not 🤷 See 4ormat/4ormat#17161
Fix: #1069
Before submitting the PR make sure the following are checked:
master
(if not - rebase it).CHANGELOG.md
if the new code introduces user-observable changes.bundle exec rake
) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).If you have created a new cop:
config/default.yml
.Enabled: pending
inconfig/default.yml
.Enabled: true
in.rubocop.yml
.VersionAdded: "<<next>>"
indefault/config.yml
.If you have modified an existing cop's configuration options:
VersionChanged: "<<next>>"
inconfig/default.yml
.