Showing 255 of 2,705 total issues
Method getStockImage
has a Cognitive Complexity of 80 (exceeds 75 allowed). Consider refactoring. Open
Open
def self.getStockImage(cloud = MU::Config.defaultCloud, platform: nil, region: nil, fail_hard: false, quiet: false)
if !MU::Cloud.supportedClouds.include?(cloud)
MU.log "'#{cloud}' is not a supported cloud provider! Available providers:", MU::ERR, details: MU::Cloud.supportedClouds
raise MuError, "'#{cloud}' is not a supported cloud provider!"
- 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 schema
has 152 lines of code (exceeds 150 allowed). Consider refactoring. Open
Open
def self.schema(_config)
toplevel_required = []
schema = {
"disabled" => {
Method create_update
has 151 lines of code (exceeds 150 allowed). Consider refactoring. Open
Open
def create_update
ipcfg = MU::Cloud::Azure.network(:NetworkInterfaceIPConfiguration).new
ipcfg.name = @mu_name
ipcfg.private_ipallocation_method = MU::Cloud::Azure.network(:IPAllocationMethod)::Dynamic
Avoid deeply nested control flow statements. Open
Open
if e.message.match(/Cannot delete an inactive project/)
# this is fine
else
MU.log "Got #{e.message} trying to delete project #{p.project_id} (#{p.name})", MU::ERR
next
Avoid deeply nested control flow statements. Open
Open
MU.log "Filesystem #{pool.name}: #{pool.file_system_id} already deleted", MU::NOTICE if e.to_s.start_with?("invalid file system ID")
Avoid deeply nested control flow statements. Open
Open
raise MuError, "Failed to delete filesystem #{pool.name}: #{pool.file_system_id}, still in use." if attempts >= 6
Avoid deeply nested control flow statements. Open
Open
elsif entitytype == "role"
resp = MU::Cloud::AWS.iam(credentials: @credentials).list_attached_role_policies(
role_name: entityname
)
Avoid deeply nested control flow statements. Open
Open
semanage_pkg = if node['platform_version'].to_i < 6
"policycoreutils"
elsif node['platform_version'].to_i < 8
"policycoreutils-python"
else
Avoid deeply nested control flow statements. Open
Open
MU.log "Disabling CloudFront distribution #{my_name ? my_name : ids[my_arn].id})", MU::NOTICE
Avoid deeply nested control flow statements. Open
Open
if id.match(/:log-group:/)
stream_id = id.sub(/:([^:]+)$/, ":log-stream:*")
# "arn:aws:logs:us-east-2:accountID:log-group:log_group_name:log-stream:CloudTrail_log_stream_name_prefix*"
statement["Resource"] << stream_id
elsif id.match(/:s3:/)
Avoid deeply nested control flow statements. Open
Open
if report_data and !report_data.empty?
report ||= {}
report[elt_namestr] = report_data
end
Avoid deeply nested control flow statements. Open
Open
return name_only ? "#default" : @@my_hosted_cfg
Avoid deeply nested control flow statements. Open
Open
elsif new_args.is_a?(Hash)
new_args[page_markers[paginator]] = new_page
Avoid deeply nested control flow statements. Open
Open
MU.log e.message+" - Google admin bucket #{adminBucketName(credentials)}/#{name} with #{credentials ? credentials : "default"} credentials", MU::DEBUG, details: aclobj
Avoid deeply nested control flow statements. Open
Open
MU.log "External Google user specified with no role binding, will grant 'viewer' in #{my_org ? "organization #{my_org.display_name}" : "project #{user['project']}"}", MU::WARN
Avoid deeply nested control flow statements. Open
Open
elsif dnsrec["type"] == "A"
if public
# Make sure we have a public IP address to register. Use the private one if we don't
deploydata['public_ip_address'] ? deploydata['public_ip_address'] : deploydata['private_ip_address']
else
Avoid deeply nested control flow statements. Open
Open
raise MuError, "No valid credentials available! Either grant admin privileges to machine service account, or manually add a different one with mu-configure" if found.nil?
Avoid deeply nested control flow statements. Open
Open
rescue
MU.log function['code']['zip_file']+" does not contain function.js or index.js, at least one must be present for runtime #{function['runtime']}", MU::ERR
ok = false
Avoid deeply nested control flow statements. Open
Open
if e.message.match(/failedPrecondition/) and retries < max_retries
sleep 30
retries += 1
retry
else
Method find
has a Cognitive Complexity of 78 (exceeds 75 allowed). Consider refactoring. Open
Open
def self.find(**args)
credcfg = MU::Cloud::Google.credConfig(args[:credentials])
customer = MU::Cloud::Google.customerID(args[:credentials])
my_org = MU::Cloud::Google.getOrg(args[:credentials])
- 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"