Showing 9,400 of 17,590 total issues
Avoid deeply nested control flow statements. Open
if current_environ.get(_norm_key(key), None) != '':
# This key value will change to ''
ret['changes'].update({key: ''})
else:
Function logging_levels
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def logging_levels(name, remote=None, local=None):
'''
Ensures that the logging levels are set on the device. The logging levels
must match the following options: emergency, alert, critical, error, warning,
notice, informational, debug.
- 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 not __salt__['win_dns_client.rm_dns'](server, interface):
ret['comment'] = (
'Failed to remove {0} from DNS server list').format(server)
ret['result'] = False
return ret
Avoid deeply nested control flow statements. Open
for k, v in record.items():
if v != rec_set[record_str].get(k):
ret['changes'] = {'new': {record_str: record}}
elif record_str[-1] == 's':
Avoid deeply nested control flow statements. Open
if tags[existing_tag] != sg['tags'][existing_tag]:
tags_to_update[existing_tag] = tags[existing_tag]
tags_to_add.pop(existing_tag)
Avoid deeply nested control flow statements. Open
if existing_vhost == '' and perms == ['', '', '']:
continue
perm_need_change = True
Avoid deeply nested control flow statements. Open
if not isinstance(record, dict):
ret['comment'] = '{0} record information must be specified as a dictionary!'.format(record_str)
return ret
for k, v in record.items():
Avoid deeply nested control flow statements. Open
if existing_tag not in tags_to_remove:
tags_to_remove.append(existing_tag)
else:
Function updated
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def updated(name=None, cyg_arch='x86_64', mirrors=None):
'''
Make sure all packages are up to date.
name : None
- 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 not isinstance(record, list):
ret['comment'] = '{0} record information must be specified as a list of dictionaries!'.format(
record_str
)
return ret
Avoid deeply nested control flow statements. Open
if 'tags' in sg:
if sg['tags']:
if tag in sg['tags']:
ret['changes']['old']['tags'][tag] = sg['tags'][tag]
if not tags_to_update and not tags_to_remove and not tags_to_add:
Avoid deeply nested control flow statements. Open
if ret['changes'].get('perms') is None:
ret['changes'].update({'perms':
{'old': {},
'new': {}}})
ret['changes']['perms']['old'].update(existing_perms)
Avoid deeply nested control flow statements. Open
if len(to_start) == len(matches):
ret['comment'] = (
'All services in group \'{0}\' will be started'
.format(name)
)
Function _get_dict_result
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _get_dict_result(node):
ret = True
for key, val in six.iteritems(node):
if key == 'result' and val is False:
ret = False
- 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 new_value['ProjectionType'] != current_value['ProjectionType']:
raise GsiNotUpdatableError('GSI projection types do not match')
elif set(new_value.get('NonKeyAttributes', [])) != set(current_value.get('NonKeyAttributes', [])):
raise GsiNotUpdatableError('NonKeyAttributes do not match for GSI projection')
elif new_value != current_value:
Avoid deeply nested control flow statements. Open
if spost['lstchg'] != date:
ret['comment'] = 'User {0} created but failed to set' \
' last change date to' \
' {1}'.format(name, date)
ret['result'] = False
Avoid deeply nested control flow statements. Open
if spost['expire'] != expire:
ret['comment'] = 'User {0} created but failed to set' \
' expire days to' \
' {1}'.format(name, expire)
ret['result'] = False
Avoid deeply nested control flow statements. Open
if not __salt__['user.setpassword'](name, password):
ret['comment'] = 'User {0} created but failed to set' \
' password to' \
' {1}'.format(name, 'XXX-REDACTED-XXX')
ret['result'] = False
Avoid deeply nested control flow statements. Open
if spost['passwd'] != '':
ret['comment'] = 'User {0} created but failed to ' \
'empty password'.format(name)
ret['result'] = False
ret['changes']['password'] = ''
Avoid deeply nested control flow statements. Open
if spost['passwd'] != password:
ret['comment'] = 'User {0} created but failed to set' \
' password to' \
' {1}'.format(name, 'XXX-REDACTED-XXX')
ret['result'] = False