Function extract_from_jsonpointer_path
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def extract_from_jsonpointer_path(target, path: str, delimiter: str = "/", auto_create=False):
parts = path.strip(delimiter).split(delimiter)
for part in parts:
path_part = int(part) if is_number(part) else part
if isinstance(target, list) and not is_number(path_part):
- 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 default
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def default(self, o):
import yaml # leave import here, to avoid breaking our Lambda tests!
if isinstance(o, HostAndPort):
return str(o)
- 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 fix_json_keys
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def fix_json_keys(item: Any):
"""make sure the keys of a JSON are strings (not binary type or other)"""
item_copy = item
if isinstance(item, list):
item_copy = []
- 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 too many return
statements within this function. Open
return float(o.value)
Avoid too many return
statements within this function. Open
return None
Avoid too many return
statements within this function. Open
return super(CustomEncoder, self).default(o)
Avoid too many return
statements within this function. Open
return bool(o.value)
Avoid too many return
statements within this function. Open
return int(o.value)
Avoid too many return
statements within this function. Open
return to_str(o)
Avoid too many return
statements within this function. Open
return str(o.value)
Function parse_json_or_yaml
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def parse_json_or_yaml(markup: str) -> Any:
import yaml # leave import here, to avoid breaking our Lambda tests!
try:
return json.loads(markup)
- 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"