Showing 255 of 2,705 total issues
Avoid deeply nested control flow statements. Open
Open
if step["adjustment"].nil?
MU.log "You must specify 'adjustment' for 'step_adjustments' when 'policy_type' is set to 'StepScaling'", MU::ERR
ok = false
end
Avoid deeply nested control flow statements. Open
Open
if disable
attr[:userAccountControl] = (attr[:userAccountControl].to_i & AD_PW_ATTRS['disable']).to_s
end
Avoid deeply nested control flow statements. Open
Open
for c in (0..(path.size-1)) do
path_str << (" " * (c+2)) + (path[c] || "<nil>")
end
Avoid deeply nested control flow statements. Open
Open
if !@config["vpc"]["vpc_name"].nil? and @dependencies.has_key?("vpc") and @dependencies["vpc"].has_key?(@config["vpc"]["vpc_name"])
igw_name, igw_template = MU::Cloud::CloudFormation.cloudFormationBase("vpcgwattach", name: @dependencies["vpc"][@config["vpc"]["vpc_name"]].cloudobj.mu_name, scrub_mu_isms: @config['scrub_mu_isms'])
MU::Cloud::CloudFormation.setCloudFormationProp(eip_template[eip_name], "DependsOn", igw_name)
end
Avoid deeply nested control flow statements. Open
Open
if policy['target_tracking_configuration']["preferred_target_group"] and
lb["targetgroups"][policy['target_tracking_configuration']["preferred_target_group"]]
lb["arn"].split(/:/)[5].sub(/^loadbalancer\//, "")+"/"+lb["targetgroups"][policy['target_tracking_configuration']["preferred_target_group"]].split(/:/)[5]
else
if policy['target_tracking_configuration']["preferred_target_group"]
Avoid deeply nested control flow statements. Open
Open
plain = (name ? name : type_of) if name or type_of
Avoid deeply nested control flow statements. Open
Open
if tier[:value].is_a?(Hash)
if name
tier[:value].delete("entity")
tier[:value].delete(name.sub(/\[.*/, '')) if name
end
Avoid deeply nested control flow statements. Open
Open
elsif cfg.id
littermate = deploy.findLitterMate(type: cfg.type, cloud_id: cfg.id, habitat: cfg.habitat)
if littermate and littermate.config['name']
hashcfg['name'] = littermate.config['name']
hashcfg.delete("id") if hashcfg["name"]
Method initialize
has a Cognitive Complexity of 78 (exceeds 75 allowed). Consider refactoring. Open
Open
def initialize(path, skipinitialupdates = false, params: {}, updating: nil, default_credentials: nil, cloud: nil)
$myPublicIp ||= MU.mu_public_ip
$myRoot ||= MU.myRoot
$myRoot.freeze
- 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 !subnet['nat_host_name'].nil?
configurator.nat_routes[subnet['name'].to_s] << subnet['nat_host_name'].to_s
end
Avoid deeply nested control flow statements. Open
Open
unless policy['type']
MU.log "You must specify a 'type' when 'policy_type' is set to 'StepScaling'", MU::ERR
ok = false
end
Avoid deeply nested control flow statements. Open
Open
if step["lower_bound"].nil? && step["upper_bound"].nil?
MU.log "You must specify 'lower_bound' and/or upper_bound for 'step_adjustments' when 'policy_type' is set to 'StepScaling'", MU::ERR
ok = false
end
Avoid deeply nested control flow statements. Open
Open
if sub["endpoint"].match(/^http:/i)
"http"
elsif sub["endpoint"].match(/^https:/i)
"https"
elsif sub["endpoint"].match(/:sqs:/i)
Avoid deeply nested control flow statements. Open
Open
if dnsrec["type"] == "CNAME"
if public
deploydata['public_dns_name'].empty? ? deploydata['private_dns_name'] : deploydata['public_dns_name']
else
deploydata['private_dns_name']
Avoid deeply nested control flow statements. Open
Open
if sib_by_name.size == 1
@vpc = sib_by_name.values.first
MU.log "Single VPC match for #{self}", loglevel, details: @vpc.to_s
else
# XXX ok but this is the wrong place for this really the config parser needs to sort this out somehow
Avoid deeply nested control flow statements. Open
Open
MU.log "#{@deploy_id}'s original config has #{@original_config[type].size == 1 ? "a" : @original_config[type].size.to_s} #{type}, but loadObjects could not populate anything from deployment metadata", MU::ERR if !@object_load_fails
Avoid deeply nested control flow statements. Open
Open
if public
{ "Fn::GetAtt" => [@dependencies["server"][dnsrec['target']].cloudobj.cfm_name, "PublicDnsName"] }
else
{ "Fn::GetAtt" => [@dependencies["server"][dnsrec['target']].cloudobj.cfm_name, "PrivateDnsName"] }
end
Avoid deeply nested control flow statements. Open
Open
configurator.nat_routes[subnet['name'].to_s] = [] if configurator.nat_routes[subnet['name'].to_s].nil?
Avoid deeply nested control flow statements. Open
Open
if wait >= 30
MU.log "User #{user} has been created in LDAP, but local system can't see it. Are PAM/LDAP configured correctly?", MU::ERR
return false
end
Avoid deeply nested control flow statements. Open
Open
if used_uids.include?(change_uid)
raise MuLDAPError, "Uid #{change_uid} is unavailable, cannot allocate to user #{user}"
end