Showing 9,400 of 17,590 total issues
Function psql_query
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def psql_query(query, user=None, host=None, port=None, maintenance_db=None,
password=None, runas=None, write=False):
'''
Run an SQL-Query and return the results as a list. This command
only supports SELECT statements. This limitation can be worked around
- 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
Function group_info
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def group_info(name):
'''
.. versionadded:: 2016.11.0
Lists all packages in the specified group
- 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 'data' not in adapters[iface_name]:
adapters[iface_name]['data'] = salt.utils.odict.OrderedDict()
Avoid deeply nested control flow statements. Open
if hostname.text not in result[uuid]['hostnames']:
result[uuid]['hostnames'].append(hostname.text)
elif item.tag != 'uuid':
Avoid deeply nested control flow statements. Open
if iface_name not in adapters:
adapters[iface_name] = salt.utils.odict.OrderedDict()
# Create item in dict, if not already there
if 'data' not in adapters[iface_name]:
Function __virtual__
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def __virtual__():
'''
Load as 'pkg' on FreeBSD 10 and greater.
Load as 'pkg' on DragonFly BSD.
Load as 'pkg' on FreeBSD 9 when config option
- 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 _comm['out']:
# If unable to commit confirm, should try to bail out
loaded_result['comment'] = 'Unable to commit confirm: {}'.format(_comm['message'])
loaded_result['result'] = False
# But before exiting, we must gracefully discard the config
Function _package_conf_file_to_dir
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _package_conf_file_to_dir(file_name):
'''
Convert a config file to a config directory.
'''
if file_name in SUPPORTED_CONFS:
- 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 new_contents:
os.remove(file_path)
Avoid deeply nested control flow statements. Open
if merged_flags:
new_contents += '{0} {1}\n'.format(
atom, ' '.join(merged_flags))
else:
new_contents += '{0}\n'.format(atom)
Avoid deeply nested control flow statements. Open
if match_list.issubset(line_list):
return True
except IOError:
Function __within2
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def __within2(value, within=None, errmsg=None, dtype=None):
'''validate that a value is in ``within`` and optionally a ``dtype``'''
valid, _value = False, value
if dtype:
try:
- 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(value, (set, list, dict)):
value = six.text_type(value)
values[key] = value
Avoid deeply nested control flow statements. Open
with salt.utils.files.fopen(file_path, 'r+') as file_handler:
for line in file_handler:
line = salt.utils.stringutils.to_unicode(line)
try:
atom = line.strip().split()[0]
Avoid deeply nested control flow statements. Open
if child.tag == 'Value':
result = child.text
Avoid deeply nested control flow statements. Open
if child.tag == 'Value':
result = child.text
Avoid deeply nested control flow statements. Open
with salt.utils.files.fopen(temp_file, 'w') as fp_:
fp_.write(running_config)
committed = _safe_commit_config(loaded_result, napalm_device)
Avoid deeply nested control flow statements. Open
if prefix == '=':
wildcards.append((param, verstr))
else:
errors.append(
'Invalid wildcard for {0}{1}{2}'.format(
Avoid deeply nested control flow statements. Open
if line_package == six.text_type(atom):
return True
else:
Avoid deeply nested control flow statements. Open
if len(sline) != 4:
msg = 'Interface file malformed: {0}.'
msg = msg.format(sline)
log.error(msg)
raise AttributeError(msg)