ManageIQ/manageiq-providers-ovirt

View on GitHub

Showing 37 of 37 total issues

Method vms has a Cognitive Complexity of 29 (exceeds 11 allowed). Consider refactoring.
Open

def vms
vms = Array(collector.vms) + Array(collector.templates)
vms.compact.each do |vm|
# Skip the place holder template
next if vm.id == '00000000-0000-0000-0000-000000000000'
Severity: Minor
Found in app/models/manageiq/providers/ovirt/inventory/parser/infra_manager.rb - About 3 hrs to fix

Cyclomatic complexity for vms is too high. [18/11]
Open

def vms
vms = Array(collector.vms) + Array(collector.templates)
vms.compact.each do |vm|
# Skip the place holder template
next if vm.id == '00000000-0000-0000-0000-000000000000'

Cyclomatic complexity for vm_hardware_guest_devices is too high. [15/11]
Open

def vm_hardware_guest_devices(persister_hardware, vm, addresses, host)
networks = {}
addresses.each do |mac, address|
network = persister.networks.lazy_find(
:hardware => persister_hardware,

Method vm_reconfigure has a Cognitive Complexity of 21 (exceeds 11 allowed). Consider refactoring.
Open

def vm_reconfigure(vm, options = {})
log_header = "EMS: [#{ext_management_system.name}] #{vm.class.name}: id [#{vm.id}], name [#{vm.name}], ems_ref [#{vm.ems_ref}]"
spec = options[:spec]
 
_log.info("#{log_header} Started...")
Severity: Minor
Found in app/models/manageiq/providers/ovirt/infra_manager/ovirt_services.rb - About 1 hr to fix

Method vm_hardware_guest_devices has a Cognitive Complexity of 21 (exceeds 11 allowed). Consider refactoring.
Open

def vm_hardware_guest_devices(persister_hardware, vm, addresses, host)
networks = {}
addresses.each do |mac, address|
network = persister.networks.lazy_find(
:hardware => persister_hardware,

Cyclomatic complexity for vm_reconfigure is too high. [13/11]
Open

def vm_reconfigure(vm, options = {})
log_header = "EMS: [#{ext_management_system.name}] #{vm.class.name}: id [#{vm.id}], name [#{vm.name}], ems_ref [#{vm.ems_ref}]"
spec = options[:spec]
 
_log.info("#{log_header} Started...")

Method ensure_network_manager has a Cognitive Complexity of 16 (exceeds 11 allowed). Consider refactoring.
Open

def ensure_network_manager
providers = ovirt_services.collect_external_network_providers
 
unless providers.blank?
providers = providers.sort_by(&:name)
Severity: Minor
Found in app/models/manageiq/providers/ovirt/infra_manager.rb - About 1 hr to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

{
:component => "text-field",
:id => "authentications.ws.userid",
:name => "authentications.ws.userid",
:label => _("Username"),
Severity: Minor
Found in app/models/manageiq/providers/ovirt/infra_manager/host.rb and 1 other location - About 45 mins to fix
app/models/manageiq/providers/ovirt/infra_manager/host.rb on lines 67..83

Similar blocks of code found in 2 locations. Consider refactoring.
Open

{
:component => "text-field",
:id => "authentications.remote.userid",
:name => "authentications.remote.userid",
:label => _("Username"),
Severity: Minor
Found in app/models/manageiq/providers/ovirt/infra_manager/host.rb and 1 other location - About 45 mins to fix
app/models/manageiq/providers/ovirt/infra_manager/host.rb on lines 123..139

Method hardware_disks has a Cognitive Complexity of 14 (exceeds 11 allowed). Consider refactoring.
Open

def hardware_disks(persister_hardware, disks)
return if disks.blank?
 
disks = Array.wrap(disks).sort_by do |disk|
match = disk.try(:name).match(/disk[^\d]*(?<index>\d+)/i)
Severity: Minor
Found in app/models/manageiq/providers/ovirt/inventory/parser/infra_manager.rb - About 45 mins to fix

Similar blocks of code found in 4 locations. Consider refactoring.
Open

def create_cloud_network_queue(userid, options = {})
task_opts = {
:action => "creating Cloud Network for user #{userid}",
:userid => userid
}
Severity: Major
Found in app/models/manageiq/providers/ovirt/network_manager.rb and 3 other locations - About 35 mins to fix
app/models/manageiq/providers/ovirt/network_manager.rb on lines 68..82
app/models/manageiq/providers/ovirt/network_manager.rb on lines 89..103
app/models/manageiq/providers/ovirt/network_manager.rb on lines 110..124

Similar blocks of code found in 4 locations. Consider refactoring.
Open

def create_security_group_queue(userid, options = {})
task_opts = {
:action => "creating Security Group for user #{userid}",
:userid => userid
}
Severity: Major
Found in app/models/manageiq/providers/ovirt/network_manager.rb and 3 other locations - About 35 mins to fix
app/models/manageiq/providers/ovirt/network_manager.rb on lines 43..57
app/models/manageiq/providers/ovirt/network_manager.rb on lines 68..82
app/models/manageiq/providers/ovirt/network_manager.rb on lines 89..103

Similar blocks of code found in 4 locations. Consider refactoring.
Open

def create_network_router_queue(userid, options = {})
task_opts = {
:action => "creating Network Router for user #{userid}",
:userid => userid
}
Severity: Major
Found in app/models/manageiq/providers/ovirt/network_manager.rb and 3 other locations - About 35 mins to fix
app/models/manageiq/providers/ovirt/network_manager.rb on lines 43..57
app/models/manageiq/providers/ovirt/network_manager.rb on lines 89..103
app/models/manageiq/providers/ovirt/network_manager.rb on lines 110..124

Similar blocks of code found in 4 locations. Consider refactoring.
Open

def create_floating_ip_queue(userid, options = {})
task_opts = {
:action => "creating Floating IP for user #{userid}",
:userid => userid
}
Severity: Major
Found in app/models/manageiq/providers/ovirt/network_manager.rb and 3 other locations - About 35 mins to fix
app/models/manageiq/providers/ovirt/network_manager.rb on lines 43..57
app/models/manageiq/providers/ovirt/network_manager.rb on lines 68..82
app/models/manageiq/providers/ovirt/network_manager.rb on lines 110..124

Similar blocks of code found in 2 locations. Consider refactoring.
Open

{
:component => 'protocol-selector',
:id => 'keypairEnable',
:name => 'keypairEnable',
:skipSubmit => true,
Severity: Minor
Found in app/models/manageiq/providers/ovirt/infra_manager.rb and 1 other location - About 25 mins to fix
app/models/manageiq/providers/ovirt/infra_manager.rb on lines 230..247

Similar blocks of code found in 2 locations. Consider refactoring.
Open

{
:component => 'protocol-selector',
:id => 'metricsEnable',
:name => 'metricsEnable',
:skipSubmit => true,
Severity: Minor
Found in app/models/manageiq/providers/ovirt/infra_manager.rb and 1 other location - About 25 mins to fix
app/models/manageiq/providers/ovirt/infra_manager.rb on lines 306..323

Identical blocks of code found in 2 locations. Consider refactoring.
Open

def parse_targeted_inventory(ems, _target, inventory)
log_header = format_ems_for_logging(ems)
_log.debug("#{log_header} Parsing inventory...")
hashes, = Benchmark.realtime_block(:parse_inventory) do
inventory.parse
app/models/manageiq/providers/ovirt/infra_manager/refresher.rb on lines 53..61

Identical blocks of code found in 2 locations. Consider refactoring.
Open

def parse_targeted_inventory(ems, _target, inventory)
log_header = format_ems_for_logging(ems)
_log.debug "#{log_header} Parsing inventory..."
hashes, = Benchmark.realtime_block(:parse_inventory) do
inventory.parse
Severity: Minor
Found in app/models/manageiq/providers/ovirt/infra_manager/refresher.rb and 1 other location - About 20 mins to fix
app/models/manageiq/providers/ovirt/network_manager/refresher.rb on lines 18..26

Avoid rescuing the Exception class. Perhaps you meant to rescue StandardError?
Open

rescue Exception => e
self.class.handle_credentials_verification_error(e)

Use filter_map instead.
Open

references(:hosts).map do |ems_ref|
connection.system_service.hosts_service.host_service(uuid_from_ems_ref(ems_ref)).get
rescue OvirtSDK4::Error # when 404
nil
end.compact
Severity
Category
Status
Source
Language