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

2.6 warning: passing splat keyword arguments as a single Hash #32556

Merged
merged 1 commit into from
Apr 17, 2018

Conversation

utilum
Copy link
Contributor

@utilum utilum commented Apr 13, 2018

Ruby 2.6.0 warns about this.

ruby 2.6.0dev (2018-04-04 trunk 63085) [x86_64-linux]

Before, see:
https://travis-ci.org/rails/rails/jobs/365740163#L1262-L1264
https://travis-ci.org/rails/rails/jobs/365944863#L2121-L2174

@rails-bot
Copy link

r? @schneems

(@rails-bot has picked a reviewer for you, use r? to override)

@utilum utilum force-pushed the splat branch 6 times, most recently from 690095b to 86cafe7 Compare April 15, 2018 08:08
@@ -200,7 +200,7 @@ def open_connection
end

def receive(connection, command:, identifiers:, channel: "ActionCable::StreamTests::ChatChannel")
identifier = JSON.generate(channel: channel, **identifiers)
identifier = JSON.generate(identifiers.merge(channel: channel))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changed merging order, but I confirmed that changing order in this helper method has no effect.

@kamipo kamipo merged commit 6378a38 into rails:master Apr 17, 2018
@utilum utilum deleted the splat branch April 17, 2018 20:02
koic added a commit to koic/rubocop that referenced this pull request May 10, 2018
## Summary

This cop emulates the following Ruby warnings in Ruby 2.6.
ruby/ruby@a23eca2

```console
% ruby -we "def m(a) end; h = {foo: 1}; m(**h)"
-e:1: warning: passing splat keyword arguments as a single Hash to `m'
```

This cop does not have autocorrect because uses of splat keyword
arguments duplicates the argument hash instance.
So, it is not necessarily compatible code.

### Use splat keyword arguments (`foo(**h)`)

```console
% ruby -vwe "def m(a) p a.object_id; end; h = {k: :v}; p h.object_id; m(**h)"
ruby 2.6.0dev (2018-05-08 trunk 63359) [x86_64-darwin17]
70248917856620
-e:1: warning: passing splat keyword arguments as a single Hash to `m'
70248917856460
```

### Use non-splat keyword arguments (`foo(h)`)

```console
% ruby -vwe "def m(a) p a.object_id; end; h = {k: :v}; p h.object_id; m(h)"
ruby 2.6.0dev (2018-05-08 trunk 63359) [x86_64-darwin17]
70211441327220
70211441327220
```

## Other Information

While this warning is experimental, however work on rails/rails has begun.

- rails/rails#32447
- rails/rails#32556
- rails/rails#32612
bbatsov pushed a commit to rubocop/rubocop that referenced this pull request May 14, 2018
## Summary

This cop emulates the following Ruby warnings in Ruby 2.6.
ruby/ruby@a23eca2

```console
% ruby -we "def m(a) end; h = {foo: 1}; m(**h)"
-e:1: warning: passing splat keyword arguments as a single Hash to `m'
```

This cop does not have autocorrect because uses of splat keyword
arguments duplicates the argument hash instance.
So, it is not necessarily compatible code.

### Use splat keyword arguments (`foo(**h)`)

```console
% ruby -vwe "def m(a) p a.object_id; end; h = {k: :v}; p h.object_id; m(**h)"
ruby 2.6.0dev (2018-05-08 trunk 63359) [x86_64-darwin17]
70248917856620
-e:1: warning: passing splat keyword arguments as a single Hash to `m'
70248917856460
```

### Use non-splat keyword arguments (`foo(h)`)

```console
% ruby -vwe "def m(a) p a.object_id; end; h = {k: :v}; p h.object_id; m(h)"
ruby 2.6.0dev (2018-05-08 trunk 63359) [x86_64-darwin17]
70211441327220
70211441327220
```

## Other Information

While this warning is experimental, however work on rails/rails has begun.

- rails/rails#32447
- rails/rails#32556
- rails/rails#32612
yahonda pushed a commit to yahonda/rails that referenced this pull request Dec 24, 2018
2.6 warning: passing splat keyword arguments as a single Hash
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

4 participants