Skip to content

Rubocop cop Layout/EmptyLineAfterGuardClause not working properly #178

@danarnold

Description

@danarnold

The Rubocop cop Layout/EmptyLineAfterGuardClause appears to trigger with slim-lint for every guard clause, regardless of whether there's an empty line after it or not.

Example:

test.html.slim

- arr = [1, 2, 3]
- arr.each do |e|
  - next if e == 2

  = e
$ bundle exec slim-lint test.html.slim
test.html.slim:3 [W] RuboCop: Layout/EmptyLineAfterGuardClause: Add empty line after guard clause.

Adding an empty code line doesn't fix it either, but just adds another warning:

- arr = [1, 2, 3]
- arr.each do |e|
  - next if e == 2
  -
  = e
$ bundle exec slim-lint test.html.slim
test.html.slim:3 [W] RuboCop: Layout/EmptyLineAfterGuardClause: Add empty line after guard clause.
test.html.slim:4 [W] EmptyControlStatement: Empty control statement can be removed

Versions:
slim-lint 0.27.0
rubocop 1.63.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions