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

Fix an incorrect autocorrect for Style/MapToHash with Layout/SingleLineBlockChain #12407

Commits on Nov 24, 2023

  1. Fix an incorrect autocorrect for Style/MapToHash and `Layout/Single…

    …LineBlockChain`
    
    This PR fixes an incorrect autocorrect for `Style/MapToHash` with `Layout/SingleLineBlockChain`
    which makes the following syntax error occur:
    
    ```console
    $ cat example.rb
    obj.map { |i| foo(i) }.to_h
       .bar
    
    $ bundle exec rubocop -A example.rb --only Style/MapToHash,Layout/SingleLineBlockChain
    Inspecting 1 file
    F
    
    Offenses:
    
    example.rb:1:5: C: [Corrected] Style/MapToHash: Pass a block to to_h instead of calling map.to_h.
    obj.map { |i| foo(i) }.to_h
        ^^^
    example.rb:1:23: C: [Corrected] Layout/SingleLineBlockChain: Put method call on a separate line if chained to a single line block.
    obj.map { |i| foo(i) }.to_h
                          ^^^^^
    example.rb:3:4: F: Lint/Syntax: unexpected token tDOT
    (Using Ruby 3.3 parser; configure using TargetRubyVersion parameter, under AllCops)
       .bar
       ^
    
    1 file inspected, 3 offenses detected, 2 offenses corrected
    ```
    koic committed Nov 24, 2023
    Configuration menu
    Copy the full SHA
    84da432 View commit details
    Browse the repository at this point in the history