Skip to content

Add Layout::EmptyLineAfterGuardClause for improved readability #327

@mrbongiolo

Description

@mrbongiolo

Not sure if this is the correct place to make a suggestion, but it would be good to have RuboCop::Cop::Layout::EmptyLineAfterGuardClause enabled.
Personally, I've always favored empty lines for code organization and context management, this rule helps with code readability as it makes it clearer which lines or "blocks" are "breaking" earlier.

Examples from Rubocop docs:

# bad
def foo
  return if need_return?
  bar
end

# good
def foo
  return if need_return?

  bar
end

# good
def foo
  return if something?
  return if something_different?

  bar
end

# also good
def foo
  if something?
    do_something
    return if need_return?
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions