Fix inherit_mode for third-party gems #1192
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #1126
See palkan/action_policy#103 (comment)
If a third-party gem, e.g.
action_policy
, defines theirconfig/default.yml
and supplements to the default RSpec DSL that we provide in ourconfig/default.yml
,rubocop
's behaviour is to actually override the configuration, asinherit_mode
isoverride
for lists by default.RuboCop has recently fixed the problem with ignored
inherit_mode
and we've bumped to userubocop
version that includes the fix, but we haven't adjusted ourconfig/default.yml
to merge by default.This is causing both user project RSpec DSL configuration and third-party gem RSpec DSL configuration to override our default, rendering our cops blind.
A little more context and reasoning for this fix palkan/action_policy#103 (comment)
Example
A new project
Ideally, both the duplicated
it_behaves_like
andsucceed
should be detected. However,action_policy
'sIncludes/Examples
setting overrides ours, andit_behaves_like
disappears from this list. As a result,rubocop
only detects the duplication ofsucceed
, but not ofit_behaves_like
.References
RSpec DSL configuration ticket #333
RSpec DSL configuration PR #956
Problem with merging #1126
Fix for ignored
inherit_mode
rubocop/rubocop#9952#1181
https://docs.rubocop.org/rubocop/1.0/configuration.html#merging-arrays-using-inherit_mode
https://docs.rubocop.org/rubocop/1.9/configuration.html#unusual-files-that-would-not-be-included-by-default
Documentation for third-party gems to work with
rubocop-rspec
https://docs.rubocop.org/rubocop-rspec/third_party_rspec_syntax_extensions.html#1077
Example third-party gem RSpec DSL configuration palkan/action_policy#138
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).