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 #10864] Fix a false positive for Style/SymbolProc #10865

Commits on Aug 4, 2022

  1. [Fix rubocop#10864] Fix a false positive for Style/SymbolProc

    Fixes rubocop#10864.
    
    This PR fixes a false positive for `Style/SymbolProc` when using `Hash#reject`.
    The same is true for `Haash#select`.
    
    ```ruby
    {foo: :bar}.reject { p _1 } # `_1` is `:foo`
    {foo: :bar}.select { p _1 } # `_1` is `:foo`
    {foo: :bar}.detect { p _1 } # `_1` is `[:foo, :bar]`
    {foo: :bar}.map { p _1 }    # `_1` is `[:foo, :bar]`
    ```
    
    It fixes `on_block` method because the same issue occurs in normal blocks.
    
    ```ruby
    {foo: :bar}.select {|item| item.nil? } #=> no erros.
    {foo: :bar}.select(&:nil?)             #=> wrong number of arguments (given 1, expected 0) (ArgumentError)
    ```
    
    `Style/SymbolProc` is already marked as unsafe, but it avoids avoidable issues.
    koic committed Aug 4, 2022
    Configuration menu
    Copy the full SHA
    d154c2a View commit details
    Browse the repository at this point in the history