Showing 255 of 2,705 total issues
Method create
has a Cognitive Complexity of 80 (exceeds 75 allowed). Consider refactoring. Open
Open
def create
@cfm_name, @cfm_template = MU::Cloud::CloudFormation.cloudFormationBase(self.class.cfg_name, self, tags: @config['tags'], scrub_mu_isms: @config['scrub_mu_isms']) if @cfm_template.nil?
@cfm_launch_name, launch_template = MU::Cloud::CloudFormation.cloudFormationBase("launch_config", self, scrub_mu_isms: @config['scrub_mu_isms'])
MU::Cloud::CloudFormation.setCloudFormationProp(@cfm_template[@cfm_name], "LaunchConfigurationName", { "Ref" => @cfm_launch_name } )
MU::Cloud::CloudFormation.setCloudFormationProp(@cfm_template[@cfm_name], "DependsOn", @cfm_launch_name)
- 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
child_params = Hash.new if child_params.nil?
Avoid deeply nested control flow statements. Open
Open
break if elt == other_elt # if they're identical, we're done
Avoid deeply nested control flow statements. Open
Open
if name.nil?
# Aws.config = {
# access_key_id: data['access_key'],
# secret_access_key: data['access_secret'],
# region: cred_cfg['region']
Avoid deeply nested control flow statements. Open
Open
if retval.error
raise MuError, retval.error.message
end
Avoid deeply nested control flow statements. Open
Open
if retries < max_retries
sleep 30
retries += 1
puts retries
else
Avoid deeply nested control flow statements. Open
Open
if e.message.match(/failedPrecondition/) and retries < max_retries
sleep 30
retries += 1
retry
else
Avoid deeply nested control flow statements. Open
Open
subnet.private? ? priv_nets << { "Ref" => "#{subnet.cfm_name}" } : pub_nets << { "Ref" => "#{subnet.cfm_name}" }
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
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
if !resp or !resp.attached_policies.map { |a_p| a_p.policy_name }.include?(p.policy_name)
MU.log "Attaching policy #{p.policy_name} to group #{entityname}", MU::NOTICE
MU::Cloud::AWS.iam(credentials: @credentials).attach_group_policy(
policy_arn: p.arn,
group_name: entityname
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
rescue Aws::EFS::Errors::BadRequest => e
MU.log "Mount target #{mp.mount_target_id} already deleted", MU::NOTICE if e.to_s.start_with?("invalid mount target ID")
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
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
if subpaths.size > 0
p_arn = "arn:"+(MU::Cloud::AWS.isGovCloud?(@region) ? "aws-us-gov" : "aws")+":iam::aws:policy/#{subpaths.shift}/"+policy
retry
end
Avoid deeply nested control flow statements. Open
Open
if type['level'] == node['glusterfs']['server']['raid_level'] and type['spare'] == node['glusterfs']['server']['raid_spare_vol'] and node['glusterfs']['server']['devices'].size >= type['min_devcies']
raid_no_spare(node['glusterfs']['server']['raid_dev'], node['glusterfs']['server']['raid_level'], node['glusterfs']['server']['devices'].size, node['glusterfs']['server']['devices'].join(" "))
end
Avoid deeply nested control flow statements. Open
Open
if new_args.size == 1 and new_args.first.is_a?(Hash)
new_args[0][page_markers[paginator]] = new_page
else
MU.log "I don't know how to insert a #{paginator} into these arguments for #{method_sym}", MU::WARN, details: new_args
end