-
Notifications
You must be signed in to change notification settings - Fork 43
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
Fixes #32099: Check if an Integer for integer data_type #326
Conversation
hmmm,
is happening somehow in test/kafo/data_types/hash_test.rb ? |
Hrmm, means this method is not used how I thought it was used. I'll take another crack at modifying the original. |
Updated. I did change one assertion because it seemed odd to me that "1foo" should be consider an Integer and return "1". If you mix letters and numbers, that ought to be a string. An integer should be clearly an integer. |
lib/kafo/data_types/integer.rb
Outdated
@@ -19,7 +19,9 @@ def to_s | |||
end | |||
|
|||
def typecast(value) | |||
value =~ /\d+/ ? value.to_i : value | |||
Integer(value) | |||
rescue |
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.
Isn't it better to catch ArgumentError
explicitly? Catching all exceptions is generally a bad practice.
Additional to this, I think having theforeman/jenkins-jobs#5 in place would help catch these outside of runtime testing. |
This required some additional cleanup to get everything to work properly. |
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.
The commit message should also mention Float, other than 👍
…ta_type This fixes a deprecation warning present in Ruby 2.7: warning: deprecated Object#=~ is called on Integer; it always returns nil The change removes Kafo's custom TypeError exception as there was no use of it inside the project and it had the effect of shadowing the built in Ruby TypeError.
This fixes a deprecation warning present in Ruby 2.7:
warning: deprecated Object#=~ is called on Integer; it always returns nil