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

Suppress keyword arguments warning for Ruby 2.7.0 #612

Merged

Conversation

koic
Copy link
Contributor

@koic koic commented Jan 10, 2020

Summary

This PR suppresses the following keyword arguments warning for Ruby 2.7.0.

% ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin17]
% DB=sqlite bundle exec appraisal activerecord_6.0.0 rake

/Users/koic/src/github.com/CanCanCommunity/cancancan/lib/cancan/unauthorized_message_resolver.rb:9:
warning: Using the last argument as keyword parameters is deprecated;
maybe ** should be added to the call
/Users/koic/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/i18n-1.8.0/lib/i18n.rb:195:
warning: The called method `translate' is defined here

For Ruby 2.8.0-dev (Ruby 3.0) the warning will be ArgumentError.
ruby/ruby#2794

Other Infromation

There are other similar warnings against Active Record, but Rails 6.0 stable branch is WIP.
rails/rails#37935

It is not subject to changes in this repository.

koic added 2 commits January 10, 2020 10:03
## Summary

This PR suppresses the following keyword arguments warning for Ruby 2.7.0.

```console
% ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin17]
% DB=sqlite bundle exec appraisal activerecord_6.0.0 rake

/Users/koic/src/github.com/CanCanCommunity/cancancan/lib/cancan/unauthorized_message_resolver.rb:9:
warning: Using the last argument as keyword parameters is deprecated;
maybe ** should be added to the call
/Users/koic/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/i18n-1.8.0/lib/i18n.rb:195:
warning: The called method `translate' is defined here
```

For Ruby 2.8.0-dev (Ruby 3.0) the warning will be `ArgumentError`.
ruby/ruby#2794

## Other Infromation

There are other similar warnings against Active Record, but Rails 6.0
stable branch is WIP.
rails/rails#37935

It is not subject to changes in this repository.
Ruby 2.7.0 has been released.

This PR adds Ruby 2.7.0 matrix. And the matrix excludes Rails 4.2
testing to prevent the following error.

```console
NoMethodError:
  undefined method `new' for BigDecimal:Class
```

- https://travis-ci.org/CanCanCommunity/cancancan/jobs/635119862
- https://travis-ci.org/CanCanCommunity/cancancan/jobs/635119863

The behavior of `BigDecimal.new` between Ruby 2.6 and Ruby 2.7
has the following differences.

```console
% ruby -rbigdecimal -ve 'BigDecimal.new(42)'
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin17]
-e:1: warning: BigDecimal.new is deprecated; use BigDecimal() method instead.
```

```console
% ruby -rbigdecimal -ve 'BigDecimal.new(42)'
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin17]
Traceback (most recent call last):
-e:1:in `<main>': undefined method `new' for BigDecimal:Class (NoMethodError)
```

Rails 4.2 is no longer maintained and will not be backported to support Ruby 2.7.
https://guides.rubyonrails.org/maintenance_policy.html

Therefore, this PR excludes the matrix of the combination of Ruby 2.7
and Rails 4.2.
@koic koic force-pushed the suppress_kwargs_warning_for_ruby_2_7_0 branch from 6b68228 to 7e6011a Compare January 10, 2020 09:24
@@ -32,6 +33,8 @@ matrix:
gemfile: gemfiles/activerecord_6.0.0.gemfile
- rvm: 2.4.2
gemfile: gemfiles/activerecord_6.0.0.gemfile
- rvm: 2.7.0
gemfile: gemfiles/activerecord_4.2.0.gemfile
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The matrix excludes Rails 4.2 testing to prevent the following error.

NoMethodError:
  undefined method `new' for BigDecimal:Class

The behavior of BigDecimal.new between Ruby 2.6 and Ruby 2.7 has the following differences.

% ruby -rbigdecimal -ve 'BigDecimal.new(42)'
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin17]
-e:1: warning: BigDecimal.new is deprecated; use BigDecimal() method instead.
% ruby -rbigdecimal -ve 'BigDecimal.new(42)'
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin17]
Traceback (most recent call last):
-e:1:in `<main>': undefined method `new' for BigDecimal:Class (NoMethodError)

Rails 4.2 is no longer maintained and will not be backported to support Ruby 2.7.
https://guides.rubyonrails.org/maintenance_policy.html

Therefore, this PR excludes the matrix of the combination of Ruby 2.7 and Rails 4.2.

Copy link
Member

@coorasse coorasse left a comment

Choose a reason for hiding this comment

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

Nice. Thank you!

@coorasse coorasse merged commit c77418b into CanCanCommunity:develop Jan 18, 2020
@koic koic deleted the suppress_kwargs_warning_for_ruby_2_7_0 branch January 18, 2020 08:32
Hamms added a commit to code-dot-org/code-dot-org that referenced this pull request Dec 13, 2022
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.

2 participants