Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong Layout/EmptyLineAfterGuardClause for returned heredoc with conditional #12221

Closed
alagos opened this issue Sep 26, 2023 · 0 comments · Fixed by #12222
Closed

Wrong Layout/EmptyLineAfterGuardClause for returned heredoc with conditional #12221

alagos opened this issue Sep 26, 2023 · 0 comments · Fixed by #12222
Labels

Comments

@alagos
Copy link

alagos commented Sep 26, 2023

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]
@koic koic added the bug label Sep 26, 2023
koic added a commit to koic/rubocop that referenced this issue Sep 26, 2023
…ardClause`

Fixes rubocop#12221.

This PR fixes a false positive for `Layout/EmptyLineAfterGuardClause`
when using `return` before guard condition with heredoc.
koic added a commit that referenced this issue Sep 27, 2023
…mpty_line_after_guard_clause

[Fix #12221] Fix a false positive for `Layout/EmptyLineAfterGuardClause`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants