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

Invalid offense/autocorrect for Style/RedundantLineContinuation #12758

Closed
MartySixFifty opened this issue Mar 7, 2024 · 0 comments · Fixed by #12759
Closed

Invalid offense/autocorrect for Style/RedundantLineContinuation #12758

MartySixFifty opened this issue Mar 7, 2024 · 0 comments · Fixed by #12759
Labels

Comments

@MartySixFifty
Copy link

MartySixFifty commented Mar 7, 2024

Expected behavior

Not to flag the Style/RedundantLineContinuation offense.

Actual behavior

Offense is flagged and incorrectly autocorrected.

Steps to reproduce the problem

Input:

return unless params[:filter].present? && params[:show_inactive].present? \
  && params[:show_inactive] == 'true'

Is flagged as:

app/controllers/api/v1/organizations_controller.rb:401:83: C: [Correctable] Style/RedundantLineContinuation: Redundant line continuation.
        return unless params[:filter].present? && params[:show_inactive].present? \ ...

Autocorrects to:

return unless params[:filter].present? && params[:show_inactive].present?
  && params[:show_inactive] == 'true'

Then produces:

app/controllers/api/v1/organizations_controller.rb:402:11: F: Lint/Syntax: unexpected token tAMPER
(Using Ruby 3.3 parser; configure using TargetRubyVersion parameter, under AllCops)
          && params[:show_inactive] == 'true'
          ^

RuboCop version

$ [bundle exec] rubocop -V
1.62.0 (using Parser 3.3.0.5, rubocop-ast 1.31.1, running on ruby 3.3.0) [arm64-darwin23]
  - rubocop-rails 2.24.0
@koic koic added the bug label Mar 7, 2024
koic added a commit to koic/rubocop that referenced this issue Mar 7, 2024
Fixes rubocop#12758.

This PR fixes false positives for `Layout/RedundantLineBreak`
when using `&&` or `||` after a backslash newline.
koic added a commit to koic/rubocop that referenced this issue Mar 9, 2024
Fixes rubocop#12758.

This PR fixes false positives for `Layout/RedundantLineBreak`
when using `&&` or `||` after a backslash newline.
bbatsov pushed a commit that referenced this issue Mar 9, 2024
Fixes #12758.

This PR fixes false positives for `Layout/RedundantLineBreak`
when using `&&` or `||` after a backslash newline.
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