Showing 9,400 of 17,590 total issues
Avoid deeply nested control flow statements. Open
Open
for _, cur_struct_val in six.iteritems(cur_struct):
found |= _compare(cmp_value, cur_struct_val)
return found
Function validate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def validate(config):
'''
Validate the beacon configuration
'''
# Configuration for adb beacon should be a dictionary with states array
- 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 'recurse' in _config['files'][path]:
if not isinstance(_config['files'][path]['recurse'], bool):
return False, ('Configuration for inotify beacon '
'recurse must be boolean.')
Avoid deeply nested control flow statements. Open
Open
if trans == 'zeromq' and not zmq:
continue
self.opts['transport'] = trans
Avoid deeply nested control flow statements. Open
Open
if close_str in self.beacons:
log.info('Closing beacon %s. State run in progress.', mod)
self.beacons[close_str](b_config[mod])
else:
log.info('Skipping beacon %s. State run in progress.', mod)
Avoid deeply nested control flow statements. Open
Open
if 'auto_add' in _config['files'][path]:
if not isinstance(_config['files'][path]['auto_add'], bool):
return False, ('Configuration for inotify beacon '
'auto_add must be boolean.')
Avoid deeply nested control flow statements. Open
Open
if isinstance(exclude, dict):
excl.append(list(exclude)[0])
else:
excl.append(exclude)
excl = pyinotify.ExcludeFilter(excl)
Avoid deeply nested control flow statements. Open
Open
if not any(j in ['mask',
'recurse',
'auto_add'] for j in _config['files'][path]):
return False, ('Configuration for inotify beacon must '
'contain mask, recurse or auto_add items.')
Avoid deeply nested control flow statements. Open
Open
if labels_key:
# at the same depth
labels = ret.get(labels_key) # if any
out.extend(self.display_rows(rows, labels, indent))
Avoid deeply nested control flow statements. Open
Open
for item in ret['data']:
comment = '{0} {1}'.format(comment, item)
elif isinstance(ret['data'], dict):
Avoid deeply nested control flow statements. Open
Open
if ind % 2 != 0:
event['args'].append(field)
event['user'] = __context__[pkey][pid]['user']
Avoid deeply nested control flow statements. Open
Open
if isinstance(_user, dict) and 'time_range' in _user:
if _check_time_range(_user['time_range'], now):
ret.append(event)
else:
if defaults and 'time_range' in defaults:
Avoid deeply nested control flow statements. Open
Open
if cmp_key not in cur_struct:
return False
return _compare(cmp_value, cur_struct[cmp_key])
Avoid deeply nested control flow statements. Open
Open
if 'servers' not in _config['backends'][backend]:
return False, ('Backends for haproxy beacon '
'require servers.')
else:
_servers = _config['backends'][backend]['servers']
Avoid deeply nested control flow statements. Open
Open
if _check_time_range(defaults['time_range'], now):
ret.append(event)
else:
Avoid deeply nested control flow statements. Open
Open
if _check_time_range(defaults['time_range'], now):
ret.append(event)
else:
Avoid deeply nested control flow statements. Open
Open
if not iret:
iret = []
iret.append(single)
Avoid deeply nested control flow statements. Open
Open
if isinstance(item, dict) and '__kwarg__' in item:
clikwargs = item.copy()
Avoid deeply nested control flow statements. Open
Open
if device not in last_state:
last_state[device] = {}
Avoid deeply nested control flow statements. Open
Open
if isinstance(event[field], bytes):
event[field] = salt.utils.stringutils.to_unicode(event[field])
event[field] = event[field].strip('\x00')