我想为VisualEditor存储库运行RuboCop。目前,我可以在存储库中找到的唯一 Ruby 文件是.docs/CustomTags.rb。
$ find . | grep rb
./.docs/CustomTags.rb
如果我只运行rubocop
,它不会找到任何文件:
$ rubocop
Inspecting 0 files
0 files inspected, no offenses detected
.docs
我猜它会忽略以点( )开头的文件夹中的文件。
关于包含文件的 RuboCop 文档说:
如果您希望它检查其他文件,您需要手动传递它们,或者在 AllCops/Include 下为它们添加条目。
如果我从命令行提供文件的路径,RuboCop 会找到该文件:
$ rubocop .docs/CustomTags.rb
Inspecting 1 file
W
(...)
1 file inspected, 26 offenses detected
我们的持续集成仅rubocop
针对存储库运行,因此我无法从命令行提供文件的路径。我必须使用AllCops/Include
,但我不知道该怎么做。
.rubocop.yml
如果我在存储库的根目录中创建一个:
AllCops:
Include:
- '.docs/CustomTags.rb'
并运行 Rubocop,它没有找到该文件:
$ rubocop
Inspecting 0 files
0 files inspected, no offenses detected
我尝试了该.rubocop.yml
文件的几种变体,包括:
AllCops:
Include:
- '**/CustomTags.rb'
和
AllCops:
Include:
- '.docs/**/*'
但是他们都没有找到该文件。