Showing 9,400 of 17,590 total issues
Avoid deeply nested control flow statements. Open
with salt.utils.files.fopen(file_path) as fh_:
for line in fh_:
line = salt.utils.stringutils.to_unicode(line).strip()
if line and not line.startswith('#'):
append_to_package_conf(
Avoid deeply nested control flow statements. Open
if 'source' not in adapters:
adapters['source'] = salt.utils.odict.OrderedDict()
# Create item in dict, if not already there
if 'data' not in adapters['source']:
Avoid deeply nested control flow statements. Open
if opt in adapters[iface_name]['data'][inet]:
opt_keys = sorted(adapters[iface_name]['data'][inet][opt].keys())
adapters[iface_name]['data'][inet][opt + '_keys'] = opt_keys
Avoid deeply nested control flow statements. Open
if not _temp_tpl_file_exists:
_loaded['result'] = False
_loaded['comment'] += 'Error while rendering the template.'
return _loaded
_rendered += __salt__['file.read'](_temp_tpl_file)
Avoid deeply nested control flow statements. Open
if conf == 'accept_keywords':
if not old_flags:
new_contents += l
if not new_flags:
added = True
Avoid deeply nested control flow statements. Open
if not committed['result']:
# If unable to commit, dicard the config (which is
# already done by the _safe_commit_config function), and
# return with the command and other details.
return loaded_result
Function upgrade
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def upgrade(*names, **kwargs):
'''
Upgrade named or all packages (run a ``pkg upgrade``). If <package name> is
omitted, the operation is executed on all packages.
- 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 bond['arp_ip_target']:
bond['arp_ip_target'] = bond['arp_ip_target'] + ',' + ip
else:
bond['arp_ip_target'] = ip
else:
Function _uninstall
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _uninstall(action='remove', name=None, pkgs=None, **kwargs):
'''
remove and purge do identical things but with different pacman commands,
this function performs the common logic.
'''
- 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 force:
continue
else:
return ret
data[k] = encoded
Avoid deeply nested control flow statements. Open
if addrfam not in adapters[iface_name]['data']:
adapters[iface_name]['data'][addrfam] = salt.utils.odict.OrderedDict()
Avoid deeply nested control flow statements. Open
if not HAS_JXMLEASE:
loaded_result['comment'] = ('This feature requires the library jxmlease to be installed.\n'
'To install, please execute: ``pip install jxmlease``.')
loaded_result['result'] = False
return loaded_result
Function apply_network_settings
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def apply_network_settings(**settings):
'''
Apply global network configuration.
CLI Example:
- 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 file_dict
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def file_dict(*packages, **kwargs):
'''
List the files that belong to a package, grouped by package. Not
specifying any packages will return a list of _every_ file on the system's
package database (not generally recommended).
- 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 bond['arp_ip_target']:
bond['arp_ip_target'] = bond['arp_ip_target'] + ',' + ip
else:
bond['arp_ip_target'] = ip
else:
Function group_diff
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def group_diff(name):
'''
.. versionadded:: 2016.11.0
- 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 word in line.split()[1:]:
if word not in adapters:
adapters[word] = salt.utils.odict.OrderedDict()
adapters[word]['hotplug'] = True
Avoid deeply nested control flow statements. Open
if 'data' not in adapters['source']:
adapters['source']['data'] = salt.utils.odict.OrderedDict()
adapters['source']['data']['sources'] = []
adapters['source']['data']['sources'].append(line.split()[1])
Avoid deeply nested control flow statements. Open
with salt.utils.files.fopen(file_path) as fp_:
rearrange.extend(salt.utils.data.decode(fp_.readlines()))
os.remove(file_path)
Function mkpart
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def mkpart(device, part_type, fs_type=None, start=None, end=None):
'''
Make a part_type partition for filesystem fs_type, beginning at start and
ending at end (by default in megabytes). part_type should be one of
"primary", "logical", or "extended".
- 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"