Home > Software design >  Rails rubocop don't indent the block after multiple condition
Rails rubocop don't indent the block after multiple condition

Time:11-13

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

CodePudding user response:

Looking at Rubocop docs this seems to be the cop you are looking for:

Layout/IndentationWidth

CodePudding user response:

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

  • Related