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

Resolve ruby 2.7 deprecation warnings #134

Closed
wants to merge 2 commits into from
Closed

Resolve ruby 2.7 deprecation warnings #134

wants to merge 2 commits into from

Conversation

robbl-as
Copy link
Contributor

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

@@ -31,6 +31,9 @@ def initialize(operation)
def call(*args, &block)
if arity.zero?
operation.(&block)
elsif args.last.is_a?(Hash)
Copy link
Contributor Author

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.

Copy link
Contributor Author

@robbl-as robbl-as Aug 18, 2020

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.

Copy link
Contributor Author

@robbl-as robbl-as Aug 19, 2020

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. :)

@dry-bot
Copy link
Contributor

dry-bot commented Aug 19, 2020

Codacy 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

@bilby91
Copy link

bilby91 commented Dec 17, 2020

Is there any chance that this could be merged and release?

@timriley

@timriley
Copy link
Member

I rebased this locally to fix the merge conflict and pushed the merged branch to master 👍🏼

@timriley timriley closed this Jan 31, 2021
@timriley
Copy link
Member

Released in 0.13.1

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.

4 participants