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

Version 2.3.1+ doesn't seem to respect "inherit_mode" #122

Closed
lucascaton opened this issue Sep 1, 2019 · 9 comments · Fixed by #189
Closed

Version 2.3.1+ doesn't seem to respect "inherit_mode" #122

lucascaton opened this issue Sep 1, 2019 · 9 comments · Fixed by #189

Comments

@lucascaton
Copy link

lucascaton commented Sep 1, 2019

Expected behavior

Since rubocop-rails 2.3.1 (also tested with 2.3.2), Rubocop is complaining about some offenses that should be ignored by default (node_modules/node-sass/src/libsass/contrib/libsass.spec) for example.

rubocop-rails 2.3.0 and previous versions didn't have this issue and I believe it started after this change.

Actual behavior

As I'm using inherit_mode, Rubocop shouldn't raise any offenses:

inherit_mode:
  merge:
    - Exclude

However, it does (after updating rubocop-rails), please see the following example.

Steps to reproduce the problem

This is my .rubocop.yml:

inherit_from: .rubocop_todo.yml

require:
  - rubocop-performance
  - rubocop-rails
  - rubocop-rspec

inherit_mode:
  merge:
    - Exclude

AllCops:
  TargetRubyVersion: 2.6

  Exclude:
    - 'db/schema.rb'

Rails:
  Enabled: true

# etc...

In order to reproduce the issue:

rubocop # with rubocop-rails 2.3.0
# 270 files inspected, no offenses detected

rubocop # with rubocop-rails 2.3.1
# 270 files inspected, 54 offenses detected

RuboCop version

$ [bundle exec] rubocop -V
0.74.0 (using Parser 2.6.4.0, running on ruby 2.6.4 x86_64-darwin18)

Please let me know if I can provide more info in order to help. Thank you.

@lucascaton lucascaton changed the title 2.3.1 "rubocop-rails" 2.3.1 doesn't seem to respect "inherit_mode" Sep 1, 2019
@lucascaton lucascaton changed the title "rubocop-rails" 2.3.1 doesn't seem to respect "inherit_mode" Version 2.3.1+ doesn't seem to respect "inherit_mode" Sep 1, 2019
@palkan
Copy link
Contributor

palkan commented Sep 20, 2019

Also faced this issue. Putting inherit_mode at the top of the .rubocop.yml doesn't help (or should it?)

@ghost
Copy link

ghost commented Oct 4, 2019

Hi there. Any news on this?

@ghost
Copy link

ghost commented Oct 15, 2019

I can confirm version 2.3.2 has the same bug.

@mpm
Copy link

mpm commented Nov 18, 2019

Same issue here. I have no clue about Rubocop extensions, but I suspect that the inherit_mode directive only applies to the the configuration stuff that is processed or directly referenced in your local .rubocop.yml?

So, if you would just use inherit_from and reference the config file from the gem, it would work.

But that is not possible, because it wouldn't load all the code for the necessary Cops.
So, when instead using require, the config file is loaded by rubocop-rails directly, so you cannot influence the inherit mode.

I suspect that merging the config happens somewhere here.

The merge only takes care of merging keys inside the hash, not the values of the keys (they are replaced). So, since the exclusion list is a list, it is just overriden...

I found this PR in Rubocop which seems to deal with this, maybe this interferes because a related method is monkey patched by rubocop-rails?

@ghost
Copy link

ghost commented Dec 7, 2019

I can confirm version 2.4.0 has the same bug.

koic added a commit to koic/rubocop-rails that referenced this issue Jan 17, 2020
Fixes rubocop#122.

`Exclude` defined in RuboCop core was not inherited.
https://github.com/rubocop-hq/rubocop/blob/v0.79.0/config/default.yml#L60-L64

This PR fixes `Exclude` paths that were not inherited.
This bug was caused by rubocop#108.
koic added a commit to koic/rubocop-rails that referenced this issue Jan 17, 2020
Fixes rubocop#122.

`Exclude` defined in RuboCop core was not inherited.
https://github.com/rubocop-hq/rubocop/blob/v0.79.0/config/default.yml#L60-L64

This PR fixes `Exclude` paths that were not inherited.
This bug was caused by rubocop#108.
@koic koic closed this as completed in #189 Jan 19, 2020
koic added a commit that referenced this issue Jan 19, 2020
[Fix #122] Fix `Exclude` paths that were not inherited
@lucascaton
Copy link
Author

Thanks @koic, but the issue still happens on version 2.4.1.
The steps to reproduce are the same as described in this issue description.

@koic
Copy link
Member

koic commented Jan 24, 2020

I will release RuboCop Rails 2.4.2 soon. It will be fixed in that version.

@lucascaton
Copy link
Author

Sorry @koic - I looked at the CHANGELOG and thought 2.4.1 included this fix. My bad 🤦‍♂️

@koic
Copy link
Member

koic commented Jan 26, 2020

FYI, RuboCop Rails 2.4.2 has been released. Thank you!
https://github.com/rubocop-hq/rubocop-rails/releases/tag/v2.4.2

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

Successfully merging a pull request may close this issue.

4 participants