dmyersturnbull/pocketutils

View on GitHub
src/pocketutils/core/decorators.py

Summary

Maintainability
B
5 hrs
Test Coverage

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

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

    def add_reprs(
        fields: Collection[str] | None = None,
        *,
        exclude: Collection[str] | Callable[[str], bool] | None | Literal[False] = None,
        exclude_from_str: Collection[str] | Callable[[str], bool] | None = None,
    Severity: Minor
    Found in src/pocketutils/core/decorators.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 gen_html has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def gen_html(
    Severity: Minor
    Found in src/pocketutils/core/decorators.py - About 35 mins to fix

      Function gen_str has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def gen_str(
      Severity: Minor
      Found in src/pocketutils/core/decorators.py - About 35 mins to fix

        Function gen_list has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def gen_list(
        Severity: Minor
        Found in src/pocketutils/core/decorators.py - About 35 mins to fix

          Function status has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def status(level: int | str | CodeStatus, vr: str | None = "", msg: str | None = None) -> Callable[..., Any]:
              """
              Annotate code quality. Emits a warning if bad code is called.
          
              Args:
          Severity: Minor
          Found in src/pocketutils/core/decorators.py - About 35 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

          Avoid too many return statements within this function.
          Open

                      return wraps(func)(my_fn)
          Severity: Major
          Found in src/pocketutils/core/decorators.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return wraps(func)(my_fn)
            Severity: Major
            Found in src/pocketutils/core/decorators.py - About 30 mins to fix

              Function _exclude_fn has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _exclude_fn(cls: type[Self], exclude) -> Callable[str, bool]:
                      if exclude is None or exclude is False:
                          return lambda s: False
                      if isinstance(exclude, str):
                          return lambda s: s == exclude
              Severity: Minor
              Found in src/pocketutils/core/decorators.py - About 25 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

              There are no issues that match your filters.

              Category
              Status