Function get_node_by_xpath
has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open
def get_node_by_xpath(mapping, xpath, default=None, ignore_errors=False,
handle_list_selector=False):
'''Return the node pointed to by xpath from mapping.
Args:
- 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 key not in mapping:
if not ignore_errors:
raise KeyError("Invalid '{}' index selector: '{}' does not match "
"anything. Available keys: {!r}".format(
xpath, key, list(mapping.keys())))
Avoid deeply nested control flow statements. Open
if len(items) <= index:
if not ignore_errors:
raise KeyError("Invalid '{}' selector: item index '{}' of '{}' is "
"outside of the list boundaries. Length is: {}".format(
xpath, index, key, len(items)))
Function set_node_by_xpath
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def set_node_by_xpath(mapping, xpath, value, extend=False, setter_attr=None):
'''Set the node pointed to by xpath from mapping.
Args:
mapping: nested dictionary.
- 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 isinstance(items, list):
if not ignore_errors:
raise KeyError("Invalid '{}' selector: '{}' is not a list, is: {}"
.format(xpath, key, type(items)))
return default
Function set_node_by_xpath
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def set_node_by_xpath(mapping, xpath, value, extend=False, setter_attr=None):
Function get_node_by_xpath
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_node_by_xpath(mapping, xpath, default=None, ignore_errors=False,
Avoid too many return
statements within this function. Open
return default
Avoid too many return
statements within this function. Open
return default
Avoid too many return
statements within this function. Open
return mapping
Function delete_node_by_xpath
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def delete_node_by_xpath(mapping, xpath, ignore_errors=False):
'''Delete the node pointed to by xpath from mapping.
Args:
mapping: nested dictionary.
- 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"