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

Prevent Lint/LiteralInInterpolation from removing necessary interpolation #8921

Merged

Commits on Oct 29, 2020

  1. Prevent Lint/LiteralInInterpolation from removing necessary interpola…

    …tion
    
    %W and %I split the content into words before expansion treating each
    interpolation as a word component.
    
    For example, the following array literal evaluates to
    `["-H", "Cookie: a=1; b=2", "https://example.com/"]`.
    
    ```ruby
    args = %W[-H #{"Cookie: a=1; b=2"} https://example.com/]
    ```
    
    However, Lint/LiteralInInterpolation will wrongly auto-correct it to
    this:
    
    ```ruby
    args = %W[-H Cookie: a=1; b=2 https://example.com/]
    ```
    
    Which gives a completely different set of elements:
    `["-H", "Cookie:", "a=1;", "b=2", "https://example.com/"]`.
    
    This fix teaches the cop not to expand an interpolation when the
    expanded value contains a space character.
    knu committed Oct 29, 2020
    Copy the full SHA
    2bb4490 View commit details
    Browse the repository at this point in the history