Showing 76 of 122 total issues
Method get_server
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def get_server
Maestro.log.info "Retrieving RightScale server information into the Composition"
# TODO: much duplication with start, but refactor after other changes for deployments land
- 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
Avoid deeply nested control flow statements. Open
Open
if !result.notices.nil?
puts "#{result.notices.size} Notices starting server (id=#{options[:server_id]} name=#{options[:server_name]})"
result.notices.each{|notice|
puts " #{notice.inspect}"
}
Avoid deeply nested control flow statements. Open
Open
elsif options[:operation] == 'stop-server'
result = helper.stop(options)
if options[:wait_until_stopped]
puts "Server (id=#{options[:server_id]} name=#{options[:server_name]}) stopped"
else
Avoid deeply nested control flow statements. Open
Open
if timeout_reset
timeout_left = timeout
reset = true
end
Avoid deeply nested control flow statements. Open
Open
if show_progress
@logger.info "#{indent}create_cloudflow_process(): Process state is now #{state}"
else
@logger.debug "#{indent}create_cloudflow_process(): Process state is now #{state}"
end
Avoid deeply nested control flow statements. Open
Open
if show_progress
@logger.info "#{indent}create_cloudflow_process(): Process state is #{state} (#{timeout-timeout_left}/#{timeout})"
else
@logger.debug "#{indent}create_cloudflow_process(): Process state is #{state} (#{timeout-timeout_left}/#{timeout})"
end
Avoid deeply nested control flow statements. Open
Open
if !result.errors.nil?
puts "#{result.errors.size} Errors starting server (id=#{options[:server_id]} name=#{options[:server_name]})"
result.errors.each{|error|
puts " #{error.message}, backtrace=#{error.backtrace}"
}
Avoid deeply nested control flow statements. Open
Open
if result.success
if options[:wait_until_started]
puts "Server (id=#{options[:server_id]} name=#{options[:server_name]}) started"
instance = result.value
puts " resource_uid: #{instance.resource_uid}"
Method validate_base_fields
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def validate_base_fields(missing_fields)
if get_field('account_id').nil?
missing_fields << 'account_id'
end
if get_field('refresh_token').nil? && get_field('username').nil? && get_field('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
Avoid too many return
statements within this method. Open
Open
return Result.new(:success => false, :errors => result.errors, :notices => result.notices)
Avoid too many return
statements within this method. Open
Open
return Result.new(:success => true, :errors => [e])
Avoid too many return
statements within this method. Open
Open
return Result.new(:success => false, :errors => [Exception.new(response_hash['summary'])])
Avoid too many return
statements within this method. Open
Open
return Result.new(:success => false, :errors => [e])
Avoid too many return
statements within this method. Open
Open
return Result.new(:success => false, :errors => [e])
Avoid too many return
statements within this method. Open
Open
return Result.new(:success => false, :errors => [Exception.new('Timed out waiting for CloudFlow to complete')])
Avoid too many return
statements within this method. Open
Open
return Result.new(:success => true, :value => process_id)
Avoid too many return
statements within this method. Open
Open
return Result.new(:success => false, :errors => [Exception.new("Couldn't find access token in response")], :value => data)
Avoid too many return
statements within this method. Open
Open
return Result.new(:success => false, :errors => [e])
Avoid too many return
statements within this method. Open
Open
return Result.new(:success => true, :value => server)
Avoid too many return
statements within this method. Open
Open
return Result.new(:success => false, :errors => [Exception.new(e.response['error_description'])], :value => e.response)