简体   繁体   中英

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 ?

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:

Layout/IndentationWidth

This in rubocop.yml helps me

Layout/BlockAlignment:
  EnforcedStyleAlignWith: start_of_block

It forced me to move last 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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