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

Style/RedundantLineContinuation should not look inside strings #11758

Closed
bquorning opened this issue Apr 4, 2023 · 2 comments · Fixed by #11759
Closed

Style/RedundantLineContinuation should not look inside strings #11758

bquorning opened this issue Apr 4, 2023 · 2 comments · Fixed by #11759
Labels

Comments

@bquorning
Copy link
Contributor

When the trailing backslash is inside a string literal, I think it needs to be disregarded by the Style/RedundantLineContinuation cop.


Expected behavior

I expect these two spec examples to pass in spec/rubocop/cop/style/redundant_line_continuation_spec.rb:

expect_no_offenses(<<~'RUBY')
  "foo \
    bar"
RUBY

expect_no_offenses(<<~'RUBY')
  'foo \
    bar'
RUBY

Actual behavior

The spec examples fail, suggesting to remove the trailing backslash.

Steps to reproduce the problem

See above.

RuboCop version

7c35167

@bquorning bquorning added the bug label Apr 4, 2023
@bquorning
Copy link
Contributor Author

cc @koic, @ydah

@koic
Copy link
Member

koic commented Apr 4, 2023

@bquorning Yeah, I've opened #11759 to fix the issue.

koic added a commit to koic/rubocop that referenced this issue Apr 4, 2023
…inuation`

Fixes rubocop#11758.

This PR fixes a false positive for `Style/RedundantLineContinuation`
when line continuations for string.
bbatsov pushed a commit that referenced this issue Apr 5, 2023
Fixes #11758.

This PR fixes a false positive for `Style/RedundantLineContinuation`
when line continuations for string.
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