leandrotoledo/python-telegram-bot

View on GitHub
telegram/ext/_extbot.py

Summary

Maintainability
F
1 wk
Test Coverage

File _extbot.py has 3926 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/ext/_extbot.py - About 1 wk to fix

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

        def _insert_defaults(self, data: Dict[str, object]) -> None:
            """Inserts the defaults values for optional kwargs for which tg.ext.Defaults provides
            convenience functionality, i.e. the kwargs with a tg.utils.helpers.DefaultValue default
    
            data is edited in-place. As timeout is not passed via the kwargs, it needs to be passed
    Severity: Minor
    Found in telegram/ext/_extbot.py - About 3 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 _insert_defaults_for_ilq_results has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def _insert_defaults_for_ilq_results(self, res: "InlineQueryResult") -> "InlineQueryResult":
            """This method is called by Bot.answer_inline_query to replace `DefaultValue(obj)` with
            `obj`.
            Overriding this to call insert the actual desired default values.
            """
    Severity: Minor
    Found in telegram/ext/_extbot.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 __init__ has 11 arguments (exceeds 4 allowed). Consider refactoring.
    Open

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

      Function __init__ has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

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

        Function _insert_callback_data has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def _insert_callback_data(self, obj: HandledTypes) -> HandledTypes:
                if self.callback_data_cache is None:
                    return obj
        
                if isinstance(obj, CallbackQuery):
        Severity: Minor
        Found in telegram/ext/_extbot.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 10 arguments (exceeds 4 allowed). Consider refactoring.
        Open

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

          Avoid deeply nested control flow statements.
          Open

                                  with media._unfrozen():
                                      media.parse_mode = self.defaults.parse_mode
          
          
          Severity: Major
          Found in telegram/ext/_extbot.py - About 45 mins to fix

            There are no issues that match your filters.

            Category
            Status