Method to_xml
has a Cognitive Complexity of 91 (exceeds 5 allowed). Consider refactoring. Open
def to_xml
builder = Nokogiri::XML::Builder.new do |xml|
xml.domain(:type => domain_type) do
xml.name(name)
xml.memory(memory_size)
- 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 server.rb
has 530 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'fog/compute/models/server'
require 'fog/libvirt/models/compute/util/util'
require 'fileutils'
module Fog
Class Server
has 44 methods (exceeds 20 allowed). Consider refactoring. Open
class Server < Fog::Compute::Server
include Fog::Libvirt::Util
attr_reader :xml
identity :id, :aliases => 'uuid'
Method to_xml
has 132 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_xml
builder = Nokogiri::XML::Builder.new do |xml|
xml.domain(:type => domain_type) do
xml.name(name)
xml.memory(memory_size)
Method create_or_clone_volume
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def create_or_clone_volume
options = {:name => volume_name || default_volume_name}
# Check if a disk template was specified
if volume_template_name
template_volume = service.volumes.all(:name => volume_template_name).first
- 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
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def save
raise Fog::Errors::Error.new('Saving an existing server may create a duplicate') unless new?
create_or_clone_volume unless xml or @volumes
create_user_data_iso if user_data
@xml ||= to_xml
- 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 addresses_ip_command
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def addresses_ip_command(service_arg=service, options={})
mac=self.mac
# Aug 24 17:34:41 juno arpwatch: new station 10.247.4.137 52:54:00:88:5a:0a eth0.4
# Aug 24 17:37:19 juno arpwatch: changed ethernet address 10.247.4.137 52:54:00:27:33:00 (52:54:00:88:5a:0a) eth0.4
- 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 setup
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def setup(credentials = {})
requires :public_key, :ssh_ip_address, :username
credentials[:proxy]= ssh_proxy unless ssh_proxy.nil?
credentials[:password] = password unless self.password.nil?
- 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 ssh_ip_command
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def ssh_ip_command(ip_command, uri)
# Retrieve the parts we need from the service to setup our ssh options
user=uri.user #could be nil
host=uri.host
keyfile=uri.keyfile
- 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 initialize_nics
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def initialize_nics
if nics
nics.map! { |nic| nic.is_a?(Hash) ? service.nics.new(nic) : nic }
else
self.nics = [service.nics.new({:type => network_interface_type, :bridge => network_bridge_name, :network => network_nat_network})]
- 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 addresses_dhcp
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def addresses_dhcp(service_arg=service, options={})
mac=self.mac
ip_address = nil
nic = self.nics.find {|nic| nic.mac==mac}
- 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 initialize_volumes
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def initialize_volumes
if attributes[:volumes] && !attributes[:volumes].empty?
@volumes = attributes[:volumes].map { |vol| vol.is_a?(Hash) ? service.volumes.new(vol) : vol }
end
end
- 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"