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

Allow parentheses in yield arguments for Style/MethodCallWithArgsParentheses #9625

Merged
merged 1 commit into from Mar 22, 2021

Commits on Mar 22, 2021

  1. Allow parentheses in yield arguments for `Style/MethodCallWithArgsPar…

    …entheses`
    
    When using the `omit_parentheses` style, we don't recognize `yield`
    argument calls and require parentheses omission. If we yield multiple
    values, we cannot omit the parentheses in method calls as this won't be
    valid Ruby. We currently register offenses for:
    
    ```ruby
    # Example 1
    yield File.basename(path)
          ^^^^^^^^^^^^^^^^^^^ Omit parentheses for method calls with arguments.
    
    # Correction...
    yield File.basename path # 👈 This compiles.
    
    # Example 2
    yield path, File.basename(path)
                ^^^^^^^^^^^^^^^^^^^ Omit parentheses for method calls with arguments.
    
    # Correction...
    yield path, File.basename path # 👈 This DOES NOT!!!
    ```
    
    If we treat yield arguments as any other method call arguments, we'll
    allow the parentheses and let people write valid Ruby in the cases
    above.
    gsamokovarov committed Mar 22, 2021
    Copy the full SHA
    770beb1 View commit details
    Browse the repository at this point in the history