dmyersturnbull/pocketutils

View on GitHub

Showing 96 of 96 total issues

Function get_encoding has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def get_encoding(self: Self, encoding: str = "utf-8") -> str:
        """
        Returns a text encoding from a more flexible string.
        Ignores hyphens and lowercases the string.
        Permits these nonstandard shorthands:
Severity: Minor
Found in src/pocketutils/tools/io_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_info has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def get_info(self: Self, path: PurePath | str, *, expand_user: bool = False, strict: bool = False) -> PathInfo:
        path = Path(path)
        has_ignore_error = hasattr(pathlib, "_ignore_error")
        if not has_ignore_error:
            logger.debug("No _ignore_error found; some OSErrors may be suppressed")
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 approx_time_wrt has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def approx_time_wrt(
        self: Self,
        now: date | datetime,
        then: date | datetime,
        *,
Severity: Minor
Found in src/pocketutils/tools/unit_tools.py - About 55 mins 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_dirs has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def verify_can_write_dirs(
        cls: type[Self],
        *paths: str | PurePath,
        missing_ok: bool = False,
    ) -> None:
Severity: Minor
Found in src/pocketutils/tools/filesys_tools.py - About 55 mins 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 strip_paired has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def strip_paired(self: Self, text: str, pieces: Iterable[tuple[str, str] | str]) -> str:
        """
        Strips pairs of (start, end) from the ends of strings.

        Example:
Severity: Minor
Found in src/pocketutils/tools/string_tools.py - About 55 mins 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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(
Severity: Major
Found in src/pocketutils/core/exceptions.py - About 50 mins to fix

    Function sanitize_node has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def sanitize_node(
    Severity: Minor
    Found in src/pocketutils/tools/path_tools.py - About 45 mins to fix

      Function pretty_function has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def pretty_function(self: Self, function: Callable, *, with_addr: bool = False) -> str:
              n_args = str(function.__code__.co_argcount) if hasattr(function, "__code__") else "?"
              pat = re.compile(r"^<bound method [^ .]+\.([^ ]+) of (.+)>$")
              boundmatch = pat.fullmatch(str(function))
              addr = " @ " + hex(id(function)) if with_addr else ""
      Severity: Minor
      Found in src/pocketutils/tools/string_tools.py - About 45 mins 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 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,
      Severity: Minor
      Found in src/pocketutils/tools/json_tools.py - About 45 mins 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 log_called_process_error has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def log_called_process_error(self: Self, e: CalledProcessError, *, log_fn: Callable[[str], None]) -> None:
              """
              Outputs some formatted text describing the error with its full stdout and stderr.
      
              Args:
      Severity: Minor
      Found in src/pocketutils/tools/call_tools.py - About 45 mins 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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(
      Severity: Minor
      Found in src/pocketutils/core/exceptions.py - About 45 mins to fix

        Function pretty_object has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def pretty_object(self: Self, thing: Any, *, with_addr: bool = False) -> str:
                """
                Get a better and shorter name for a function than str(function).
                Ex: `pprint_function(lambda s: s)  == '<λ>'`
        
        
        Severity: Minor
        Found in src/pocketutils/tools/string_tools.py - About 45 mins 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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(
        Severity: Minor
        Found in src/pocketutils/core/exceptions.py - About 45 mins to fix

          Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(
          Severity: Minor
          Found in src/pocketutils/core/exceptions.py - About 45 mins to fix

            Function strip_any_ends has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def strip_any_ends(self: Self, s: str, prefixes: str | Sequence[str], suffixes: str | Sequence[str]) -> str:
                    """
                    Flexible variant that strips any number of prefixes and any number of suffixes.
                    Also less type-safe than more specific variants.
                    Note that the order of the prefixes (or suffixes) DOES matter.
            Severity: Minor
            Found in src/pocketutils/tools/string_tools.py - About 45 mins 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 only has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def only(
            Severity: Minor
            Found in src/pocketutils/tools/common_tools.py - About 45 mins to fix

              Function format_pint_quantity has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def format_pint_quantity(
              Severity: Minor
              Found in src/pocketutils/tools/unit_tools.py - About 45 mins to fix

                Function write has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def write(
                Severity: Minor
                Found in src/pocketutils/core/smartio.py - About 45 mins to fix

                  Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def __init__(
                  Severity: Minor
                  Found in src/pocketutils/core/exceptions.py - About 45 mins to fix

                    Function dict_to_str has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def dict_to_str(
                    Severity: Minor
                    Found in src/pocketutils/tools/string_tools.py - About 45 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language