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 #12793

Closed
mkllnk opened this issue Mar 15, 2024 · 0 comments · Fixed by #12810
Closed

False positive of Style/RedundantLineContinuation #12793

mkllnk opened this issue Mar 15, 2024 · 0 comments · Fixed by #12810
Labels

Comments

@mkllnk
Copy link

mkllnk commented Mar 15, 2024

Expected behavior

The following code is correct:

        ids = managed_permitted_ids | hubs_permitted_ids | hubs_permitting_ids \
          | producers_permitted_ids | producers_permitting_ids | managed_active_ids \
          | hubs_active_ids | producers_active_ids
          filter_scope("spree_orders.completed_at >= ?", params.completed_at_gt) \
            if params.completed_at_gt.present?
          filter_scope("spree_orders.completed_at <= ?", params.completed_at_lt) \
            if params.completed_at_lt.present?

Actual behavior

This is corrected to invalid code:

        ids = managed_permitted_ids | hubs_permitted_ids | hubs_permitting_ids \
          | producers_permitted_ids | producers_permitting_ids | managed_active_ids 
          | hubs_active_ids | producers_active_ids
          filter_scope("spree_orders.completed_at >= ?", params.completed_at_gt) 
            if params.completed_at_gt.present?
          filter_scope("spree_orders.completed_at <= ?", params.completed_at_lt) 
            if params.completed_at_lt.present?

Steps to reproduce the problem

Run Rubocop on the examples above.

RuboCop version

$ [bundle exec] rubocop -V
1.62.1 (using Parser 3.3.0.5, rubocop-ast 1.31.2, running on ruby 3.1.4) [x86_64-linux]
  - rubocop-rails 2.24.0
  - rubocop-rspec 2.27.1

The issue was first observed in version 1.61.0. A possible fix was merged but the new version is still offending:

@koic koic added the bug label Mar 15, 2024
koic added a commit to koic/rubocop that referenced this issue Mar 22, 2024
Part of rubocop#12793.

This PR fixes false positives for `Style/RedundantLineContinuation`
when using line continuation with modifier.
koic added a commit to koic/rubocop that referenced this issue Mar 22, 2024
Part of rubocop#12793.

This PR fixes false positives for `Style/RedundantLineContinuation`
when using line continuation with modifier.
koic added a commit to koic/rubocop that referenced this issue Mar 25, 2024
…nuation`

Fixes rubocop#12793.

This PR fixes false positives for `Style/RedundantLineContinuation`
when multi-line continuations with operators.

In rubocop#12678, the use of `RuboCop::Cop::Base#parse` method was avoided due to errors in Prism.
Now, the error in Prism have been fixed:
rubocop#12677 (comment)

And given redundant line continuation patterns is too varied,
this PR have reverted to a simpler implementation using the `parse` method.
bbatsov pushed a commit that referenced this issue Mar 25, 2024
Fixes #12793.

This PR fixes false positives for `Style/RedundantLineContinuation`
when multi-line continuations with operators.

In #12678, the use of `RuboCop::Cop::Base#parse` method was avoided due to errors in Prism.
Now, the error in Prism have been fixed:
#12677 (comment)

And given redundant line continuation patterns is too varied,
this PR have reverted to a simpler implementation using the `parse` method.
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