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/RedundantCondition still making invalid corrections #10624

Closed
pbstriker38 opened this issue May 11, 2022 · 1 comment
Closed

Style/RedundantCondition still making invalid corrections #10624

pbstriker38 opened this issue May 11, 2022 · 1 comment

Comments

@pbstriker38
Copy link

Autocorrect for Style/RedundantCondition is producing invalid code.


For the following code

def progress_text(batch_status, data_ready_status)
  if data_ready_status
    {
      'in_progress' => 'In Progress',
      'complete' => 'Complete',
      'cancelled' => 'Cancelled'
    }[data_ready_status]
  else
    {
      'in_progress' => 'In Progress',
      'complete' => 'Batch complete',
      'failed' => 'Failed'
    }[batch_status]
  end
end

It is being autocorrected to

def progress_text(batch_status, data_ready_status)
  {
    'in_progress' => 'In Progress',
    'complete' => 'Complete',
    'cancelled' => 'Cancelled'
  }[data_ready_status] || batch_status
end

RuboCop version

❯ bundle exec rubocop -V
1.29.0 (using Parser 3.1.2.0, rubocop-ast 1.17.0, running on ruby 3.1.0 arm64-darwin20)
  - rubocop-performance 1.13.3
  - rubocop-rails 2.14.2
  - rubocop-rake 0.6.0
  - rubocop-rspec 2.10.0
@ydah
Copy link
Member

ydah commented May 11, 2022

Thank you so much!

Looks like this issue has already been solved with #10606
Please wait for the next RuboCop version and it will work😄

@koic koic added the duplicate label May 12, 2022
@koic koic closed this as completed May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants