Rubocop: Feature request: empty line after early return

Created on 2 Jan 2018  路  2Comments  路  Source: rubocop-hq/rubocop

It would be nice to have a cop that enforces consistent usage of empty lines after early returns.
Example:

 def on_block(node)
  return unless style == :method_call
  add_offense(node) if expect_change_with_block?(node)
end

Here the cop would require adding a blank line after the return.

Note: it's possible tho have multiple consecutive return statements with different conditions. In that case I would suggest adding the blank line after the last return.

feature request

Most helpful comment

Yeah, that makes perfect sense to me. It's an extremely common style of coding, practiced by myself as well.

All 2 comments

Yeah, that makes perfect sense to me. It's an extremely common style of coding, practiced by myself as well.

I have had this on my list for a while, but I imagine an EmptyLinesAroundGuardClause, which would cover things like next as well. 馃檪

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ecbrodie picture ecbrodie  路  3Comments

benoittgt picture benoittgt  路  3Comments

lepieru picture lepieru  路  3Comments

AndreiMotinga picture AndreiMotinga  路  3Comments

bquorning picture bquorning  路  3Comments