-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Resolve ruby 2.7 deprecation warnings #134
Resolve ruby 2.7 deprecation warnings #134
Conversation
lib/dry/transaction/callable.rb
Outdated
@@ -31,6 +31,9 @@ def initialize(operation) | |||
def call(*args, &block) | |||
if arity.zero? | |||
operation.(&block) | |||
elsif args.last.is_a?(Hash) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hint: I'm not sure about how to solve this in a better way and could use some help. This line is to showcase why the deprecation warning is caused here.
When args
is an array with a last element being a hash, the splat operator pulls elements out of the array and the hash will be the last argument to the operation. If the operation is a method with keyword arguments, this will cause the deprecation warning dry-transaction/lib/dry/transaction/callable.rb:35: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
.
Any idea if this is missing some use cases, that also will lead to the same deprecation warning, but are not covered by the test suite and/or the elsif
-block?
Any idea to improve the implementation here, I dislike the elsif
-branch-style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obviously this change does break older rubies. Looks like **last
allows not only symbol but also string hash keys to be splatted to keyword arguments in ruby 2.7 but not other rubies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a check for ruby27 to the condition. :)
Here is an overview of what got changed by this pull request: Complexity increasing per file
==============================
- lib/dry/transaction/callable.rb 1
See the complete overview on Codacy |
Is there any chance that this could be merged and release? |
I rebased this locally to fix the merge conflict and pushed the merged branch to master 👍🏼 |
Released in 0.13.1 |
This PR resolves all deprecation warnings shown when running the specs with ruby 2.7.
dry-transaction/lib/dry/transaction/instance_methods.rb:19: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
dry-transaction/lib/dry/transaction/callable.rb:35: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
dry-transaction/spec/integration/passing_step_arguments_spec.rb:4