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

Parenthesized forwarded args in Style/MethodCallWithArgsParentheses omit_parentheses #9637

Merged

Commits on Mar 25, 2021

  1. Parenthesized forwarded args in Style/MethodCallWithArgsParentheses

    The new-style arguments delegation included in Ruby 2.7 and expanded in
    Ruby 3.0 is required to be parenthesized, since the syntax is clashing
    with the endless `start...` range, which can be started with `start ...`
    as well. Currently, the most iffy cop of them all is issuing offenses
    for:
    
    ```ruby
    def delegated_call(...)
      @proxy.call(...)
                 ^^^^^ Omit parentheses for method calls with arguments.
    end
    ```
    
    Removing the parens will start an endless range with the beginning
    being the result of the method call without arguments. See the parse
    trees below for more details:
    
    ```bash
    -> ruby-parse -e "def foo(...); bar(...); end"
    (def :foo
      (args
        (forward-arg))
      (send nil :bar
        (forwarded-args)))
    
    -> ruby-parse -e "def foo(...); bar ...; end"
    (def :foo
      (args
        (forward-arg))
      (erange
        (send nil :bar) nil))
    
    -> ruby-parse -e "def foo(...); bar...; end"
    (def :foo
      (args
        (forward-arg))
      (erange
        (send nil :bar) nil))
    ```
    
    We don't want that so allow the parens and leave this gotcha to the poor
    developer that's gonna run into it.
    gsamokovarov committed Mar 25, 2021
    Copy the full SHA
    c8e7058 View commit details
    Browse the repository at this point in the history

Commits on Mar 28, 2021

  1. Copy the full SHA
    8eed46d View commit details
    Browse the repository at this point in the history