Showing 9,400 of 17,590 total issues
Avoid deeply nested control flow statements. Open
if 'xen:' in __salt__['cmd.run']('dmesg').lower():
grains['virtual_subtype'] = 'Xen PV DomU'
elif os.path.isfile('/sys/bus/xen/drivers/xenconsole'):
# An actual DomU will have the xenconsole driver
grains['virtual_subtype'] = 'Xen PV DomU'
Avoid deeply nested control flow statements. Open
if grains['lsb_distrib_codename'] and patchstr not in grains['lsb_distrib_codename']:
grains['lsb_distrib_codename'] += ' ' + patchstr
if not grains.get('lsb_distrib_codename'):
Avoid deeply nested control flow statements. Open
with salt.utils.files.fopen('/etc/redhat-release') as ifile:
for line in ifile:
if "red hat enterprise linux server" in line.lower():
# This is a SUSE Expanded Support Rhel installation
grains['lsb_distrib_id'] = 'RedHat'
Avoid deeply nested control flow statements. Open
if alias not in config['providers']:
config['providers'][alias] = {}
Avoid deeply nested control flow statements. Open
if alias not in providers:
raise salt.exceptions.SaltCloudConfigError(
'The \'{0}\' cloud provider entry in \'{1}\' is '
'trying to extend data from \'{2}\' though '
'\'{2}\' is not defined in the salt cloud '
Avoid deeply nested control flow statements. Open
if res and len(res.groups()) >= 1:
grains[dest] = res.group(1).strip().replace("'", '')
Avoid deeply nested control flow statements. Open
if not line.startswith(' '):
break # game over
if 'Features' in line:
Avoid deeply nested control flow statements. Open
if log_message is True:
# This provider does not include all necessary keys,
# continue to next one.
log.warning(
"The required '%s' configuration setting is "
Avoid deeply nested control flow statements. Open
if retry_dns_count == 0:
raise SaltMasterUnresolvableError
retry_dns_count -= 1
Avoid deeply nested control flow statements. Open
if master_len > 1:
secondary_masters = opts['master'][1:]
master_idx = crc32(opts['id']) % master_len
try:
preferred_masters = opts['master']
Avoid deeply nested control flow statements. Open
for line in ifile:
# ALT Linux Sisyphus (unstable)
comps = line.split()
if comps[0] == 'ALT':
grains['lsb_distrib_release'] = comps[2]
Function _smartos_computenode_data
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _smartos_computenode_data():
'''
Return useful information from a SmartOS compute node
'''
# Provides:
- 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 old_to_new
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def old_to_new(opts):
providers = (
'AWS',
'CLOUDSTACK',
'DIGITALOCEAN',
- 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 _update_ssl_config
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _update_ssl_config(opts):
'''
Resolves string names to integer constant in ssl configuration.
'''
if opts['ssl'] in (None, 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 not cpe:
log.error('Broken CPE_NAME format in /etc/os-release!')
elif cpe.get('vendor', '').lower() in ['suse', 'opensuse']:
grains['os'] = "SUSE"
# openSUSE `osfullname` grain normalization
Avoid deeply nested control flow statements. Open
if provider not in providers.get(alias):
raise salt.exceptions.SaltCloudConfigError(
'The \'{0}\' cloud provider entry in \'{1}\' is '
'trying to extend data from \'{2}:{3}\' though '
'\'{3}\' is not defined in \'{1}\''.format(
Avoid deeply nested control flow statements. Open
if None in VALID_OPTS[key]:
continue
except TypeError:
Avoid deeply nested control flow statements. Open
if key == 'uuid':
grains['uuid'] = grains['uuid'].lower()
except (IOError, OSError) as err:
Avoid deeply nested control flow statements. Open
if isinstance(value, dict):
value.update(details[name].copy())
else:
value = deepcopy(details[name])
elif len(opts['providers'].get(vm_['driver'], ())) > 1:
Avoid deeply nested control flow statements. Open
for item in supported_inits:
if item in buf:
if six.PY3:
item = item.decode('utf-8')
grains['init'] = item