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 negative for Style/RedundantLineContinuation when the following line starts with a percent array #13677

Closed
ydakuka opened this issue Jan 11, 2025 · 1 comment · Fixed by #13689
Labels

Comments

@ydakuka
Copy link

ydakuka commented Jan 11, 2025

Describe the solution you'd like

RSpec.describe Campaigns::CloneInteractor do
  let :campaign_location do
    create(:campaign_location, \
           %i[allowed disallowed].sample,
           created_at: campaign_location_created_at)
  end

  pending 'add something'
end

RuboCop

ydakuka@yauhenid:~/Work/project$ rubocop -V
1.70.0 (using Parser 3.3.6.0, rubocop-ast 1.37.0, analyzing as Ruby 2.7, running on ruby 2.7.8) [x86_64-linux]
  - rubocop-capybara 2.21.0
  - rubocop-factory_bot 2.26.1
  - rubocop-performance 1.23.1
  - rubocop-rails 2.28.0
  - rubocop-rake 0.6.0
  - rubocop-rspec 3.3.0
  - rubocop-rspec_rails 2.30.0
  - rubocop-thread_safety 0.6.0
@ydakuka ydakuka changed the title False negatives on the Style/RedundantLineContinuation cop False negatives for Style/RedundantLineContinuation Jan 11, 2025
@dvandersluis dvandersluis changed the title False negatives for Style/RedundantLineContinuation False negative for Style/RedundantLineContinuation when the following line starts with a percent array Jan 13, 2025
@dvandersluis
Copy link
Member

I split the second example to #13688 because there are two different bugs to fix here.

dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Jan 13, 2025
…ation` when the continuation is followed by a percent array

Previously, `start_with_arithmetic_operator?` used a regexp to check if the following line starts with an arithmetic operator (`+`, `-`, `*`, `/` or `%`). However, a percent array (eg. `%i[foo bar]`) also starts with a `%`, and as such, was being marked as a required continuation.

This has been corrected now to check against the first token of the line rather than the first character.
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Jan 13, 2025
…ation` when the continuation is followed by a percent array

Previously, `start_with_arithmetic_operator?` used a regexp to check if the following line starts with an arithmetic operator (`+`, `-`, `*`, `/` or `%`). However, a percent array (eg. `%i[foo bar]`) also starts with a `%`, and as such, was being marked as a required continuation.

This has been corrected now to check against the first token of the line rather than the first character.

Additionally, the previous regex masked instances where arguments to an unparenthesized method call started with an arithmetic operator character; these cases are now properly handled.
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Jan 13, 2025
…ation` when the continuation is followed by a percent array

Previously, `start_with_arithmetic_operator?` used a regexp to check if the following line starts with an arithmetic operator (`+`, `-`, `*`, `/` or `%`). However, a percent array (eg. `%i[foo bar]`) also starts with a `%`, and as such, was being marked as a required continuation.

This has been corrected now to check against the first token of the line rather than the first character.

Additionally, the previous regex masked instances where arguments to an unparenthesized method call started with an arithmetic operator character; these cases are now properly handled.
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Jan 13, 2025
…ation` when the continuation is followed by a percent array

Previously, `start_with_arithmetic_operator?` used a regexp to check if the following line starts with an arithmetic operator (`+`, `-`, `*`, `/` or `%`). However, a percent array (eg. `%i[foo bar]`) also starts with a `%`, and as such, was being marked as a required continuation.

This has been corrected now to check against the first token of the line rather than the first character.

Additionally, the previous regex masked instances where arguments to an unparenthesized method call started with an arithmetic operator character; these cases are now properly handled.
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Jan 13, 2025
…ation` when the continuation is followed by a percent array

Previously, `start_with_arithmetic_operator?` used a regexp to check if the following line starts with an arithmetic operator (`+`, `-`, `*`, `/` or `%`). However, a percent array (eg. `%i[foo bar]`) also starts with a `%`, and as such, was being marked as a required continuation.

This has been corrected now to check against the first token of the line rather than the first character.

Additionally, the previous regex masked instances where arguments to an unparenthesized method call started with an arithmetic operator character; these cases are now properly handled.
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Jan 13, 2025
…ation` when the continuation is followed by a percent array

