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

False positive of Style/RedundantLineContinuation #12862

Closed
r7kamura opened this issue Apr 23, 2024 · 0 comments · Fixed by #12867
Closed

False positive of Style/RedundantLineContinuation #12862

r7kamura opened this issue Apr 23, 2024 · 0 comments · Fixed by #12867
Labels

Comments

@r7kamura
Copy link
Contributor

Expected behavior

The following code should not be in violation because removing the backslash would change the meaning.

def foo
  return \
    "foo"
end

Actual behavior

It would violate Style/RedundantLineContinuation, then would be autocorrected to:

def foo
  return
  "foo"
end

Steps to reproduce the problem

Run rubocop on the example code above like this:

$ bundle exec rubocop -A example.rb

Offenses:

example.rb:2:9: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
  return 
        ^
example.rb:2:10: C: [Corrected] Style/RedundantLineContinuation: Redundant line continuation.
  return \ ...
         ^
example.rb:3:3: W: Lint/UnreachableCode: Unreachable code detected.
  "foo"
  ^^^^^
example.rb:3:5: C: [Corrected] Layout/IndentationConsistency: Inconsistent indentation detected.
    "foo"
    ^^^^^

1 file inspected, 4 offenses detected, 3 offenses corrected

RuboCop version

1.63.2 (using Parser 3.3.0.5, rubocop-ast 1.31.2, running on ruby 2.7.8) [x86_64-linux]
  - rubocop-capybara 2.18.0
  - rubocop-rails 2.9.1
  - rubocop-rspec 2.2.0
@koic koic added the bug label Apr 23, 2024
koic added a commit to koic/rubocop that referenced this issue Apr 24, 2024
…inuation`

Fixes rubocop#12862.

This PR fixes a false positive for `Style/RedundantLineContinuation`
when line continuations involve `return` with a return value.
koic added a commit that referenced this issue Apr 25, 2024
…ndant_line_continuation

[Fix #12862] Fix a false positive for `Style/RedundantLineContinuation`
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