[QA] How to make RuboCop inspect a file in a folder that starts with dot

Antoine Musso hashar+wmf at free.fr
Thu Oct 23 14:32:41 UTC 2014


Le 23/10/2014 13:17, Željko Filipin a écrit :
> If you are familiar with RuboCop, I could use some help.
> 
> http://stackoverflow.com/q/26508803/17469
> 
> Željko

That is an issue in rubocop.  It traverses the tree hierarchy using:

  Dir["somepath/**/*"]

Which is the equivalent of:

  Dir.glob( "somepath/**/*", 0 )

0 is the flag parameter which be made File::FNM_DOTMATCH to match
dotfiles (including '.' and '..'. So the Dir[] needs to be rewritten to
something like:

 Dir.glob("somepath/**/*", File::FNM_DOTMATCH)

And skip '.' and '..'.

Related code is target_files_in_dir method:

https://github.com/bbatsov/rubocop/blob/master/lib/rubocop/target_finder.rb#L58


The actual filtering via Include/Exclude, happens AFTER the tree
traversal (by invoking file_to_include?(file).  So whatever you put in
the config file, it is never going to find dotfiles.

-- 
Antoine "hashar" Musso




More information about the QA mailing list