Skip to content
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

DisabledByDefault doesn't appear to merge properly #2467

Closed
thommay opened this issue Dec 1, 2015 · 3 comments
Closed

DisabledByDefault doesn't appear to merge properly #2467

thommay opened this issue Dec 1, 2015 · 3 comments

Comments

@thommay
Copy link

thommay commented Dec 1, 2015

given a config file:

inherit_gem:
  rubocop: config/default.yml

AllCops:
  DisabledByDefault: true

I'd expect all cops to be disabled, however the default set of cops is applied:

11:00 ~/code/rubocop % be bin/rubocop -c /Users/thom/work/chefstyle/config/chefstyle.yml /Users/thom/work/chefstyle -f simple
[...]
6 files inspected, 51 offenses detected

Removing the inherit_gem section correctly results in no cops being applied:

1:01 ~/code/rubocop % be bin/rubocop -c /Users/thom/work/chefstyle/config/chefstyle.yml /Users/thom/work/chefstyle -f simple
6 files inspected, no offenses detected
@thommay
Copy link
Author

thommay commented Dec 1, 2015

Rubocop from current git master:

11:08 ~/code/rubocop % be bin/rubocop -V                               [master]
0.35.1 (using Parser 2.2.3.0, running on ruby 2.2.3 x86_64-darwin15)

@jonas054
Copy link
Collaborator

This is what happens. You load configuration from the rubocop gem where AllCops:DisabledByDefault is false. This value is then overridden by your local setting DisabledByDefault: true. The default configuration is then merged with your user configuration, and since DisabledByDefault if true, the default configuration is disabled and your user configuration is enabled.

The thing you might have missed is that user configuration is everything in your .rubocop.yml, including configuration that you excplicitly inherit from, in this case from the rubocop gem. The default configuration is defined by config/default.yml in the rubocop you're running, which may or may not be the same as the gem. Either way, it's two configurations.

I think it better if we make rubocop fail when inherit_gem uses the rubocop gem, because it makes no sense to inherit that way. It only causes confusion.

@alexdowad
Copy link
Contributor

OK, just pushed a commit which implements @jonas054's suggestion. Let's see what @bbatsov says about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants