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 default config for sub-departments #1163
Conversation
f9fdf16
to
d3c48ae
Compare
@ShockwaveNN can you please check that this fix solves your case? # Gemfile
gem 'rubocop-rspec', github: 'rubocop/rubocop-rspec', branch: 'fix-config-for-nested-departments' |
@jonas054 Looks good? |
d3c48ae
to
9e84186
Compare
@pirj Can confirm, this do not broke my minitests |
9e84186
to
b7e8995
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.
Looks good as far as I can tell. 👍
Bump |
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 don't really understand the changes 🤷♂️ Please rebase anyway :)
b7e8995
to
880e01b
Compare
@Darhazer Rebased 👍 The explanation of the problem is in #1160 (comment)
RSpec/Rails:
Include:
- "**/*_spec.rb"
- "**/spec/**/*"
|
@@ -1,10 +1,10 @@ | |||
--- | |||
RSpec: | |||
Enabled: true | |||
Include: | |||
Include: &1 |
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.
It seems that this could be named, e.g. alphanumeric. Might make the file less scary, if it has proper names :)
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 vaguely recall I planned to do so (to mimic the well-known &default
from config/database.yml
😄), but ended up with numbers somehow. Fixed 👍
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, now I recall. It's bin/build_config
that does that:
--- a/config/default.yml
+++ b/config/default.yml
@@ -1,10 +1,10 @@
---
RSpec:
Enabled: true
- Include: &include
+ Include: &1
- "**/*_spec.rb"
- "**/spec/**/*"
- Language: &language
+ Language: &2
inherit_mode:
merge:
- Expectations
Supposedly, YAML.dump(unified_config)
has no respect for named anchors.
I'll revert, otherwise CI is red.
@@ -24,6 +25,8 @@ def dump | |||
|
|||
def unified_config | |||
cops.each_with_object(config.dup) do |cop, unified| | |||
next if SUBDEPARTMENTS.include?(cop) |
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.
so those are not really cops, but departments declarations. Nice
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.
Most of them are cops, but some are departments. It's because cops
partially comes from config.keys
. And we've included departments separately to config now.
a4f7a36
to
2e20ce1
Compare
It turns out that the default config does not apply for sub-departments. It is weird on many levels: - RSpec DSL configuration didn't work - - RSpec DSL doesn't work as intended anyway #1126 - if users would re-define RSpec DSL, they would have to do it for all sub-departments, as YAML defaults are only for the default config - if users would re-define RSpec DSL and use YAML defaults, too, the merging of the resulting config is undetermined Still, I believe having `Include` to work correctly is the most important. fixes #1160
dc71418
to
ed894a0
Compare
It turns out that the default config does not apply for sub-departments.
It is weird on many levels:
RSpec/Language
isn't merging properly #1126Still, I believe having
Include
to work correctly is the most important.fixes #1160
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).