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鈥檒l 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

Conversation

@gsamokovarov
Copy link
Contributor

@gsamokovarov gsamokovarov commented Mar 20, 2021

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:

# 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 gsamokovarov force-pushed the gsamokovarov:omit-parentheses-in-yield branch 2 times, most recently from afe7be3 to 25dd03e Mar 20, 2021
@bbatsov
Copy link
Collaborator

@bbatsov bbatsov commented Mar 22, 2021

The suggested change looks good, just move the changelog entry to the changelog folder.

鈥ntheses`

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 gsamokovarov force-pushed the gsamokovarov:omit-parentheses-in-yield branch from 25dd03e to 770beb1 Mar 22, 2021
@gsamokovarov
Copy link
Contributor Author

@gsamokovarov gsamokovarov commented Mar 22, 2021

Thanks, moved the changelog.

@bbatsov bbatsov merged commit 973188d into rubocop:master Mar 22, 2021
31 checks passed
31 checks passed
@github-actions
windows 2.4
Details
@github-actions
windows 2.5
Details
@github-actions
windows 2.6
Details
@github-actions
windows 2.7
Details
@github-actions
windows 3.0
Details
@github-actions
windows mingw
Details
@mergify
Summary 2 potential rules
Details
ci/circleci: cc-setup Your tests passed on CircleCI!
Details
ci/circleci: cc-upload-coverage Your tests passed on CircleCI!
Details
ci/circleci: documentation-checks Your tests passed on CircleCI!
Details
ci/circleci: jruby-9.2-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: jruby-9.2-rubocop Your tests passed on CircleCI!
Details
ci/circleci: jruby-9.2-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.4-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.4-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.4-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.5-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.5-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.5-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.6-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.6-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.6-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.7-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.7-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.7-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-3.0-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-3.0-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-3.0-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-head-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-head-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-head-spec Your tests passed on CircleCI!
Details
@bbatsov
Copy link
Collaborator

@bbatsov bbatsov commented Mar 22, 2021

Thanks!

@gsamokovarov gsamokovarov deleted the gsamokovarov:omit-parentheses-in-yield branch Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants