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

Commit

Permalink
update rubocop to 0.60.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoll committed Nov 11, 2018
1 parent 002fcf9 commit c2b6782
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 18 deletions.
12 changes: 6 additions & 6 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-05-05 02:13:49 +0200 using RuboCop version 0.54.0.
# on 2018-11-11 15:08:09 +0100 using RuboCop version 0.60.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -41,29 +41,29 @@ Lint/UselessAssignment:
Metrics/AbcSize:
Max: 67

# Offense count: 2
# Offense count: 1
# Configuration parameters: CountBlocks.
Metrics/BlockNesting:
Max: 4

# Offense count: 2
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 368
Max: 367

# Offense count: 3
Metrics/CyclomaticComplexity:
Max: 12

# Offense count: 21
# Configuration parameters: CountComments.
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/MethodLength:
Max: 52

# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 113
Max: 111

# Offense count: 1
# Configuration parameters: CountKeywordArgs.
Expand All @@ -76,7 +76,7 @@ Metrics/PerceivedComplexity:

# Offense count: 4
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: io, id, to
# AllowedNames: io, id, to, by, on, in, at, ip, db
Naming/UncommunicativeMethodParamName:
Exclude:
- 'app/helpers/xen_compute_helper.rb'
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ source 'https://rubygems.org'

gemspec

gem 'rubocop', '~> 0.54.0', require: false
gem 'rubocop', '~> 0.60.0', require: false
1 change: 1 addition & 0 deletions app/controllers/foreman_xen/snapshots_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def destroy
snapshots = @compute_resource.find_snapshots
snapshots.each do |snapshot|
next unless snapshot.reference == ref

name = snapshot.name
snapshot.destroy
notice "Successfully deleted snapshot #{snapshot.name}"
Expand Down
12 changes: 5 additions & 7 deletions app/helpers/xen_compute_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,17 @@ def hosts_controller_compute_attribute_map(params, compute_resource, new)
compute_attributes = compute_resource.compute_profile_attributes_for(params['host']['compute_profile_id'])
attribute_map = filter_compute_attributes(attribute_map, compute_attributes)
elsif new
attribute_map[:cpu_count] = new.vcpus_max ? new.vcpus_max : nil
attribute_map[:memory_min] = new.memory_static_min ? new.memory_static_min : nil
attribute_map[:memory_max] = new.memory_static_max ? new.memory_static_max : nil
attribute_map[:cpu_count] = new.vcpus_max || nil
attribute_map[:memory_min] = new.memory_static_min || nil
attribute_map[:memory_max] = new.memory_static_max || nil
if new.vbds
vdi = new.vbds.first.vdi
if vdi
attribute_map[:volume_selected] = vdi.sr.uuid ? vdi.sr.uuid : nil
attribute_map[:volume_selected] = vdi.sr.uuid || nil
attribute_map[:volume_size] = vdi.virtual_size ? (vdi.virtual_size.to_i / 1_073_741_824).to_s : nil
end
end
if new.vifs
attribute_map[:network_selected] = new.vifs.first.network.name ? new.vifs.first.network.name : nil
end
attribute_map[:network_selected] = new.vifs.first.network.name || nil if new.vifs
end
attribute_map
end
Expand Down
13 changes: 9 additions & 4 deletions app/models/foreman_xen/xenserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def find_vm_by_uuid(uuid)
Foreman::Logging.exception("Failed retrieving xenserver vm by uuid #{uuid}", e)
raise(ActiveRecord::RecordNotFound) if e.message.include?('HANDLE_INVALID')
raise(ActiveRecord::RecordNotFound) if e.message.include?('VM.get_record: ["SESSION_INVALID"')

raise e
end

Expand Down Expand Up @@ -92,6 +93,7 @@ def storage_pools!

available_hypervisors.each do |host|
next unless sr.reference == host.suspend_image_sr

found = true
subresults[:name] = sr.name
subresults[:display_name] = sr.name + '(' + host.hostname + ')'
Expand Down Expand Up @@ -161,10 +163,11 @@ def associated_host(vm)

def find_snapshots_for_vm(vm)
return [] if vm.snapshots.empty?

tmps = begin
client.servers.templates.select(&:is_a_snapshot)
rescue
[]
rescue
[]
end
retval = []
tmps.each do |snapshot|
Expand All @@ -176,15 +179,16 @@ def find_snapshots_for_vm(vm)
def find_snapshots
tmps = begin
client.servers.templates.select(&:is_a_snapshot)
rescue
[]
rescue
[]
end
tmps.sort_by(&:name)
end

def new_vm(attr = {})
test_connection
return unless errors.empty?

opts = vm_instance_defaults.merge(attr.to_hash).symbolize_keys

%i[networks volumes].each do |collection|
Expand Down Expand Up @@ -422,6 +426,7 @@ def get_templates(templates)

def get_hypervisor_host(args)
return client.hosts.first unless args[:hypervisor_host] != ''

client.hosts.find { |host| host.name == args[:hypervisor_host] }
end

Expand Down
1 change: 1 addition & 0 deletions lib/foreman_xen/vnc_tunnel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def listen(client_srv)
begin
data = @client_socket.read_nonblock(1024)
break if data.nil?

@srv_socket.write(data)
rescue IO::WaitReadable => e
IO.select([@client_socket])
Expand Down

0 comments on commit c2b6782

Please sign in to comment.