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

Rails/IndexBy invalid correction when .to_h invocation is split in different lines #238

Closed
diogoosorio opened this issue Apr 22, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@diogoosorio
Copy link

I caught this while upgrading Rubocop in one of our company's internal codebases. This all refers to the Rails/IndexBy cop.

Given a snippet of code like so:

x.map { |y| [y.to_sym, y] }.
  to_h

The correction yields invalid Ruby code:

x.index_by { |y| y.to_sym }. # notice the ending '.'

Expected behavior

Not having the final dot...

Actual behavior

The additional dot makes the correction emit invalid Ruby. 😅

Steps to reproduce the problem

PR incoming with a couple of tests...

RuboCop version

[21:05:25] ~/workspace/marleyspoon/rubocop-rails ● $ bundle exec rubocop -V
0.82.0 (using Parser 2.7.1.1, running on ruby 2.6.2 x86_64-darwin19)
@koic koic added the bug Something isn't working label Apr 23, 2020
@koic koic closed this as completed in 8307c6a Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants