Ruby 2.6 warning: passing splat keyword arguments as a single Hash #32612
Conversation
Before: ``` $ ruby -v ruby 2.6.0dev (2018-04-04 trunk 63085) [x86_64-linux] $ bundle exec rake test:template ... /rails/actionview/lib/action_view/digestor.rb:76: warning: passing splat keyword arguments as a single Hash to `find_all' ```
(@rails-bot has picked a reviewer for you, use r? to override) |
Can you fix all the remaining places where this warning is being raised in the same PR. This is the 3rd PR for the same change. |
In current master this is the last place. I wanted to add this to the 2nd PR when it popped up, but took longer to figure out the proper way. Sorry. |
Thanks for looking on all the other places. Yeah, not sure how to avoid introducing this warning again since it only happen on Ruby 2.6 and that version is not even released yet. Maybe we can add a rubocop rule? |
prefixes = args[1] || [] | ||
partial = args[2] || false | ||
keys = args[3] || [] | ||
options = args[4] || {} |
printercu
Apr 28, 2018
•
Contributor
Why not just def find_template(finder, name, prefixes = [], partial = false, keys = [], options = {})
?
@rafaelfranca will you accept PR with this change?
Why not just def find_template(finder, name, prefixes = [], partial = false, keys = [], options = {})
?
@rafaelfranca will you accept PR with this change?
printercu
Apr 28, 2018
Contributor
even find_template(finder, *args, **options)
should be fine.
even find_template(finder, *args, **options)
should be fine.
rafaelfranca
May 2, 2018
Member
Yup. Please open a PR
Yup. Please open a PR
## 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
## 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
## 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
## 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
Ruby 2.6 warning: passing splat keyword arguments as a single Hash
Ruby 2.6 warning: passing splat keyword arguments as a single Hash
Ruby 2.6 warning: passing splat keyword arguments as a single Hash
Ruby 2.6 warning: passing splat keyword arguments as a single Hash
Before:
See:
https://travis-ci.org/rails/rails/jobs/367493803#L1516-L1874