-
-
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
Fix an error when using RSpec/FilePath
and revert to enabled by default
#1718
Conversation
It appears that Danger is failing because GITHUB_TOKEN does not have write permission. https://github.com/rubocop/rubocop-rspec/settings/actions |
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.
Thank you!
On the surface, that seems a bit dangerous. Isn’t is possible to use a token with fewer permissions. |
Is Danger trying to tell us that we’re introducing a cop in Enabled status? wondering if there’s an option to tell danger not to post PR comments but rather just dump their warnings to stdout for inspection |
CHANGELOG.md
Outdated
## 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]) | ||
- **(Breaking)** 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]) |
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 am confused. Isn't RSpec/FilePath
now enabled by default again? 🤔 If so, is this really a breaking change then? 🤓
- **(Breaking)** 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]) | |
- Split `RSpec/FilePath` into `RSpec/SpecFilePathSuffix` and `RSpec/SpecFilePathFormat`. `RSpec/FilePath` cop is enabled by default and the two new cops are pending and need to be enabled explicitly. ([@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.
Oh, sure, we'll enable it back for next version, but isn't it is breaking change for those who use v2.24.0?
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.
Perhaps we’re asking “does two breaking changes equal zero breaking changes”?
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.
Ah, I understand. Indeed it is.
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 updated this PR. How about it?
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.
Feedback: Our builds were actually broken twice by this two breaking changes.
https://danger.systems/ruby/ |
I suggest replacing Danger with a shell script file. We only use it to grep through the PR diff, should be doable, right? |
@rubocop/rubocop-rspec Danger replacement should be able to be done as a follow-up, so it would be nice to be able to merge and do a patch version release if there are no problems with this first. How about it? |
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.
Thank you!
RSpec/FilePath
and revert to enabled by defaultRSpec/FilePath
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.
Now when I think of this - why have we disabled the cop? Should we enable it again for those who don’t follow the brave ‘NewCops: true’ path? Can we split and remove the old cop in a major version, and meanwhile just keep those two new pending cops?
New cops would duplicate the function of the old one, but this is not a problem, is it?
RSpec/FilePath
RSpec/FilePath
and revert to enabled by default.
RSpec/FilePath
and revert to enabled by default.RSpec/FilePath
and revert to enabled by default
I had misunderstood the comment I received at #1718 (comment) . I changed it to |
Just for the reference #1717 (comment) i don’t think we need to disable FilePath until v3 (where we remove it). |
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.
Thank you!
This PR commits `RSpec/FilePath` to suppress the following offenses: ```console $ bundle exec rake internal_investigation (snip) Offenses: spec/rubocop/cop/internal_affairs/redundant_let_rubocop_config_new_spec.rb:3:1: C: RSpec/FilePath: Spec path should end with rubocop/cop/internal_affairs/redundant_let_rubo_cop_config_new*_spec.rb. RSpec.describe RuboCop::Cop::InternalAffairs::RedundantLetRuboCopConfigNew, :config do ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/rubocop/cop/mixin/enforce_superclass_spec.rb:3:1: C: RSpec/FilePath: Spec path should end with rubocop/cop/enforce_superclass*_spec.rb. RSpec.describe RuboCop::Cop::EnforceSuperclass, :restore_registry do ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/rubocop/formatter/junit_formatter_spec.rb:3:1: C: RSpec/FilePath: Spec path should end with rubocop/formatter/j_unit_formatter*_spec.rb. RSpec.describe RuboCop::Formatter::JUnitFormatter, :config do ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` https://app.circleci.com/pipelines/github/rubocop/rubocop/9942/workflows/0c732f10-f59d-45a9-be69-5af5ceb0c5d8/jobs/289057 The offenses are due to a change in RuboCop RSpec 2.24.1, and it will ignore the deprecated `RSpec/FilePath`. rubocop/rubocop-rspec#1718
I think I see regression with this and custom inflections in Zeitwerk. # config/initializers/zeitwerk.rb
Rails.autoloaders.each do |autoloader|
autoloader.inflector = Zeitwerk::Inflector.new
autoloader.inflector.inflect(
'bvd' => 'BvD'
)
end Every spec file that covers
It was not an issue neither for |
@timon I see no info that I can suggest to you to add some configuration. You've got the warning from
|
# 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. |
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 What is the suggested way to migrate?
I've updated my config like the following for 0.24.0
.
- Removed
RSpec/FilePath
- Disabled
RSpec/SpecFilePathFormat
- Enabled
RSpec/SpecFilePathSuffix
But this new change in 0.24.1
is forcing me to update my config again like the following.
- Add
RSpec/FilePath
back and disable it
Does that mean my config will be broken when RSpec/FilePath
is removed in the next major version update to 3.0?
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 understand your frustration with some reconfiguration required for a minor/patch level version dependency updates.
May I kindly ask you to elaborate what you mean by "forcing"?
You meant 2.24.0.
my config will be broken ... in the next major version update to 3.0?
Major updates often come with breaking changes, so most probably yes.
But worry not, we'll provide a detailed update checklist like we did with 1.x -> 2.x update.
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.
Thanks for responding to my question 🙏
May I kindly ask you to elaborate what you mean by "forcing"?
You meant 2.24.0.
- Before
2.24.0
: I hadRSpec/FilePath
explicitly disabled in my config. - At
2.24.0
: I had to removeRSpec/FilePath
completely from my config or the rubocop command would not exit with a successful status. - At
2.24.1
: Now I had to disableRSpec/FilePath
again or it would be enabled by default.
After updated the config twice in each of these two versions, I was a bit alerted by the words "plan for migration" and curious about what that actually means.
But on second thought, I think 2.24.1
just moved the state back to what we were at before 2.24.0
.
If I interpret what you said correctly, there will be no breaking changes like this until 3.0. But we probably will need to update the config when upgrading to 3.x, which is quite normal. Is my understanding correct?
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 see, thanks for the explanation. And please accept my apologies for introducing breaking changes.
Your understanding is correct.
Fix: #1717
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
.