Abr*_*ram 73 ruby ruby-on-rails sublimetext3 rubocop
我刚刚将RuboCop添加到rails项目中并安装了Sublime软件包以在编辑器中查看RuboCop建议.我试图弄清楚如何从80个字符更改最大行长度,或者完全忽略规则.
目前正在使用中:
Sté*_*ert 108
在您的代码中,您可以禁用一堆这样的行:
# rubocop:disable LineLength
puts "This line is lonnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnng"
# rubocop:enable LineLength
Run Code Online (Sandbox Code Playgroud)
或者将其添加到您的.rubocop.yml文件中以增加最大长度:
Metrics/LineLength:
Max: 100
Run Code Online (Sandbox Code Playgroud)
Alt*_*gos 59
在项目的根目录中创建一个.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'
Run Code Online (Sandbox Code Playgroud)
随着 2019 年 12 月 18 日 rubocop gem 版本 0.78.0 的最新更改,从现在开始,LineLength cop 从指标部门转移到布局部门。所以基本上,如果有人需要使用高于 0.78.0 的版本号禁用长行,应该这样做。
# rubocop:disable Layout/LineLength
"I'm a really long line"
# rubocop:enable Layout/LineLength
Run Code Online (Sandbox Code Playgroud)
配置也.rubocop.yml改为这样。
Layout/LineLength:
Max: 100
Run Code Online (Sandbox Code Playgroud)
要查看 rubocop 更改日志,请单击此处
| 归档时间: |
|
| 查看次数: |
32568 次 |
| 最近记录: |