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

Add new "Arguments Forwarding" rule #845

Merged
merged 1 commit into from Oct 8, 2020

Conversation

koic
Copy link
Member

@koic koic commented Oct 8, 2020

Follow rubocop/rubocop#7646.

This PR adds new "Arguments Forwarding" rule that prefers Ruby 2.7's arguments forwarding syntax.

# bad
def some_method(*args, &block)
  other_method(*args, &block)
end

# bad
def some_method(*args, **kwargs, &block)
  other_method(*args, **kwargs, &block)
end

# bad
# Please note that it can cause unexpected incompatible behavior
# because `...` forwards block also.
# https://github.com/rubocop-hq/rubocop/issues/7549
def some_method(*args)
  other_method(*args)
end

# good
def some_method(...)
  other_method(...)
end

Follow rubocop/rubocop#7646.

This PR adds new "Arguments Forwarding" rule that prefers
Ruby 2.7's arguments forwarding syntax.

```ruby
# bad
def some_method(*args, &block)
  other_method(*args, &block)
end

# bad
def some_method(*args, **kwargs, &block)
  other_method(*args, **kwargs, &block)
end

# bad
# Please note that it can cause unexpected incompatible behavior
# because `...` forwards block also.
# rubocop/rubocop#7549
def some_method(*args)
  other_method(*args)
end

# good
def some_method(...)
  other_method(...)
end
```
@bbatsov bbatsov merged commit 4cd001f into rubocop:master Oct 8, 2020
@bbatsov
Copy link
Collaborator

bbatsov commented Oct 8, 2020

Looks good! Thanks!

@koic koic deleted the add_arguments_forwarding_rule branch October 8, 2020 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants