Showing 9,400 of 17,590 total issues
Avoid deeply nested control flow statements. Open
Open
if len(_config['averages'][item]) != 2:
return False, ('Configuration for load beacon: '
'1m, 5m and 15m items must be '
'a list of two items.')
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 interface_config[attr] and \
'onvalue' in interface_config[attr]:
config_value = interface_config[attr]['onvalue']
new_value = ast.literal_eval(_diff_stats_dict[attr])
Avoid deeply nested control flow statements. Open
Open
if _config['services'][name][key] == cur[key]:
n_flag += 1
if n_flag == len(_config['services'][name]):
Avoid deeply nested control flow statements. Open
Open
if wm.watches[wd].mask != mask:
update = True
if wm.watches[wd].auto_add != auto_add:
Avoid deeply nested control flow statements. Open
Open
if not pub_channel.auth.authenticated:
continue
del self.opts['detect_mode']
Avoid deeply nested control flow statements. Open
Open
if not config_value or config_value == new_value:
_send_event = True
_ret_diff[attr] = new_value
Avoid deeply nested control flow statements. Open
Open
if isinstance(exclude, dict):
_exclude = next(iter(exclude))
if exclude[_exclude].get('regex', False):
try:
if re.search(_exclude, event.pathname):
Avoid deeply nested control flow statements. Open
Open
if policy == 'any' and bool(cnt) or cnt == len(mapping):
if self.opts['discovery'].get('multimaster'):
discovered.append(proto_data['master'])
else:
self.opts['master'] = proto_data['master']
Avoid deeply nested control flow statements. Open
Open
for key, value in ret['data'].items():
comment = '{0}\n\t\t{1}: {2}'.format(comment, key, value)
else:
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
Avoid deeply nested control flow statements. Open
Open
if isinstance(cur_struct, (list, tuple)):
for cur_ele in cur_struct:
found |= _compare(cmp_value, cur_ele)
elif isinstance(cur_struct, dict):
for _, cur_ele in six.iteritems(cur_struct):
Avoid deeply nested control flow statements. Open
Open
if 'type' in interface_config and \
interface_config['type'] == 'equal':
if getattr(_if_stats, attr, None) == \
int(interface_config[attr]):
_diff = True
Avoid deeply nested control flow statements. Open
Open
if 'battery' not in val or battery_level != val['battery']:
if ('battery' not in val or val['battery'] > _config['battery_low']) and \
battery_level <= _config['battery_low']:
ret.append({'device': device, 'battery_level': battery_level, 'tag': 'battery_low'})
Avoid deeply nested control flow statements. Open
Open
if wm.watches[wd].auto_add != auto_add:
update = True
if update:
Avoid deeply nested control flow statements. Open
Open
if update:
wm.update_watch(wd, mask=mask, rec=rec, auto_add=auto_add)
elif os.path.exists(path):
Function validate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def validate(config):
'''
Validate the beacon configuration
'''
# Configuration for ps beacon should be a list of dicts
- 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 isinstance(event[field], bytes):
event[field] = salt.utils.stringutils.to_unicode(event[field])
event[field] = event[field].strip('\x00')
Avoid deeply nested control flow statements. Open
Open
if ind == 1:
event['cmd'] = field
continue
if ind % 2 != 0:
Avoid deeply nested control flow statements. Open
Open
if self.opts['master_failback'] and 'master_list' in self.opts:
if self.opts['master'] != self.opts['master_list'][0]:
schedule = {
'function': 'status.ping_master',
'seconds': self.opts['master_failback_interval'],