42
我剛剛將RuboCop添加到rails項目並安裝了Sublime軟件包,以便在編輯器中查看RuboCop建議。我試圖弄清楚如何從80個字符改變最大行長度,或者完全忽略這個規則。RuboCop:行太長< - 如何忽略
我剛剛將RuboCop添加到rails項目並安裝了Sublime軟件包,以便在編輯器中查看RuboCop建議。我試圖弄清楚如何從80個字符改變最大行長度,或者完全忽略這個規則。RuboCop:行太長< - 如何忽略
在你的代碼,你可以禁用一堆線這樣的:
# rubocop:disable LineLength
puts "This line is lonnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnng"
# rubocop:enable LineLength
使用
目前或者添加到您的.rubocop.yml
文件,以增加最大長度:
Metrics/LineLength:
Max: 100
使用.rubocop.yml
文件,你有一大堆的選擇:
Metrics/LineLength:
# This will disable the rule completely, regardless what other options you put
Enabled: false
# Change the default 80 chars limit value
Max: 120
# If you want the rule only apply to a specific folder/file
Include:
- 'app/**/*'
# If you want the rule not to apply to a specific folder/file
Exclude:
- 'db/schema.rb'
我在哪裏可以把這個? – Abram
所以我複製這個文件https://github.com/bbatsov/rubocop/blob/master/config/default.yml,並作出改變,並重新啓動崇高,但仍然看到問題.. – Abram
啊,我看到我去了哪裏錯誤。我在'.rubocop.yml'中忘了''。現在開始工作了,謝謝! – Abram