Showing 96 of 96 total issues
File common_tools.py
has 461 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 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 string_tools.py
has 426 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
"""
File exceptions.py
has 393 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
"""
The motivation here is simply that Python lacks some standard exceptions that I consider important.
File dot_dict.py
has 386 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
"""
File filesys_tools.py
has 358 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 sanitize_node
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def sanitize_node(
self: Self,
bit: PurePath | str,
*,
is_file: bool | None = None,
- 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
FrozeDict
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class FrozeDict(Mapping[K_contra, V_co], Hashable):
"""
An immutable dictionary/mapping.
Hashable and ordered.
"""
FrozeList
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class FrozeList(Sequence[T_co], Hashable):
"""
An immutable list, hashable and ordered.
"""
StringUtils
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class StringUtils:
def pretty_dict(self: Self, dct: Mapping[Any, Any]) -> str:
"""
Returns a pretty-printed dict, complete with indentation. Will fail on non-JSON-serializable datatypes.
"""
File frozen_types.py
has 271 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
"""
Hashable and ordered collections.
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
"""
File io_tools.py
has 252 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 pretty_float
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def pretty_float(self: Self, v: float | int, n_sigfigs: int | None = 5) -> str:
"""
Represents a float as a string, with symbols for NaN and infinity.
The returned string always has a minus or + prepended. Strip off the plus with `.lstrip('+')`.
If v is an integer (by isinstance), makes sure to display without a decimal point.
- 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 exact_natsort_alg
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def exact_natsort_alg(self: Self, flags: int | Collection[int | str] | None) -> NatsortFlagsAndValue:
"""
Gets the flag names and combined `alg=` argument for natsort.
Examples:
- 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 get_env_info
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def get_env_info(self: Self, *, extended: bool = False, insecure: bool = False) -> Mapping[str, str]:
"""
Get a dictionary of some system and environment information.
Includes os_release, hostname, username, mem + disk, shell, etc.
- 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 __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 verify_can_read_files
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def verify_can_read_files(
cls: type[Self],
*paths: str | Path,
missing_ok: bool = False,
attempt: bool = False,
- 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 verify_can_write_files
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def verify_can_write_files(
cls: type[Self],
*paths: str | Path,
missing_ok: bool = False,
attempt: bool = False,
- 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 add_reprs
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_reprs(