Previously, `start_with_arithmetic_operator?` used a regexp to check if the following line starts with an arithmetic operator (`+`, `-`, `*`, `/` or `%`). However, a percent array (eg. `%i[foo bar]`) also starts with a `%`, and as such, was being marked as a required continuation.

This has been corrected now to check against the first token of the line rather than the first character.

Additionally, the previous regex masked instances where arguments to an unparenthesized method call started with an arithmetic operator character; these cases are now properly handled.
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Jan 13, 2025
…ation` when the continuation is followed by a percent array

Previously, `start_with_arithmetic_operator?` used a regexp to check if the following line starts with an arithmetic operator (`+`, `-`, `*`, `/`, '**' or `%`). However, a percent array (eg. `%i[foo bar]`) also starts with a `%`, and as such, was being marked as a required continuation.

This has been corrected now to check against the first token of the line rather than the first character.

Additionally, the previous regex masked instances where arguments to an unparenthesized method call started with an arithmetic operator character; these cases are now properly handled.
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Jan 13, 2025
…ation` when the continuation is followed by a percent array

Previously, `start_with_arithmetic_operator?` used a regexp to check if the following line starts with an arithmetic operator (`+`, `-`, `*`, `/`, '**' or `%`). However, a percent array (eg. `%i[foo bar]`) also starts with a `%`, and as such, was being marked as a required continuation.

This has been corrected now to check against the first token of the line rather than the first character.

Additionally, the previous regex masked instances where arguments to an unparenthesized method call started with an arithmetic operator character; these cases are now properly handled.
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Jan 13, 2025
…ation` when the continuation is followed by a percent array

Previously, `start_with_arithmetic_operator?` used a regexp to check if the following line starts with an arithmetic operator (`+`, `-`, `*`, `/`, '**' or `%`). However, a percent array (eg. `%i[foo bar]`) also starts with a `%`, and as such, was being marked as a required continuation.

This has been corrected now to check against the first token of the line rather than the first character.

Additionally, the previous regex masked instances where arguments to an unparenthesized method call started with an arithmetic operator character; these cases are now properly handled.
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Jan 13, 2025
…ation` when the continuation is followed by a percent array

Previously, `start_with_arithmetic_operator?` used a regexp to check if the following line starts with an arithmetic operator (`+`, `-`, `*`, `/`, '**' or `%`). However, a percent array (eg. `%i[foo bar]`) also starts with a `%`, and as such, was being marked as a required continuation.

This has been corrected now to check against the first token of the line rather than the first character.

Additionally, the previous regex masked instances where arguments to an unparenthesized method call started with an arithmetic operator character; these cases are now properly handled.
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Jan 13, 2025
…ation` when the continuation is followed by a percent array

Previously, `start_with_arithmetic_operator?` used a regexp to check if the following line starts with an arithmetic operator (`+`, `-`, `*`, `/`, '**' or `%`). However, a percent array (eg. `%i[foo bar]`) also starts with a `%`, and as such, was being marked as a required continuation.

This has been corrected now to check against the first token of the line rather than the first character.
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Jan 15, 2025
…ation` when the continuation is followed by a percent array

Previously, `start_with_arithmetic_operator?` used a regexp to check if the following line starts with an arithmetic operator (`+`, `-`, `*`, `/`, '**' or `%`). However, a percent array (eg. `%i[foo bar]`) also starts with a `%`, and as such, was being marked as a required continuation.

This has been corrected now to check against the first token of the line rather than the first character.
dvandersluis added a commit that referenced this issue Jan 15, 2025
[Fix #13677] Fix false negative on `Style/RedundantLineContinuation` when the continuation is followed by a percent array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants