Showing 94 of 130 total issues
Method create_vm
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create_vm(attributes = {})
# build up vm configuration
cluster = get_raw_cluster(attributes[:cluster], attributes[:datacenter])
raise Fog::Vsphere::Compute::NotFound, "Cluster #{attributes[:cluster]} Doesn't Exist in the DC!" unless cluster
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method list_folders
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def list_folders(filters = {})
path = filters[:path] || filters['path'] || ''
datacenter_name = filters[:datacenter]
# if we don't need to display folders for a specific path
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method get_vm_by_name
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def get_vm_by_name(name, dc, folder, recursive)
vms = if folder
# This returns an Enumerator, which when called with .find will
# search only until it finds the VM we're looking for
raw_list_all_virtual_machines_in_folder(folder, dc, recursive)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method vm_relocate
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def vm_relocate(options = {})
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
# Find the VM Object
search_filter = { :uuid => options['instance_uuid'], 'vmSearch' => true, 'instanceUuid' => true }
Method connect
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def connect
# This is a state variable to allow digest validation of the SSL cert
bad_cert = false
loop do
begin
Method list_hosts
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def list_hosts(filters = {})
cluster = get_raw_cluster(filters[:cluster], filters[:datacenter])
results = property_collector_results(host_system_filter_spec(cluster))
Method vm_clone_check_options
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def vm_clone_check_options(options)
default_options = {
'force' => false,
'linked_clone' => false,
'nic_type' => 'VirtualE1000'
Method get_raw_folder
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_raw_folder(path, datacenter_name_or_obj, type)
# The required path syntax - 'topfolder/subfolder
# Clean up path to be relative since we're providing datacenter name
dc = if datacenter_name_or_obj.is_a?(String)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method list_vm_volumes
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def list_vm_volumes(vm_id)
get_vm_ref(vm_id).disks.map do |vol|
{
id: vol.backing.uuid,
thin: (begin
Method modify_template_nics_simple_spec
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def modify_template_nics_simple_spec(network_label, nic_type, network_adapter_device_key, datacenter)
config_spec_operation = RbVmomi::VIM::VirtualDeviceConfigSpecOperation('edit')
# Get the portgroup and handle it from there.
network = get_raw_network(network_label, datacenter)
nic_backing_info = if network.is_a? RbVmomi::VIM::DistributedVirtualPortgroup
Method boot_order
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def boot_order(attributes, vm_cfg)
# attributes[:boot_order] may be an array like this ['network', 'disk']
# stating, that we want to prefer network boots over disk boots
boot_order = []
attributes[:boot_order].each do |boot_device|
Method create_disk
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_disk(disk, operation = :add, options = {})
# If we deploy the vm on a storage pod, datastore has to be an empty string
datastore = if options[:storage_pod]
''
else
Method list_child_snapshots
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def list_child_snapshots(_snapshot, _opts = {})
[
{
name: 'clean',
quiesced: false,
Method vm_reconfig_cdrom
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def vm_reconfig_cdrom(options = {})
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
# Attach iso / disattach
if options.key?('iso')
raise ArgumentError, 'datastore is a required parameter' unless options.key? 'datastore'
Method list_vm_snapshots
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def list_vm_snapshots(vm_id, _opts = {})
[
{
name: 'clean',
quiesced: false,
Method vm_reconfig_cdrom
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def vm_reconfig_cdrom(options = {})
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
if options.key?('iso')
raise ArgumentError, 'datastore is a required parameter' unless options.key? 'datastore'
backing = {
Method choose_finder
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def choose_finder(ref_or_name, distributedswitch)
case distributedswitch
when String
# only the one will do
proc do |n|
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method get_vm_ref
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def get_vm_ref(id, dc = nil, folder = nil, recursive = false)
raw_datacenter = find_raw_datacenter(dc) if dc
vm = case is_uuid?(id)
# UUID based
when true
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method vm_reconfig_cdrom
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def vm_reconfig_cdrom(options = {})
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
# Attach iso / disattach
if options.key?('iso')
raise ArgumentError, 'datastore is a required parameter' unless options.key? 'datastore'
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method vm_migrate
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def vm_migrate(options = {})
# priority is the only required option, and it has a sane default option.
priority = options['priority'].nil? ? 'defaultPriority' : options['priority']
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"