rubocop: Cannot exclude vendor/ folder

I’m using bundler, and all my gems are installed in projects_folder/vendor/ (including rubocop). I’ve been succesfully excluding folders, but somehow I’m not able to exclude the vendor folder. Maybe it has something to do with rubocop being in it???

I think I’ve tried everything, like

vendor/**
'**/vendor/**'
vendor/**/*

etc.

(furthermore: in the code in Rubocop::Config#match_path? I see that pattern can either be a string or a regex… but how to define a regex in the rubocop.yml?)

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 19 (5 by maintainers)

Commits related to this issue

Most upvoted comments

@bogdan8 Yes, the correct pattern for excluding all files under vendor recursively is vendor/**/*.

Is there a reason why vendor is not excluded by default?

I have to agree with @dmolesUC ; it’s pretty surprising to add an exclude directive to .rubocop.yml and have that result in files that were previous being excluded no longer being so. It’s true that after reading about it and reasoning about it you can totally understand how it works, but it’s pretty confusing when you first encounter it.

I filed an issue to merge Exclude: by default, I believe that is always the intention for RuboCop users: #9325

👍 on merging Exclude: should be the default, who doesn’t want that?

OK, I’ve been using RuboCop for six years and this is the first time I’ve heard of inherit_mode — I see it wasn’t in the README back in the day.

Personally I think Exclude should default to merge, but failing that, maybe it should be documented more prominently – or the fact that without it adding any custom Exclude will lose the defaults should be called out more explicitly. Given the special behavior of Include and Exclude with regard to shadowing in subdirectories, it’s not entirely intuitive.

Is there a reason why vendor is not excluded by default?

I agree it probably should. I’ll try to remember to do that when I tackle #7819; you may want to subscribe to that thread.