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 for Style/RedundantLineContinuation #12797

Closed
marocchino opened this issue Mar 18, 2024 · 1 comment · Fixed by #12798
Closed

False positive for Style/RedundantLineContinuation #12797

marocchino opened this issue Mar 18, 2024 · 1 comment · Fixed by #12798
Labels

Comments

@marocchino
Copy link
Contributor

I found more edge case for this lint.


Expected behavior

No offence.

Actual behavior

$ ruby -e 'puts "a = b \\\n   || c"' | bundle exec rubocop --stdin test.rb --only Style/RedundantLineContinuation
Inspecting 1 file
C

Offenses:

test.rb:1:7: C: [Correctable] Style/RedundantLineContinuation: Redundant line continuation.
a = b \ ...
      ^

$ ruby -e 'puts "a = b \\\n  if c"' | bundle exec rubocop --stdin test.rb --only Style/RedundantLineContinuation
Inspecting 1 file
C

Offenses:

test.rb:1:7: C: [Correctable] Style/RedundantLineContinuation: Redundant line continuation.
a = b \ ...
      ^

$ ruby -e 'puts "a = b if c \\\n ||  d"' | bundle exec rubocop --stdin test.rb --only Style/RedundantLineContinuation
Inspecting 1 file
C

Offenses:

test.rb:1:12: C: [Correctable] Style/RedundantLineContinuation: Redundant line continuation.
a = b if c \ ...
           ^

Note that 1st, 2nd one maybe duplicate of #12793

Steps to reproduce the problem

see Actual behavior

RuboCop version

$ rubocop -V
1.62.1 (using Parser 3.3.0.5, rubocop-ast 1.31.2, running on ruby 3.1.3) [arm64-darwin22]
  - rubocop-capybara 2.20.0
  - rubocop-factory_bot 2.25.1
  - rubocop-performance 1.20.2
  - rubocop-rails 2.24.0
  - rubocop-rspec 2.27.1
@koic koic added the bug label Mar 19, 2024
koic added a commit to koic/rubocop that referenced this issue Mar 19, 2024
…nuation`

Fixes rubocop#12797.

This PR fixes false positives for `Style/RedundantLineContinuation`
when using line continuations with `&&` or `||` operator in assignment.
@koic
Copy link
Member

koic commented Mar 19, 2024

I've opened #12798. The case regarding if is likely to be fixed in #12793.

bbatsov pushed a commit that referenced this issue Mar 20, 2024
Fixes #12797.

This PR fixes false positives for `Style/RedundantLineContinuation`
when using line continuations with `&&` or `||` operator in assignment.
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