Skip to content

Commit

Permalink
Ruby 2.4 - Replace all Fixnum|Bignum
Browse files Browse the repository at this point in the history
Both are deprecated in favor of Integer

https://bugs.ruby-lang.org/issues/12005
  • Loading branch information
chrisarcand committed Sep 18, 2017
1 parent a160544 commit 0c21d70
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/models/generic_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def _property_setter(name, value)
end

# the method parameters are passed into automate as a hash:
# {:param_1 => 12, :param_1_type => "Vm", :param_2 => 14, :param_2_type => "Fixnum"}
# {:param_1 => 12, :param_1_type => "Vm", :param_2 => 14, :param_2_type => "Integer"}
# the return value from automate is in $evm.root['method_result']
def _call_automate(method_name, *args)
raise "A user is required to send [#{method_name}] to automate." unless @user
Expand Down
4 changes: 2 additions & 2 deletions app/models/metric/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ def self.get_time_zone(options = nil)
# interval_name of hourly (and others)
# Just your typical x.seconds.ago
#
# @param start_offset [Fixnum]
# @param end_offset [Fixnum|nil]
# @param start_offset [Integer]
# @param end_offset [Integer|nil]
# @return [Range<Datetime,Datetime>] timestamp range for offsets
def self.time_range_from_offset(interval_name, start_offset, end_offset, tz = nil)
if interval_name == "daily"
Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_provision/automate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def get_network_details
end

vc_id = related_vm.ext_management_system.id
unless vc_id.kind_of?(Fixnum)
unless vc_id.kind_of?(Integer)
_log.error("Invalid EMS ID <#{vc_id.inspect}> for #{related_vm_description} of Provision Object")
return nil
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_report/generator/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def build_html_col(output, col_name, col_format, row_data)
else
if row_data[col_name].kind_of?(Time)
output << "<td#{style_class} " + 'style="text-align:center">'
elsif row_data[col_name].kind_of?(Bignum) || row_data[col_name].kind_of?(Fixnum) || row_data[col_name].kind_of?(Float)
elsif row_data[col_name].kind_of?(Integer) || row_data[col_name].kind_of?(Float)
output << "<td#{style_class} " + 'style="text-align:right">'
else
output << "<td#{style_class}>"
Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_schedule_worker/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def check_roles_changed
# In Rufus::Scheduler Version 2, schedule returns a Job
# In Rufus::Scheduler Version 3, schedule could return a Job/JobID, depending on whether :job => true is
# passed to opts
if j.kind_of?(Fixnum)
if j.kind_of?(Integer)
@system_scheduler.unschedule(j)
else
if j.respond_to?(:tags)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def start_algorithm_used_swap_percent_lt_value_and_free_memory_gt_half_worker_me
end

value = settings[:memory_threshold]
unless value.kind_of?(Fixnum)
unless value.kind_of?(Integer)
_log.warn("Allowing worker: [#{options[:worker_name]}] to start since the threshold is invalid: [#{value}], type: [#{value.class.name}]")
return false
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_widget.rb
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def self.get_group(group)
case group
when String
group = MiqGroup.in_my_region.find_by(:description => group)
when Fixnum
when Integer
group = MiqGroup.in_my_region.find_by(:id => group)
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/vmdb_metric/purging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module ClassMethods
def purge_date(interval)
type = "keep_#{interval}_metrics".to_sym
value = ::Settings.database.metrics_history[type]
value = value.to_i.days if value.kind_of?(Fixnum) # Default unit is days
value = value.to_i.days if value.kind_of?(Integer) # Default unit is days
value = value.to_i_with_method.seconds.ago.utc unless value.nil?
value
end
Expand Down
2 changes: 1 addition & 1 deletion config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@
:mem_minimum: 32.megabytes
:reporting:
:format_by_class:
:Fixnum:
:Integer:
:function:
:name: number_with_delimiter
:Float:
Expand Down
6 changes: 3 additions & 3 deletions lib/vmdb/config/validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def webservices(data)
valid = false; errors << [:nameresolution, "webservices nameresolution, \"#{data.nameresolution}\", invalid. Should be one of: true or false"]
end

if keys.include?(:timeout) && !data.timeout.kind_of?(Fixnum)
if keys.include?(:timeout) && !data.timeout.kind_of?(Integer)
valid = false; errors << [:timeout, "timeout, \"#{data.timeout}\", invalid. Should be numeric"]
end

Expand Down Expand Up @@ -108,7 +108,7 @@ def session(data)
keys = data.each_pair.to_a.transpose.first.to_set

if keys.include?(:timeout)
unless data.timeout.kind_of?(Fixnum)
unless data.timeout.kind_of?(Integer)
valid = false; errors << [:timeout, "timeout, \"#{data.timeout}\", invalid. Should be numeric"]
end

Expand All @@ -118,7 +118,7 @@ def session(data)
end

if keys.include?(:interval)
unless data.interval.kind_of?(Fixnum)
unless data.interval.kind_of?(Integer)
valid, key, message = [false, :interval, "interval, \"#{data.interval}\", invalid. invalid. Should be numeric"]
end

Expand Down
2 changes: 1 addition & 1 deletion spec/models/custom_attribute_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
expect(time_custom_attribute.value_type).to eq(:datetime)
end

it "returns the value type of Fixnum custom attributes" do
it "returns the value type of Integer custom attributes" do
# TODO: Ruby 2.4 unifies fixnum and bignum into integer, we shouldn't be
# returnings ruby types like this.
expected = RUBY_VERSION >= "2.4.0" ? :integer : :fixnum
Expand Down
2 changes: 1 addition & 1 deletion spec/models/vmdb_database_connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

it 'computes wait_time' do
setting = VmdbDatabaseConnection.all.first
expect(setting.wait_time).to be_kind_of(Fixnum)
expect(setting.wait_time).to be_kind_of(Integer)
end

it 'wait_time_ms defaults to 0 on nil query_start' do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/vmdb_database_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
expected_keys = ["client_address", "database", "spid", "is_waiting", "query"]
expect(connections.first.keys).to match_array(expected_keys)

expect(connections.first['spid']).to be_kind_of(Fixnum)
expect(connections.first['spid']).to be_kind_of(Integer)
end
end

Expand Down

0 comments on commit 0c21d70

Please sign in to comment.