简体   繁体   English

Rails rubocop 在多个条件后不缩进块

[英]Rails rubocop don't indent the block after multiple condition

The code looks like this:代码如下所示:

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

Is there a rubocop rule that allows you to add indent after do ?是否有 rubocop 规则允许您在do之后添加缩进?

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

Looking at Rubocop docs this seems to be the cop you are looking for:查看 Rubocop 文档,这似乎是您正在寻找的警察:

Layout/IndentationWidth 布局/缩进宽度

This in rubocop.yml helps me rubocop.yml 中的这个对我有帮助

Layout/BlockAlignment:
  EnforcedStyleAlignWith: start_of_block

It forced me to move last end :它迫使我最后移动end

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

and then rubocop force to use indentation然后 rubocop 强制使用缩进

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM