File vmware.rb
has 719 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'fog_extensions/vsphere/mini_servers'
require 'foreman/exception'
begin
require 'rbvmomi'
Class Vmware
has 71 methods (exceeds 20 allowed). Consider refactoring. Open
class Vmware < ComputeResource
include ComputeResourceConsoleCommon
include ComputeResourceCaching
validates :user, :password, :server, :datacenter, :presence => true
Method guest_types_descriptions
has 197 lines of code (exceeds 25 allowed). Consider refactoring. Open
def guest_types_descriptions
{
"almalinux_64Guest" => "AlmaLinux (64-bit)",
"amazonlinux2_64Guest" => "Amazon Linux 2 (64 bit)",
"amazonlinux3_64Guest" => "Amazon Linux 3 (64 bit)",
Method normalize_vm_attrs
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
def normalize_vm_attrs(vm_attrs)
normalized = slice_vm_attributes(vm_attrs, ['cpus', 'firmware', 'guest_id', 'annotation', 'resource_pool_id', 'image_id'])
normalized['cores_per_socket'] = vm_attrs['corespersocket']
normalized['memory'] = vm_attrs['memory_mb'].nil? ? nil : (vm_attrs['memory_mb'].to_i * 1024)
Method clone_vm
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def clone_vm(raw_args)
args = parse_args(raw_args)
opts = {
"datacenter" => 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_vm
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def create_vm(args = { })
vm = nil
test_connection
return unless errors.empty?
- 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 clone_vm
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def clone_vm(raw_args)
args = parse_args(raw_args)
opts = {
"datacenter" => datacenter,
Method normalize_vm_attrs
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def normalize_vm_attrs(vm_attrs)
normalized = slice_vm_attributes(vm_attrs, ['cpus', 'firmware', 'guest_id', 'annotation', 'resource_pool_id', 'image_id'])
normalized['cores_per_socket'] = vm_attrs['corespersocket']
normalized['memory'] = vm_attrs['memory_mb'].nil? ? nil : (vm_attrs['memory_mb'].to_i * 1024)
- 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 save_vm
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def save_vm(uuid, attr)
vm = find_vm_by_uuid(uuid)
vm.attributes.merge!(attr.deep_symbolize_keys)
# volumes are not part of vm.attributes so we have to set them seperately if needed
if attr.has_key?(:volumes_attributes)
- 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 parse_args
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def parse_args(args)
args = args.deep_symbolize_keys
# convert rails nested_attributes into a plain, symbolized hash
[:interfaces, :volumes].each do |collection|
- 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 client
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def client
@client ||= ::Fog::Compute.new(
:provider => "vsphere",
:vsphere_username => user,
:vsphere_password => password,
- 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"