Showing 46 of 50 total issues
File run_instance.rb
has 722 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'log4r'
require 'vagrant/util/retryable'
require 'vagrant-cloudstack/exceptions/exceptions'
require 'vagrant-cloudstack/util/timer'
require 'vagrant-cloudstack/model/cloudstack_resource'
Class RunInstance
has 49 methods (exceeds 20 allowed). Consider refactoring. Open
class RunInstance
include Vagrant::Util::Retryable
include VagrantPlugins::Cloudstack::Model
include VagrantPlugins::Cloudstack::Service
include VagrantPlugins::Cloudstack::Exceptions
Method call
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def call(env)
# Initialize metrics if they haven't been
env[:metrics] ||= {}
server = env[:cloudstack_compute].servers.get(env[:machine].id)
- 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 compose_server_creation_options
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def compose_server_creation_options
options = {
:display_name => @domain_config.display_name,
:group => @domain_config.group,
:zone_id => @zone.id,
- 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 finalize!
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def finalize!
INSTANCE_VAR_DEFAULT_NIL.each do |instance_variable|
# ... must be nil, since we can't default that
instance_variable_set("@#{instance_variable}", nil) if
instance_variable_get("@#{instance_variable}") == UNSET_VALUE
- 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_randomport_forwarding_rule
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def create_randomport_forwarding_rule(rule, randomrange, filename)
pf_public_port = rule[:publicport]
retryable(:on => DuplicatePFRule, :tries => 10) do
begin
# Only if public port is missing, will generate a random one
- 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 remove_volumes
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def remove_volumes(env)
volumes_file = env[:machine].data_dir.join('volumes')
if volumes_file.file?
env[:ui].info(I18n.t('vagrant_cloudstack.deleting_volumes'))
File.read(volumes_file).each_line do |line|
- 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 apply_port_forwarding_rules
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def apply_port_forwarding_rules
return if @domain_config.port_forwarding_rules.empty?
@domain_config.port_forwarding_rules.each do |port_forwarding_rule|
# Sanatize/defaults pf rule before applying
- 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 generate_firewall_rules_for_communicators
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def generate_firewall_rules_for_communicators
return if @pf_ip_address.is_undefined? ||
!@domain_config.pf_trusted_networks ||
@domain_config.pf_open_firewall
- 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 generate_firewall_rules_for_portforwarding_rules
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def generate_firewall_rules_for_portforwarding_rules
@pf_ip_address.details.has_key?('vpcid') ? port_name = :privateport : port_name = :publicport
unless @domain_config.port_forwarding_rules.empty?
@domain_config.port_forwarding_rules.each do |port_forwarding_rule|
- 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 remove_firewall_rules
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def remove_firewall_rules(env)
env[:ui].info(I18n.t('vagrant_cloudstack.deleting_firewall_rule'))
firewall_file = env[:machine].data_dir.join('firewall')
if firewall_file.file?
File.read(firewall_file).each_line do |line|
- 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 read_winrm_info
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def read_winrm_info(cloudstack, machine)
return nil if (server = find_server(cloudstack, machine)).nil?
# Get the Port forwarding config
domain = machine.provider_config.domain_id
- 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 call
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def call(env)
# Initialize metrics if they haven't been
env[:metrics] ||= {}
server = env[:cloudstack_compute].servers.get(env[:machine].id)
Method remove_firewall_rules
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def remove_firewall_rules(env)
env[:ui].info(I18n.t('vagrant_cloudstack.deleting_firewall_rule'))
firewall_file = env[:machine].data_dir.join('firewall')
if firewall_file.file?
File.read(firewall_file).each_line do |line|
Method remove_portforwarding
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def remove_portforwarding(env)
env[:ui].info(I18n.t('vagrant_cloudstack.deleting_port_forwarding_rule'))
port_forwarding_file = env[:machine].data_dir.join('port_forwarding')
if port_forwarding_file.file?
File.read(port_forwarding_file).each_line do |line|
- 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 store_password
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def store_password
password = nil
if @server.password_enabled and @server.respond_to?('job_id')
server_job_result = @env[:cloudstack_compute].query_async_job_result({:jobid => @server_job_id})
if server_job_result.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 apply_firewall_rule
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def apply_firewall_rule(acl_name, options, response_string, type_string)
firewall_rule = nil
begin
resp = @env[:cloudstack_compute].request(options)
job_id = resp[response_string]['jobid']
- 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 remove_security_groups
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def remove_security_groups(env)
security_groups_file = env[:machine].data_dir.join('security_groups')
if security_groups_file.file?
File.read(security_groups_file).each_line do |line|
security_group_id = line.strip
Method wait_for_communicator_ready
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def wait_for_communicator_ready
@env[:metrics]['instance_ssh_time'] = Util::Timer.time do
# Wait for communicator to be ready.
communicator_short_name = get_communicator_short_name(@env[:machine].communicate)
@env[:ui].info(
- 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 validate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def validate(machine)
errors = []
if @domain
# Get the configuration for the domain we're using and validate only that domain.
- 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"