Rubocop excludes files configured in .rubocop.yml .
Rubocop checks .irbrc even though it's excludes in .rubocop.yml .
$ cat Gemfile
source 'https://rubygems.org'
gem 'nesty'
gem 'rubocop'
$ cat .rubocop.yml
AllCops:
Exclude:
- '**/vendor/**/*'
$ bundle install --path vendor/bundle
Using rake 12.0.0
Using ast 2.3.0
Using nesty 1.0.2
Using parallel 1.11.2
Using powerpack 0.1.1
Using ruby-progressbar 1.8.1
Using unicode-display_width 1.3.0
Using bundler 1.14.6
Using rainbow 2.2.2
Using parser 2.4.0.0
Using rubocop 0.49.1
Bundle complete! 2 Gemfile dependencies, 11 gems now installed.
Bundled gems are installed into ./vendor/bundle.
$ bundle exec rubocop
Inspecting 2 files
.C
Offenses:
vendor/bundle/ruby/2.3.0/gems/nesty-1.0.2/.irbrc:1:1: C: Prefer $LOAD_PATH over $:.
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), 'lib'))
^^
2 files inspected, 1 offense detected
$ bundle exec rubocop -V
0.49.1 (using Parser 2.4.0.0, running on ruby 2.3.3 x86_64-darwin15)
I'm no expert, but doesn't the double star glob need to match at least some sub-directory? I.e. it doesn't match the current directory? 馃
If you try:
ls **/vendor
from the same directory, do you get this?
ls: **/vendor: No such file or directory
@Drenmi I don't think the double star is supported by default in bash for example , but you can enable it with
shopt -s globstar
The problem here is that dot files aren't matched by the single star at the end of the pattern. You'd need the following to exlude dot files too:
AllCops:
Exclude:
- '**/vendor/**/*'
- '**/vendor/**/.*'
@jonas054: Oh. Maybe I enabled it way back and don't recall. Either way, if I'm in the root of, say, a Rails directory, and run:
ls **/app
I will get:
ls: **/app: No such file or directory
However, if I run:
ls **/models
it will list the files in app/models and spec/models.
@jonas054 's configuration solves the issue. (thanks!)
Apparently, **/vendor/**/* doesn't include dotfiles.
$ ls **/vendor/**/* | grep .irbrc
$ ls **/vendor/**/.* | grep .irbrc
vendor/bundle/ruby/2.3.0/gems/nesty-1.0.2/.irbrc
Adding '**/vendor/**/.*' line solves the issue.
@Drenmi Weird. You and I get different behaviors. I've tried in a Terminal running bash under Ubuntu Linux, and I get
master ~/dev/rubocop$ ls -d **/lib
lib
master ~/dev/rubocop$ ls -d **/style
lib/rubocop/cop/style spec/rubocop/cop/style
I used the pattern as follows and it worked for me.
vendor/*/
Rubocop version 0.50.0
Most helpful comment
@Drenmi I don't think the double star is supported by default in bash for example , but you can enable it with
The problem here is that dot files aren't matched by the single star at the end of the pattern. You'd need the following to exlude dot files too: