问题描述
如何仅通过几个警察从命令行运行rubocop?
我可以为一个警察成功运行它:
rubocop --only Layout/HeredocIndentation
那行得通,但我想一次通过多个警察来运行它。我尝试了三种不同的变体,没有运气:
rubocop --only Rails/Blank --only Layout/HeredocIndentation --only Naming/FileName
rubocop --only Rails/Blank Layout/HeredocIndentation Naming/FileName
rubocop --only Rails/Blank,Layout/HeredocIndentation,Naming/FileName
https://docs.rubocop.org/rubocop/usage/basic_usage.html说:
--only | Run only the specified cop(s) and/or cops in the specified departments.
...但未提供语法示例。
我如何仅对几个警察(在命令行中给出)运行rubocop?
解决方法
要对命令行上指定的多个警察运行rubocop,请用逗号分隔警察,但不要留空格:
rubocop --only Rails/Blank,Layout/HeredocIndentation,Naming/FileName