Skip to content

Wrong Layout/EmptyLineAfterGuardClause for returned heredoc with conditional #12221

@alagos

Description

@alagos

Expected behavior

No offense for this example

def foo(params)
  return true if <<-TEXT.length > 100
    bar #{params[:baz]}
  TEXT

  false
end

Actual behavior

Getting Layout/EmptyLineAfterGuardClause

┗ rubocop asdf.rb --debug
For /Users/alter: Default configuration from /Users/alter/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rubocop-1.50.1/config/default.yml
Use parallel by default.
Skipping parallel inspection: only a single file needs inspection
Inspecting 1 file
Scanning /Users/alter/asdf.rb
C

Offenses:

asdf.rb:1:1: C: [Correctable] Style/FrozenStringLiteralComment: Missing frozen string literal comment.
def foo(params)
^
asdf.rb:2:3: C: [Correctable] Layout/EmptyLineAfterGuardClause: Add empty line after guard clause.
  return true if <<-TEXT.length > 100
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1 file inspected, 2 offenses detected, 2 offenses autocorrectable
Finished in 0.15189099998679012 seconds

RuboCop version

┗ rubocop -V
1.50.1 (using Parser 3.2.2.0, rubocop-ast 1.28.0, running on ruby 3.1.2) [x86_64-darwin21]

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy