fabiommendes/sidekick

View on GitHub
sidekick-functions/sidekick/functions/lib_runtime.py

Summary

Maintainability
B
5 hrs
Test Coverage

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

def catching(errors: Catchable, func: Func):
    """
    Similar to catch, but decorates a function rewriting its error handling
    policy.

Severity: Minor
Found in sidekick-functions/sidekick/functions/lib_runtime.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 throttle has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def throttle(
    dt: float,
    func: Func,
    policy: Literal["last", "block"] = "last",
    clock: Callable[[], T] = time.monotonic,
Severity: Minor
Found in sidekick-functions/sidekick/functions/lib_runtime.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 retry has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def retry(n: int, func: Func, *, error: Catchable = Exception, sleep=None) -> fn:
    """
    Retry to execute function at least n times before raising an error.

    This is useful for functions that may fail due to interaction with external
Severity: Minor
Found in sidekick-functions/sidekick/functions/lib_runtime.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 catch has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def catch(exc: Union[Catchable, Dict[Catchable, Any]], func: Func, /, *args, **kwargs):
    """
    Handle exception in function. If the exception occurs, it executes the given
    handler.

Severity: Minor
Found in sidekick-functions/sidekick/functions/lib_runtime.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 retry has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def retry(n: int, func: Func, *, error: Catchable = Exception, sleep=None) -> fn:
Severity: Minor
Found in sidekick-functions/sidekick/functions/lib_runtime.py - About 35 mins to fix

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

    def throttle(
    Severity: Minor
    Found in sidekick-functions/sidekick/functions/lib_runtime.py - About 35 mins to fix

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

      def catch(exc: Union[Catchable, Dict[Catchable, Any]], func: Func, /, *args, **kwargs):
      Severity: Minor
      Found in sidekick-functions/sidekick/functions/lib_runtime.py - About 35 mins to fix

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

            def get(self, timeout=None, *, default=NOT_GIVEN):
                """
                Return result of computation.
        
                Can set optional timeout and default arguments.
        Severity: Minor
        Found in sidekick-functions/sidekick/functions/lib_runtime.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