轨道 rubocop 在多个条件后不缩进块



代码如下:

db_table
.where('some condition')
.joins('another table')
.find_each do |table_record|
puts table_record.name
end

是否有允许在do之后添加缩进的rubocop规则?

db_table
.where('some condition')
.joins('another table')
.find_each do |table_record|
puts table_record.name
end
查看Rubocop文档这似乎就是你要找的警察:

布局/缩进宽度

这在rubocop.yml中帮助我

Layout/BlockAlignment:
EnforcedStyleAlignWith: start_of_block

它迫使我移动最后一个end:

db_table
.where('some condition')
.joins('another table')
.find_each do |table_record|
puts table_record.name
end

然后用rubocop力进行压痕

最新更新