-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Strange(wrong?) behavior with Exclude and inherit_from #3960
Comments
Is this a dupe of #3744? |
@mikegee I'm on my phone right now, but at first glance it might be. I'll check when I get back to my desk.
|
The behavior is intended, and the explanation can be found here: https://github.com/bbatsov/rubocop/blob/v0.47.1/lib/rubocop/config.rb#L266-L270 I can see how this might be confusing, but is there a better way? |
@jonas054 Some special handling for files like The problem is, is there any way currently to make the above scenario work? Or do you just have to not use inheritance? There should at least be some way to fix it IMO. |
@mordocai The workaround solution is to specify the paths relative to the project base, i.e. I expect that people may want to use the feature of realtive-to-current-dir-paths in inherited files, but as you say, this is not always the wanted behavior. I think we could let the paths be relative to the configuration file's directory in all files beginning with |
Thanks @jonas054! I tried the workaround and it isn't working for me. I imagine I'm doing it wrong. I updated
And now the exclude doesn't work at all. Running |
@mordocai The path |
@jonas054 Right, that's the reason the issue was opened. So the workaround I was looking for was for there to be some way to have the path work from the project directory when inherited. For our use case the only other things I can think to fix our specific issue are:
|
Ah, it's flycheck. It's good that you have some ideas for solutions. I still think we should make a fix in RuboCop, as I proposed earlier:
|
Yeah, that sounds reasonable. |
Before this change, Include and Exclude paths in .rubocop.yml and .rubocop_todo.yml were taken as relative to the config file's directory. This extends that behavior to any file beginning with ".rubocop".
Setup
Make one "good behavior" setup.
mkdir test && cd test
mkdir blargh && echo '?x' > blargh/blah.rb
Make one "bad behavior" setup.
mkdir test-bad && cd test-bad
mkdir blargh && echo '?x' > blargh/blah.rb
Expected behavior
Running
rubocop
intest
,test-bad
,test/blargh
, andtest-bad/blargh
should all show no violations.Actual behavior
Running
rubocop
intest
,test-bad
, andtest/blargh
shows no violations. Running rubocop intest-bad/blargh
shows violations.RuboCop version
0.47.1 (using Parser 2.3.3.1, running on ruby 2.3.1 x86_64-linux)
Note
This is probably the root cause of rubocop/rubocop-emacs#24 (@johnfoley3 is my co-worker).
The text was updated successfully, but these errors were encountered: