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

Fixes Rails/IndexBy correction when .to_h is separated by a newline #239

Merged
merged 1 commit into from Apr 23, 2020
Merged

Fixes Rails/IndexBy correction when .to_h is separated by a newline #239

merged 1 commit into from Apr 23, 2020

Commits on Apr 22, 2020

  1. [Fix #238] Rails/IndexBy invalid syntax when .to_h is separated by a …

    …newline
    
    I believe that the test cases included in this commit express well the
    problem I'm trying to address, but running the auto-correction against
    the following snippet of code:
    
    ```rb
    x.map { |el| [el.to_sym, el] }.
      to_h
    ```
    
    Would yield:
    
    ```rb
    x.index_by { |el| el.to_sym }. # notice the ending "dot"
    ```
    
    The output isn't parseable/valid Ruby. I belive the problem has to do
    with the fact that correction code assumes that the `.to_h` statement is
    always grouped together (which might not be always true).
    
    The proposed solution was to try to compute the number of trailing characters
    to be stripped by subtracting the end position of the map block (the `}`
    character) from end position of the whole expression.
    Diogo Osório committed Apr 22, 2020
    Copy the full SHA
    8307c6a View commit details
    Browse the repository at this point in the history