markusressel/telegram-click

View on GitHub
telegram_click/decorator.py

Summary

Maintainability
B
5 hrs
Test Coverage

Function _create_callback_wrapper has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

def _create_callback_wrapper(func: callable, help_message: str,
                             arguments: [Argument],
                             permissions: Permission,
                             command_target: bytes,
                             error_handlers: List[ErrorHandler]) -> callable:
Severity: Minor
Found in telegram_click/decorator.py - About 2 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

Function command has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

def command(name: str or [str], description: str = None,
Severity: Major
Found in telegram_click/decorator.py - About 50 mins to fix

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

    def _create_callback_wrapper(func: callable, help_message: str,
    Severity: Minor
    Found in telegram_click/decorator.py - About 45 mins to fix

      Avoid too many return statements within this function.
      Open

          return wrapper
      Severity: Major
      Found in telegram_click/decorator.py - About 30 mins to fix

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

        def check_optional_argument_after_other(command_name: str, arguments: List[Argument]):
            """
            Checks the order of arguments to make sure no required argument is defined after an optional one
            :param command_name: command name the arguments belong to
            :param arguments: arguments to check
        Severity: Minor
        Found in telegram_click/decorator.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