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
Defining cops' include
/exclude
overwrites department configuration (and there's no way to merge them)
#9983
Comments
I don't think it's related to #9952 as the issue is still reproducible using the steps given. I would like to give a bit more details of our setup and our particular use-case. We currently use:
rswag uses a DSL written on top of RSpec to describe requests tests. We do not want to run That being said, what we would like to have (but doesn't currently work) is: our_gem's RSpec:
Enabled: true
Excludes:
- "spec/requests/**/*.rb" project's inherit_from: rubocop_todo.yml # line auto-added by rubocop auto-gen-conf
inherit_gem:
our_gem: rubocop.yml project's # ... some comments added automatically ...
RSpec/LetSetup:
# note: rubocop auto-gen-conf does not populate Excludes with anything from `spec/requests` (which is expected)
Excludes:
- spec/controllers/foo_controller.rb With this particular setup, if we run For this reason, as a temporary workaround we are not defining excludes at RSpec department level anymore: Over-haul/rubocop-overhaul#24 |
@Drowze I commented on that rswag issue, but it should be possible to use rubocop-rspec now with it's configurable syntax. That's not really the point of this issue, but I thought I'd mention it. I still think the fix in #9624 may solve your problem. Can you try checking out the branch from that PR and running it against your code? |
@dvandersluis checking out to #9624 unfortunately did not fix anything for me. Using example from first post
Using inherit_gem/rubocop_todo/etc
|
A problem I see here is that it's not entirely clear what we mean by inheritance in RuboCop. (1): A cop's parameter overrides the same cop parameter in another file. We reference that other file with (2): A cop's parameter overrides the cop's department's value for the same parameter in the same file or in another file. This is actually not called inheritance in the documentation (as far as I could see), and But maybe it's reasonable to call (2) inheritance too, and to let |
Expected behavior
I expect that when I define
inherit_mode.merge = ['Exclude']
on myrubocop.yml
, the departmentexclude
configuration is merged with the individual cops'Exclude
. This should actually happen withInclude
too.Actual behavior
When I have an
Exclude
option configured at the department level, it is always overwritten on individual cops if they define anyExclude
themselves.Steps to reproduce the problem
Given test.rb:
And given a .rubocop.yml:
When I run
rubocop --debug --only Style/FrozenStringLiteralComment test.rb
I get:RuboCop version
The text was updated successfully, but these errors were encountered: