Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Fix Ruby 2.4 deprecations #216

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

dillonwelch
Copy link

lib/devise_security_extension/models/password_archivable.rb:20: warning: constant ::Fixnum is deprecated

I'm upgrading my app to Ruby 2.4 and getting these deprecations everywhere.

lib/devise_security_extension/models/password_archivable.rb:20: warning: constant ::Fixnum is deprecated
This requires Rails 4.2.8+ to get the correct version of the json gem
Use assert_nil if expecting nil from /devise_security_extension/test/test_paranoid_verification.rb:64:in `block in <class:TestParanoidVerification>'. This will fail in MT6.
@@ -20,7 +20,11 @@ Gem::Specification.new do |s|
s.require_paths = ['lib']
s.required_ruby_version = '>= 2.1.0'

s.add_runtime_dependency 'railties', '>= 3.2.6', '< 6.0'
if RUBY_VERSION >= '2.4'
Copy link
Author

Choose a reason for hiding this comment

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

Is pre Rails 4.2.8 compatibility important? If so, is this the way you want to support it? Ruby 2.4+ requires Rails 4.2.8+ because of changes in the json gem.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, its easy enough to upgrade to 4.2.[8, 9, 10] we should not need to support previous versions

@rsullivan00
Copy link

This successfully removes the warnings for me on Ruby 2.4.1 👍

@rsullivan00
Copy link

Is there anything stopping merging this branch? This warning is driving me crazy.

@dillonwelch
Copy link
Author

Someone with merge permissions :trollface:

@@ -61,7 +61,7 @@ class TestParanoidVerification < ActiveSupport::TestCase
test 'when code not match upon verification code, should not set paranoid_verified_at' do
user = User.new(paranoid_verification_code: 'abcde')
user.verify_code('wrong')
assert_equal(nil, user.paranoid_verified_at)
assert_nil(user.paranoid_verified_at)

Choose a reason for hiding this comment

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

rip

@knightq
Copy link

knightq commented Jun 6, 2017

Please merge

@wakproductions
Copy link

Is this gem still actively maintained?

@dillonwelch
Copy link
Author

Unfortunately it doesn't appear so. A couple of us have made a fork called devise-security

@@ -16,7 +16,7 @@ def validate_password_archive

# validate is the password used in the past
def password_archive_included?
unless deny_old_passwords.is_a? Fixnum
unless deny_old_passwords.is_a? 1.class
Copy link

Choose a reason for hiding this comment

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

Why not use Integer here? Even in Ruby < 2.4:

1.class #=> Fixnum
1.is_a? Integer #=> true

Copy link
Author

Choose a reason for hiding this comment

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

The maintainers of this repo seemed to have disappeared, so a few of us are maintaining a fork at https://github.com/devise-security/devise-security. Feel free to make a PR with these changes over there.

@@ -51,6 +51,12 @@ def update_password_changed
self.password_changed_at = Time.now if (self.new_record? or self.encrypted_password_changed?) and not self.password_changed_at_changed?
end

def expired_password_after_numeric?
return @_numeric if defined?(@_numeric)
@_numeric ||= self.expire_password_after.is_a?(1.class) ||
Copy link

Choose a reason for hiding this comment

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

||= is redundant if you're using a guard

Copy link
Author

Choose a reason for hiding this comment

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

Good point

@@ -51,6 +51,12 @@ def update_password_changed
self.password_changed_at = Time.now if (self.new_record? or self.encrypted_password_changed?) and not self.password_changed_at_changed?
end

def expired_password_after_numeric?
return @_numeric if defined?(@_numeric)
Copy link

Choose a reason for hiding this comment

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

Is it actually a good idea to memoize this? Could there be a scenario where this gets checked and then the column is made to be nil?

expired_password_after_numeric? #=> true
self.expire_password_after = nil
expired_password_after_numeric? #=> true

Copy link
Author

Choose a reason for hiding this comment

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

Unfortunately I don't know the code well enough to say.

@tibbon
Copy link

tibbon commented Jul 26, 2018

Any reason to not merge this?

@olbrich
Copy link

olbrich commented Jul 27, 2018

@tibbon
This repo is pretty much unmaintained at this point... try the fork of it at https://github.com/devise-security/devise-security

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants