Showing 9,400 of 17,590 total issues
Consider simplifying this complex logical expression. Open
Open
if ( matcher[ expando ] ) {
// Find the next relative operator (if any) for proper handling
j = ++i;
for ( ; j < len; j++ ) {
if ( Expr.relative[ tokens[j].type ] ) {
Consider simplifying this complex logical expression. Open
Open
if ( s.crossDomain == null ) {
parts = rurl.exec( s.url.toLowerCase() );
s.crossDomain = !!( parts &&
( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
Consider simplifying this complex logical expression. Open
Open
else if (Object(a) === a)
for (n in m = function () {
var b = 0,
c;
for (c in a) a.hasOwnProperty(c) && b++;
Consider simplifying this complex logical expression. Open
Open
if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) {
return;
}
Consider simplifying this complex logical expression. Open
Open
if (!o && g(l.readyState) && (u.r = o = 1, !q && h(), l.onload = l.onreadystatechange = null, b)) {
"img" != a && m(function () {
t.removeChild(l)
}, 50);
for (var d in y[c]) y[c].hasOwnProperty(d) && y[c][d].onload()
Consider simplifying this complex logical expression. Open
Open
if result['success'] or \
'Operation failed: Channel closed' in result['stdout'] or \
'Communication error: java.util.concurrent.ExecutionException: Operation failed' in result['stdout']:
wait_time = 0
status = None
Consider simplifying this complex logical expression. Open
Open
if hold == 'minute' and \
timestamp_now <= timestamp:
continue
elif hold == 'hour' and \
timestamp_now.replace(**comp_hour) <= timestamp.replace(**comp_hour):
Consider simplifying this complex logical expression. Open
Open
if not (present or boolean or integer or string or
listing or dictionary):
raise SaltInvocationError('Missing required argument text.')
Consider simplifying this complex logical expression. Open
Open
if (vtype in ['bool', 'boolean']) and ((value in [True, 'TRUE', 'YES'] and current_value == '1') or
(value in [False, 'FALSE', 'NO'] and current_value == '0')):
ret['comment'] += '{0} {1} is already set to {2}'.format(domain, name, value)
elif vtype in ['int', 'integer'] and safe_cast(current_value, int) == safe_cast(value, int):
ret['comment'] += '{0} {1} is already set to {2}'.format(domain, name, value)
Consider simplifying this complex logical expression. Open
Open
if is_proxy(opts) and always_alive:
# if it is running in a NAPALM Proxy and it's using the default
# always alive behaviour, will get the cached copy of the network
# device object which should preserve the connection.
if force_reconnect:
Consider simplifying this complex logical expression. Open
Open
if salt.utils.platform.is_sunos():
on_supported_platform = True
elif salt.utils.platform.is_freebsd() and _check_retcode('kldstat -q -m zfs'):
on_supported_platform = True
elif salt.utils.platform.is_linux() and os.path.exists('/sys/module/zfs'):
Consider simplifying this complex logical expression. Open
Open
if 'Darwin' in six.text_type(traceroute_version[1]) or \
'FreeBSD' in six.text_type(traceroute_version[1]) or \
__grains__['kernel'] in ('SunOS', 'AIX'):
try:
traceline = re.findall(r'\s*(\d*)\s+(.*)\s+\((.*)\)\s+(.*)$', line)[0]
Consider simplifying this complex logical expression. Open
Open
if proto == 'salt':
path, senv = salt.utils.url.parse(single_src)
if not senv:
senv = saltenv
if (path, saltenv) in mfiles or (path, saltenv) in mdirs:
Consider simplifying this complex logical expression. Open
Open
if proto == 'file' and (
os.path.exists(urlparsed_src.netloc) or
os.path.exists(urlparsed_src.path) or
os.path.exists(os.path.join(
urlparsed_src.netloc,
Consider simplifying this complex logical expression. Open
Open
if archive or hidden or notIndexed or readonly or system or temporary:
raise CommandExecutionError(
'Normal attribute may not be used with any other attributes')
ret = win32file.SetFileAttributes(path, 128)
Consider simplifying this complex logical expression. Open
Open
if ((mac and # pylint: disable=too-many-boolean-expressions
napalm_helpers.convert(napalm_helpers.mac, mac_entry.get('mac', '')) ==
napalm_helpers.convert(napalm_helpers.mac, mac)) or
(interface and interface in mac_entry.get('interface', '')) or
(vlan and six.text_type(mac_entry.get('vlan', '')) == six.text_type(vlan))):
Consider simplifying this complex logical expression. Open
Open
if ((mac and arp_entry.get('mac', '').lower() == mac.lower()) or # pylint: disable=too-many-boolean-expressions
(interface and interface in arp_entry.get('interface', '')) or
(ip and napalm_helpers.convert(napalm_helpers.ip, arp_entry.get('ip', '')) ==
napalm_helpers.convert(napalm_helpers.ip, ip))):
rows.append({
Consider simplifying this complex logical expression. Open
Open
if lost['require'] or lost['watch'] or lost['prereq'] \
or lost['onfail'] or lost['onchanges'] \
or lost.get('prerequired'):
comment = 'The following requisites were not found:\n'
for requisite, lreqs in six.iteritems(lost):
Consider simplifying this complex logical expression. Open
Open
if osdata['kernel'] == 'Linux' and os.path.exists('/sys/class/dmi/id'):
# On many Linux distributions basic firmware information is available via sysfs
# requires CONFIG_DMIID to be enabled in the Linux kernel configuration
sysfs_firmware_info = {
'biosversion': 'bios_version',
Function run
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def run(self):
if not os.path.exists(SALT_VERSION_HARDCODED) or self.distribution.with_salt_version:
# Write the version file
if getattr(self.distribution, 'salt_version_hardcoded_path', None) is None:
print('This command is not meant to be called on it\'s own')
- 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"