Function prepare
has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring. Open
def prepare(
self: Self,
data: Any,
*,
inf_handling: NanInfHandling,
- 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
File json_tools.py
has 254 lines of code (exceeds 250 allowed). Consider refactoring. Open
# SPDX-FileCopyrightText: Copyright 2020-2023, Contributors to pocketutils
# SPDX-PackageHomePage: https://github.com/dmyersturnbull/pocketutils
# SPDX-License-Identifier: Apache-2.0
"""
Function __call__
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def __call__(self: Self, obj: Any) -> Any:
"""
Tries to return a serializable result for `obj`.
Meant to be passed as `default=` in `orjson.dumps`.
Only encodes types that can always be represented exactly,
- 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 new_default
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def new_default(
self: Self,
*fallbacks: Callable[[Any], Any] | None,
first: Callable[[Any], Any] | None = _misc_types_default,
last: Callable[[Any], Any] | None = str,
- 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 encoder
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def encoder(
Consider simplifying this complex logical expression. Open
if (
(is_list_with_inf or is_np_array_with_inf or is_list_with_nan or is_list_with_nan)
and inf_handling is NanInfHandling.convert_to_str
and nan_handling is NanInfHandling.convert_to_str
):
Consider simplifying this complex logical expression. Open
if (
(is_list_with_inf or is_np_array_with_inf)
and (is_list_with_nan or is_list_with_nan)
and inf_handling is NanInfHandling.convert_to_str
and nan_handling is NanInfHandling.convert_to_null
Consider simplifying this complex logical expression. Open
if (
(is_list_with_inf or is_np_array_with_inf)
and (is_list_with_nan or is_list_with_nan)
and inf_handling is NanInfHandling.convert_to_null
and nan_handling is NanInfHandling.convert_to_str
Avoid too many return
statements within this function. Open
return obj._asdict()
Avoid too many return
statements within this function. Open
return data.tolist()
Avoid too many return
statements within this function. Open
return [self.prepare(e, inf_handling=inf_handling, nan_handling=nan_handling) for e in data]
Avoid too many return
statements within this function. Open
return str(data)
Avoid too many return
statements within this function. Open
return obj.Self
Avoid too many return
statements within this function. Open
return base64.b64decode(obj)
Avoid too many return
statements within this function. Open
return dict(obj)
Avoid too many return
statements within this function. Open
return data
Avoid too many return
statements within this function. Open
return obj.tzname(datetime.now(tz=obj))
Avoid too many return
statements within this function. Open
return list(obj)
Avoid too many return
statements within this function. Open
return base64.b64decode(bytes(obj))