How do you configure Rubocop to display rule when running

时间:2016-07-11 21:39:34

标签: ruby-on-rails ruby rubocop

It seems like, instead of the SUPER helpful Offense/Concern/Warning sytax like:

C: Use delete instead of gsub.

It could display:

C: Use delete instead of gsub. Cop name: [Whatever it's upset about]

So you could disable the thing without another hour of googling the ungooglable.

I've googled this for a while now and have yet to find the answer in the 4,200 questions this excellent linter has generated.

2 个答案:

答案 0 :(得分:2)

要在输出中显示警察名称,您可以使用--display-cop-names或简称-D

示例:

$ bundle exec rubocop -D tmp.rb
Inspecting 1 file
C

Offenses:

tmp.rb:1:6: C: Style/MethodCallParentheses: Do not use parentheses for method calls with no arguments.
hello()
     ^

答案 1 :(得分:-1)

be rubocop --dedbug

That sort of does it... you can toss a file name in there as well

be rubocop app/models/ihaterubocop.rb --dedbug