Željko Filipin
Željko Filipin

Reputation: 57262

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

I want to run RuboCop for VisualEditor repository. At the moment, the only Ruby file I could find in the repository is .docs/CustomTags.rb.

$ find . | grep rb
./.docs/CustomTags.rb

If I run only rubocop, it does not find any files:

$ rubocop
Inspecting 0 files
0 files inspected, no offenses detected

I guess it ignores files in folders that start with dot (.docs).

RuboCop documentation on including files says:

If you'd like it to check other files you'll need to manually pass them in, or to add entries for them under AllCops/Include.

If I provide path to the file from the command line, RuboCop finds the file:

$ rubocop .docs/CustomTags.rb 
Inspecting 1 file
W
(...)
1 file inspected, 26 offenses detected

Our continuous integration just runs rubocop for the repository, so I can not provide path to the file from the command line. I have to use AllCops/Include, but I can not figure out how to do it.

If I create a .rubocop.yml in the root of the repository:

AllCops:
  Include:
    - '.docs/CustomTags.rb'

and run Rubocop, it does not find the file:

$ rubocop
Inspecting 0 files
0 files inspected, no offenses detected

I have tried several variations of the .rubocop.yml file, including:

AllCops:
  Include:
    - '**/CustomTags.rb'

and

AllCops:
  Include:
    - '.docs/**/*'

But none of them are finding the file.

Upvotes: 2

Views: 9542

Answers (1)

Željko Filipin
Željko Filipin

Reputation: 57262

It was a bug in RuboCop. It is fixed now, but the gem with the fix is not released yet.

Upvotes: 2

Related Questions