False positive of `Style/RedundantLineContinuation`
r7kamura opened this issue · comments
Ryo Nakamura commented
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