Showing 9,400 of 17,590 total issues
Function bootstrap
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def bootstrap(version='develop',
script=None,
hosts='',
script_args='',
roster='flat',
- 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
if isinstance(result, list):
# Errors were detected
raise CommandExecutionError(
'Failed up update winrepo remotes: {0}'.format(
'\n'.join(result)
Avoid deeply nested control flow statements. Open
if 'name' not in result:
# Highstate output dict, the results are actually nested
# one level down.
key = next(iter(result))
result = result[key]
Avoid deeply nested control flow statements. Open
if 'connection_stats' in display_fields:
connection_stats = '{state} {active}/{received}/{accepted}/{damped}'.format(
state=neighbor.get('connection_state', -1),
active=neighbor.get('active_prefix_count', -1),
received=neighbor.get('received_prefix_count', -1),
Avoid deeply nested control flow statements. Open
if fnmatch.fnmatch(ret[item]['Function'], key):
_match = True
Function _find_vm
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _find_vm(name, data, quiet=False):
'''
Scan the query data for the named VM
'''
for hv_ in data:
- 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
if ipnet_obj and neighbor.get('remote_address'):
neighbor_ip_obj = IPAddress(neighbor.get('remote_address'))
if neighbor_ip_obj not in ipnet_obj:
# Neighbor not in this network
continue
Avoid deeply nested control flow statements. Open
if 'interface_description' in display_fields or 'interface_name' in display_fields:
net_find = __salt__['net.interfaces'](device=minion,
ipnet=neighbor.get('remote_address'),
display=False)
if net_find:
Function render
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def render(genshi_data, saltenv='base', sls='', method='xml', **kws):
'''
Render a Genshi template. A method should be passed in as part of the
kwargs. If no method is passed in, xml is assumed. Valid methods are:
- 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
for item in record.get(key):
ret[key] = item
if key in lists:
Avoid deeply nested control flow statements. Open
if self.as_list:
# Make list
temp = {}
crd[ret[i]] = [crd[ret[i]], temp]
crd = temp
Avoid deeply nested control flow statements. Open
if not isinstance(crd[ret[nk]], list):
crd[ret[nk]] = [crd[ret[nk]]]
# if it's already a list, do nothing
else:
Avoid deeply nested control flow statements. Open
if k.startswith(prefix):
tmplctx[k[len(prefix):]] = tmplctx[k]
del tmplctx[k]
else:
Avoid deeply nested control flow statements. Open
if '=' in item:
skey, sval = item.split('=', 1)
if skey not in data:
data[skey] = [sval]
else:
Avoid deeply nested control flow statements. Open
for key in search_metadata:
if key in ret[item]['Metadata']:
if ret[item]['Metadata'][key] == search_metadata[key]:
_match = True
else:
Avoid deeply nested control flow statements. Open
if id(crd) not in listify:
listify[id(crd)] = []
listify_dicts[id(crd)] = crd
if nk not in listify[id(crd)]:
Avoid deeply nested control flow statements. Open
if nk not in listify[id(crd)]:
listify[id(crd)].append(nk)
# Collision detection
if self.as_list and (nk in crd):
Avoid deeply nested control flow statements. Open
if isinstance(arg, dict) and next(iter(arg)) == 'name':
break
else:
Avoid deeply nested control flow statements. Open
if 'vrf' in display_fields:
row['vrf'] = vrf
if 'connection_stats' in display_fields:
Function _do_search
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _do_search(conf):
'''
Builds connection and search arguments, performs the LDAP search and
formats the results as a dictionary appropriate for pillar use.
'''
- 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"