leandrotoledo/python-telegram-bot

View on GitHub
telegram/_bot.py

Summary

Maintainability
F
3 wks
Test Coverage

File _bot.py has 7766 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
# pylint: disable=too-many-arguments
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2024
Severity: Major
Found in telegram/_bot.py - About 3 wks to fix

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

        def __init__(
            self,
            token: str,
            base_url: str = "https://api.telegram.org/bot",
            base_file_url: str = "https://api.telegram.org/file/bot",
    Severity: Minor
    Found in telegram/_bot.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 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Major
    Found in telegram/_bot.py - About 1 hr to fix

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

          def _insert_defaults(self, data: Dict[str, object]) -> None:
              """This method is here to make ext.Defaults work. Because we need to be able to tell
              e.g. `send_message(chat_id, text)` from `send_message(chat_id, text, parse_mode=None)`, the
              default values for `parse_mode` etc are not `None` but `DEFAULT_NONE`. While this *could*
              be done in ExtBot instead of Bot, shortcuts like `Message.reply_text` need to work for both
      Severity: Minor
      Found in telegram/_bot.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 _parse_file_input has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def _parse_file_input(
      Severity: Minor
      Found in telegram/_bot.py - About 35 mins to fix

        There are no issues that match your filters.

        Category
        Status