Showing 9,400 of 17,590 total issues
Avoid deeply nested control flow statements. Open
Open
for line in ifile:
# Need to pull out the version and codename
# in the case of custom content in /etc/centos-release
find_release = re.compile(r'\d+\.\d+')
find_codename = re.compile(r'(?<=\()(.*?)(?=\))')
Avoid deeply nested control flow statements. Open
Open
if res and len(res.groups()) >= 1:
grains[dest] = res.group(1).strip().replace("'", '')
Avoid deeply nested control flow statements. Open
Open
if ':' in driver:
# Weird, but...
alias, driver = driver.split(':')
Avoid deeply nested control flow statements. Open
Open
if 'extends' not in details:
log.error(
'Please check your cloud providers configuration. '
'There\'s no \'driver\' nor \'extends\' definition '
'referenced.'
Avoid deeply nested control flow statements. Open
Open
for key, val in six.iteritems(string_kwarg):
invalid_kwargs.append('{0}={1}'.format(key, val))
else:
Function _handle_signals
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def _handle_signals(client, signum, sigframe):
try:
# This raises AttributeError on Python 3.4 and 3.5 if there is no current exception.
# Ref: https://bugs.python.org/issue23003
trace = traceback.format_exc()
- 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 _call_syndic
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def _call_syndic(self, func, args=(), kwargs=None, master_id=None):
'''
Wrapper to call a given func on a syndic, best effort to get the one you asked for
'''
if kwargs is 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
Open
if pkginrepo.match(line):
grains['pkgin_repositories'].append(line)
Avoid deeply nested control flow statements. Open
Open
if vz_match and int(vz_match.groups()[0]) != 0:
grains['virtual'] = 'openvzve'
elif vz_match and int(vz_match.groups()[0]) == 0:
grains['virtual'] = 'openvzhn'
if isdir('/proc/sys/xen') or \
Avoid deeply nested control flow statements. Open
Open
if osminorrelease:
osrelease.append(osminorrelease)
grains['osrelease'] = ".".join(osrelease)
Avoid deeply nested control flow statements. Open
Open
if match_pkgsrcpath:
grains['pkgsrcpath'] = match_pkgsrcpath.group(1)
match_pkgsrcversion = pkgsrcversion.match(match_pkgsrcpath.group(1))
if match_pkgsrcversion:
grains['pkgsrcversion'] = match_pkgsrcversion.group(1)
Avoid deeply nested control flow statements. Open
Open
for line in fp_:
try:
key, val = line.rstrip('\n').split('=')
except ValueError:
continue
Avoid deeply nested control flow statements. Open
Open
if driver in providers.get(extends):
details['extends'] = '{0}:{1}'.format(extends, driver)
elif '-only-extendable-' in providers.get(extends):
details['extends'] = '{0}:{1}'.format(
extends, '-only-extendable-{0}'.format(ext_count)
Avoid deeply nested control flow statements. Open
Open
if opts['master'] in opts['local_masters']:
# create new list of master with the possibly failed
# one moved to the end
failed_master = opts['master']
opts['master'] = [x for x in opts['local_masters'] if opts['master'] != x]
Avoid deeply nested control flow statements. Open
Open
for line in fhr:
if 'enterprise' in line.lower():
grains['lsb_distrib_id'] = 'SLES'
grains['lsb_distrib_codename'] = re.sub(r'\(.+\)', '', line).strip()
elif 'version' in line.lower():
Avoid deeply nested control flow statements. Open
Open
if len(synoinfo) != 3:
log.warning(
'Unable to determine Synology version info. '
'Please report this, as it is likely a bug.'
)
Avoid deeply nested control flow statements. Open
Open
if 'Features' in line:
start = line.find('<')
end = line.find('>')
if start > 0 and end > 0:
flag = line[start + 1:end].split(',')
Avoid deeply nested control flow statements. Open
Open
if os_release['ID'] == 'debian':
codename_match = re.search(r'\((\w+)\)$', codename)
if codename_match:
codename = codename_match.group(1)
grains['lsb_distrib_codename'] = codename
Avoid deeply nested control flow statements. Open
Open
if not iret:
iret = []
iret.append(single)
Avoid deeply nested control flow statements. Open
Open
if 'driver' not in detail:
raise salt.exceptions.SaltCloudConfigError(
'The cloud provider alias \'{0}\' has an entry '
'missing the required setting of \'driver\'.'.format(
alias