File create_vm.rb
has 319 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Fog
module Vsphere
class Compute
class Real
def create_vm(attributes = {})
Method create_vm
has a Cognitive Complexity of 13 (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 create_vm
has 34 lines of code (exceeds 25 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
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 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_vm_on_storage_pod
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_vm_on_storage_pod(vm_pod_name, volumes, vm_cfg, vmFolder, resource_pool, datacenter, host = nil)
Method pod_selection_spec
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def pod_selection_spec(vm_pod_name, disks_per_pod, datacenter, with_relocation: false, only_volumes: false)
raw_pods = {}
raw_pods[vm_pod_name] = get_raw_storage_pod(vm_pod_name, datacenter)
disks_per_pod.each_key { |pod_name| raw_pods[pod_name] ||= get_raw_storage_pod(pod_name, datacenter) }
- 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 create_controller
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create_controller(controller = nil, index = 0)
options = if controller
controller_default_options.merge(controller.attributes)
else
controller_default_options
- 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 create_disk
has a Cognitive Complexity of 7 (exceeds 5 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
- 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 controller_get_shared_from_options
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def controller_get_shared_from_options(options)
if (options.key?(:shared) && (options[:shared] == false)) || (!options.key? :shared)
:noSharing
elsif options[:shared] == true
:virtualSharing
- 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"