Showing 9,400 of 17,590 total issues
Avoid deeply nested control flow statements. Open
if optval in ('""', "''"):
optval = ''
self._add_option(cursect, optname, optval)
Function merge_subreturn
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def merge_subreturn(original_return, sub_return, subkey=None):
'''
Update an existing state return (`original_return`) in place
with another state return (`sub_return`), i.e. for a subresource.
- 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 idx in range(len(bindings[cport])):
if bindings[cport][idx] is None:
# Now that we are adding multiple
# bindings
try:
Avoid deeply nested control flow statements. Open
if 'kb' + kb in item.lower():
pkg = item.split(' : ')[1]
ret['DismPackage'] = pkg
Function human_to_bytes
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def human_to_bytes(size):
'''
Given a human-readable byte string (e.g. 2G, 30M),
return the number of bytes. Will return 0 if the argument has
unexpected form.
- 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 _string_check
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _string_check(self, value, allow_list=False):
'''
Based on the string-checking code from the SafeConfigParser's set()
function, this enforces string values for config options.
'''
- 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 LooseVersion(version_text) <= LooseVersion(ver_item):
break
insert_point += 1
Avoid deeply nested control flow statements. Open
if not update.IsInstalled:
ret['Updates'][uid]['Result'] = \
'Uninstallation Succeeded'
else:
ret['Updates'][uid]['Result'] = \
Avoid deeply nested control flow statements. Open
if comment:
if not curr_desc:
pp_res['desc'] = comment
elif comment != curr_desc:
pp_res['desc'] = '{0}, {1}'.format(curr_desc, comment)
Avoid deeply nested control flow statements. Open
if not isinstance(fchunk, list):
continue
else:
# bydefault onfail will fail, but you can
# set onfail_stop: False to prevent the highstate
Avoid deeply nested control flow statements. Open
if isinstance(bindings[cport], list):
# Append to existing list of bindings for this
# container port.
bindings[cport].append(bind_def)
else:
Avoid deeply nested control flow statements. Open
if isinstance(curr_proto, (list, tuple)):
curr_proto.append(proto)
else:
pp_res['proto'] = [curr_proto, proto]
Avoid deeply nested control flow statements. Open
if ip_net not in sortlist:
sortlist.append(ip_net)
elif directive == 'options':
Function translate_command
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def translate_command(val):
'''
Input should either be a single string, or a list of strings. This is used
for the two args that deal with commands ("command" and "entrypoint").
'''
- 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 in ip_raw:
# No netmask has been provided, guess
# the "natural" one
if ip_net.version == 4:
ip_addr = six.text_type(ip_net.network_address)
Function camel_to_snake_case
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def camel_to_snake_case(camel_input):
'''
Converts camelCase (or CamelCase) to snake_case.
From https://codereview.stackexchange.com/questions/185966/functions-to-convert-camelcase-strings-to-snake-case
- 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 extend
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def extend(self, *state_funcs):
if self.options.ordered or self.last_func():
raise PyDslError(
'Cannot extend() after the ordered option was turned on!'
)
- 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 mod_ == st['state'] and fstate == st['__id__']:
ofresult = rstate.get('result', _empty)
if ofresult in [False, True]:
nret = ofresult
if ofresult is False:
Avoid deeply nested control flow statements. Open
for tag in tags:
if fnmatch.fnmatch(event['tag'], tag):
found_match = True
publish = found_match
Avoid deeply nested control flow statements. Open
if '' == suffix:
continue # Next suffix (__init__ must have a suffix)
init_file = '__init__{0}'.format(suffix)