leandrotoledo/python-telegram-bot

View on GitHub
telegram/ext/_handlers/commandhandler.py

Summary

Maintainability
B
4 hrs
Test Coverage

Function check_update has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def check_update(
        self, update: object
    ) -> Optional[Union[bool, Tuple[List[str], Optional[Union[bool, FilterDataDict]]]]]:
        """Determines whether an update should be passed to this handler's :attr:`callback`.

Severity: Minor
Found in telegram/ext/_handlers/commandhandler.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 __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(
        self,
        command: SCT[str],
        callback: HandlerCallback[Update, CCT, RT],
        filters: Optional[filters_module.BaseFilter] = None,
Severity: Minor
Found in telegram/ext/_handlers/commandhandler.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 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(
Severity: Minor
Found in telegram/ext/_handlers/commandhandler.py - About 35 mins to fix

    Avoid too many return statements within this function.
    Open

            return None
    Severity: Major
    Found in telegram/ext/_handlers/commandhandler.py - About 30 mins to fix

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

          def _check_correct_args(self, args: List[str]) -> Optional[bool]:
              """Determines whether the args are correct for this handler. Implemented in check_update().
              Args:
                  args (:obj:`list`): The args for the handler.
              Returns:
      Severity: Minor
      Found in telegram/ext/_handlers/commandhandler.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