Showing 9,400 of 17,590 total issues
Avoid deeply nested control flow statements. Open
Open
if part['data']['id'] in minion_tracker[queue]['minions']:
minion_tracker[queue]['minions'].remove(part['data']['id'])
else:
salt.utils.stringutils.print_cli('minion {0} was already deleted from tracker, probably a duplicate key'.format(part['id']))
else:
Avoid deeply nested control flow statements. Open
Open
if matches is None:
matches = []
# Resolve inc_sls in the specified environment
if env_key in matches or fnmatch.filter(self.avail[env_key], inc_sls):
Avoid deeply nested control flow statements. Open
Open
for hind in range(len(high[name][state])):
if isinstance(arg, six.string_types) and isinstance(high[name][state][hind], six.string_types):
# replacing the function, replace the index
high[name][state].pop(hind)
high[name][state].insert(hind, arg)
Avoid deeply nested control flow statements. Open
Open
if chunk.get('__prerequired__'):
# Prereq recusive, run this chunk with prereq on
if tag not in self.pre:
low['__prereq__'] = True
self.pre[ctag] = self.call(low, chunks, running)
Avoid deeply nested control flow statements. Open
Open
for tgt in targets:
top[saltenv][tgt] = ctop[saltenv][tgt]
except TypeError:
Avoid deeply nested control flow statements. Open
Open
for val in six.itervalues(slsmod):
if not val:
errors.append(
'Improperly formatted top file matcher '
'in saltenv {0}: {1} file'.format(
Avoid deeply nested control flow statements. Open
Open
if not resolved_envs:
msg = ('Unknown include: Specified SLS {0}: {1} is not available on the salt '
'master in saltenv(s): {2} '
).format(env_key,
inc_sls,
Function get_bnum
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def get_bnum(opts, minions, quiet):
'''
Return the active number of minions to maintain
'''
partition = lambda x: float(x) / 100.0 * len(minions)
- 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 state == 'require' or state == 'watch':
continue
errors.append(
Avoid deeply nested control flow statements. Open
Open
for fun in funcs:
live['fun'] = fun
chunks.append(live)
else:
Avoid deeply nested control flow statements. Open
Open
if not update:
high[name][state].append(arg)
return high, errors
Avoid deeply nested control flow statements. Open
Open
if not arg:
# Empty arg dict
# How did we get this far?
continue
# Split out the components
Avoid deeply nested control flow statements. Open
Open
if req_val is None:
continue
if req_key == 'sls':
Avoid deeply nested control flow statements. Open
Open
if sls in done[saltenv]:
continue
tops[saltenv].append(
Avoid deeply nested control flow statements. Open
Open
if env_key in matches or fnmatch.filter(self.avail[env_key], inc_sls):
resolved_envs = [env_key]
else:
resolved_envs = []
else:
Avoid deeply nested control flow statements. Open
Open
if isinstance(arg, six.string_types):
fun += 1
if ' ' in arg.strip():
errors.append(('The function "{0}" in state '
'"{1}" in SLS "{2}" has '
Avoid deeply nested control flow statements. Open
Open
if req_val is None:
continue
if req_key == 'sls':
Avoid deeply nested control flow statements. Open
Open
if isinstance(item, six.string_types):
matches[saltenv].append(item)
elif isinstance(item, dict):
env_key, inc_sls = item.popitem()
if env_key not in self.avail:
Avoid deeply nested control flow statements. Open
Open
if match:
levels, include = match.groups()
else:
msg = ('Badly formatted include {0} found in include '
'in SLS \'{2}:{3}\''
Avoid deeply nested control flow statements. Open
Open
if 'is not available' in error:
# match SLS foobar in environment
this_sls = 'SLS {0} in saltenv'.format(
sls_match)
if this_sls in error: