dmyersturnbull/pocketutils

View on GitHub

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
"""

Severity: Minor
Found in src/pocketutils/tools/common_tools.py - About 7 hrs to fix

    Function prepare has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
    Open

        def prepare(
            self: Self,
            data: Any,
            *,
            inf_handling: NanInfHandling,
    Severity: Minor
    Found in src/pocketutils/tools/json_tools.py - About 6 hrs to fix

    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
    """
    
    
    Severity: Minor
    Found in src/pocketutils/tools/string_tools.py - About 6 hrs to fix

      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.
      Severity: Minor
      Found in src/pocketutils/core/exceptions.py - About 5 hrs to fix

        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
        """
        
        
        Severity: Minor
        Found in src/pocketutils/core/dot_dict.py - About 5 hrs to fix

          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
          """
          
          
          Severity: Minor
          Found in src/pocketutils/tools/filesys_tools.py - About 4 hrs to fix

            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,
            Severity: Minor
            Found in src/pocketutils/tools/path_tools.py - About 3 hrs to fix

            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.
                """
            Severity: Minor
            Found in src/pocketutils/core/frozen_types.py - About 2 hrs to fix

              FrozeList has 24 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class FrozeList(Sequence[T_co], Hashable):
                  """
                  An immutable list, hashable and ordered.
                  """
              
              
              Severity: Minor
              Found in src/pocketutils/core/frozen_types.py - About 2 hrs to fix

                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.
                        """
                Severity: Minor
                Found in src/pocketutils/tools/string_tools.py - About 2 hrs to fix

                  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.
                  Severity: Minor
                  Found in src/pocketutils/core/frozen_types.py - About 2 hrs to fix

                    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
                    """
                    
                    
                    Severity: Minor
                    Found in src/pocketutils/tools/json_tools.py - About 2 hrs to fix

                      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
                      """
                      
                      
                      Severity: Minor
                      Found in src/pocketutils/tools/io_tools.py - About 2 hrs to fix

                        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.
                        Severity: Minor
                        Found in src/pocketutils/tools/string_tools.py - About 1 hr to fix

                        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:
                        Severity: Minor
                        Found in src/pocketutils/tools/sort_tools.py - About 1 hr to fix

                        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.
                        
                        
                        Severity: Minor
                        Found in src/pocketutils/tools/sys_tools.py - About 1 hr to fix

                        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,
                        Severity: Minor
                        Found in src/pocketutils/tools/json_tools.py - About 1 hr to fix

                        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,
                        Severity: Minor
                        Found in src/pocketutils/tools/filesys_tools.py - About 1 hr to fix

                        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,
                        Severity: Minor
                        Found in src/pocketutils/tools/filesys_tools.py - About 1 hr to fix

                        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(
                        Severity: Major
                        Found in src/pocketutils/core/decorators.py - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language