Showing 94 of 130 total issues
Method vm_clone
has a Cognitive Complexity of 418 (exceeds 5 allowed). Consider refactoring. Open
def vm_clone(options = {})
# Option handling
options = vm_clone_check_options(options)
# Options['template_path']<~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 vm_clone
has 376 lines of code (exceeds 25 allowed). Consider refactoring. Open
def vm_clone(options = {})
# Option handling
options = vm_clone_check_options(options)
# Options['template_path']<~String>
File compute.rb
has 704 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'digest/sha2'
# rubocop:disable Lint/RescueWithoutErrorClass
# rubocop:disable Metrics/ModuleLength
module Fog
module Vsphere
Method data
has 271 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.data
# rubocop:disable Metrics/BlockLength
@data ||= Hash.new do |hash, key|
hash[key] = {
servers: {
File vm_clone.rb
has 558 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Fog
module Vsphere
class Compute
module Shared
private
Class Server
has 52 methods (exceeds 20 allowed). Consider refactoring. Open
class Server < Fog::Compute::Server # rubocop:disable Metrics/ClassLength
extend Fog::Deprecation
deprecate(:ipaddress, :public_ip_address)
deprecate(:scsi_controller, :scsi_controllers)
Method props_to_attr_hash
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
def props_to_attr_hash(vm_mob_ref, props)
# NOTE: Object.tap is in 1.8.7 and later.
# Here we create the hash object that this method returns, but first we need
# to add a few more attributes that require additional calls to the vSphere
# API. The hypervisor name and mac_addresses attributes may not be available
- 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
File create_vm.rb
has 333 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Fog
module Vsphere
class Compute
# rubocop:disable Metrics/ClassLength
class Real
File server.rb
has 305 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'fog/compute/models/server'
module Fog
module Vsphere
class Compute
Method vm_clone_check_options
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def vm_clone_check_options(options)
default_options = {
'force' => false,
'linked_clone' => false,
'nic_type' => 'VirtualE1000'
- 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 props_to_attr_hash
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
def props_to_attr_hash(vm_mob_ref, props)
# NOTE: Object.tap is in 1.8.7 and later.
# Here we create the hash object that this method returns, but first we need
# to add a few more attributes that require additional calls to the vSphere
# API. The hypervisor name and mac_addresses attributes may not be available
Method cloudinit_to_customspec
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def cloudinit_to_customspec(user_data)
raise ArgumentError, "user_data can't be nil" if user_data.nil?
custom_spec = { 'customization_spec' => {} }
user_data = YAML.safe_load(user_data)
# https://pubs.vmware.com/vsphere-55/index.jsp#com.vmware.wssdk.apiref.doc/vim.vm.customization.Specification.html
- 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_raw_interface
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def get_raw_interface(vm_id, options = {})
raise ArgumentError, 'instance id is a required parameter' unless vm_id
if options.is_a? Fog::Vsphere::Compute::Interface
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 cloudinit_to_customspec
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def cloudinit_to_customspec(user_data)
raise ArgumentError, "user_data can't be nil" if user_data.nil?
custom_spec = { 'customization_spec' => {} }
user_data = YAML.safe_load(user_data)
custom_spec['encryptionKey'] = user_data['encryptionKey'] if user_data.key?('encryptionKey')
- 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_networks
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def list_networks(filters = {})
datacenter_name = filters[:datacenter]
cluster_name = filters.fetch(:cluster, nil)
# default to show all networks
only_active = filters[:accessible] || false
- 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 a Cognitive Complexity of 13 (exceeds 5 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 }
- 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_compute_resources
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def list_compute_resources(_filters = {})
[
{
id: 'domain-s7',
name: 'fake-host',
Method list_networks
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def list_networks(filters = {})
datacenter_name = filters[:datacenter]
cluster_name = filters.fetch(:cluster, nil)
# default to show all networks
only_active = filters[:accessible] || false
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 modify_template_nics_specs
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def modify_template_nics_specs(vm_mob_ref, nics, datacenter)
specs = []
template_nics = vm_mob_ref.config.hardware.device.grep(RbVmomi::VIM::VirtualEthernetCard)
modified_nics = nics.take(template_nics.size)
new_nics = nics.drop(template_nics.size)