【问题标题】:How to make RuboCop inspect a file in a folder that starts with dot如何让 RuboCop 检查以点开头的文件夹中的文件
【发布时间】:2014-10-22 13:38:22
【问题描述】:

我想为VisualEditor 存储库运行RuboCop。目前,我可以在存储库中找到的唯一 Ruby 文件是 .docs/CustomTags.rb

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

如果我只运行rubocop,它不会找到任何文件:

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

我猜它会忽略以点 (.docs) 开头的文件夹中的文件。

including files 上的 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/**/*'

但他们都没有找到文件。

【问题讨论】:

标签: ruby rubocop


【解决方案1】:

这是一个bug in RuboCop。现已修复,但修复的 gem 尚未发布。

【讨论】:

  • 看起来它已在 Rubocop 版本 0.27.1 中修复。
猜你喜欢
  • 1970-01-01
  • 2023-03-06
  • 2015-04-06
  • 2022-06-12
  • 1970-01-01
  • 2017-11-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多