leandrotoledo/python-telegram-bot

View on GitHub

Showing 334 of 334 total issues

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

File _defaults.py has 299 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2024
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
Severity: Minor
Found in telegram/ext/_defaults.py - About 3 hrs to fix

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

        def __init__(
    Severity: Major
    Found in telegram/_update.py - About 3 hrs to fix

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

          def __init__(
      Severity: Major
      Found in telegram/_reply.py - About 3 hrs to fix

        Function to_dict has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

            def to_dict(self, recursive: bool = True) -> JSONDict:
                """Gives representation of object as :obj:`dict`.
        
                .. versionchanged:: 20.0
        
        
        Severity: Minor
        Found in telegram/_telegramobject.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

        Defaults has 26 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Defaults:
            """Convenience Class to gather all parameters with a (user defined) default value
        
            .. seealso:: :wiki:`Architecture Overview <Architecture>`,
                :wiki:`Adding Defaults to Your Bot <Adding-defaults-to-your-bot>`
        Severity: Minor
        Found in telegram/ext/_defaults.py - About 3 hrs to fix

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

              def __init__(
          Severity: Major
          Found in telegram/_inline/inputinvoicemessagecontent.py - About 2 hrs to fix

            File nestedconversationbot.py has 280 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            #!/usr/bin/env python
            # pylint: disable=unused-argument
            # This program is dedicated to the public domain under the CC0 license.
            
            """
            Severity: Minor
            Found in examples/nestedconversationbot.py - About 2 hrs to fix

              Function de_json has 68 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def de_json(cls, data: Optional[JSONDict], bot: "Bot") -> Optional["Message"]:
                      """See :meth:`telegram.TelegramObject.de_json`."""
                      data = cls._parse_data(data)
              
                      if not data:
              Severity: Major
              Found in telegram/_message.py - About 2 hrs to fix

                File _replykeyboardmarkup.py has 276 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                #!/usr/bin/env python
                #
                # A library that provides a Python interface to the Telegram Bot API
                # Copyright (C) 2015-2024
                # Leandro Toledo de Souza <devs@python-telegram-bot.org>
                Severity: Minor
                Found in telegram/_replykeyboardmarkup.py - About 2 hrs to fix

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

                      def check_update(self, update: object) -> bool:
                          """Determines whether an update should be passed to this handler's :attr:`callback`.
                  
                          Args:
                              update (:class:`telegram.Update` | :obj:`object`): Incoming update.
                  Severity: Minor
                  Found in telegram/ext/_handlers/messagereactionhandler.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 check_update has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def check_update(self, update: object) -> Optional[Union[bool, object]]:
                          """Determines whether an update should be passed to this handler's :attr:`callback`.
                  
                          Args:
                              update (:class:`telegram.Update` | :obj:`object`): Incoming update.
                  Severity: Minor
                  Found in telegram/ext/_handlers/callbackqueryhandler.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 autodoc_process_docstring has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def autodoc_process_docstring(
                      app: Sphinx, what, name: str, obj: object, options, lines: list[str]
                  ):
                      """We do the following things:
                      1) Use this method to automatically insert the Keyword Args and "Shortcuts" admonitions
                  Severity: Minor
                  Found in docs/auxil/sphinx_hooks.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

                  File file.py has 271 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  #!/usr/bin/env python
                  #
                  # A library that provides a Python interface to the Telegram Bot API
                  # Copyright (C) 2015-2024
                  # Leandro Toledo de Souza <devs@python-telegram-bot.org>
                  Severity: Minor
                  Found in telegram/_files/file.py - About 2 hrs to fix

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

                        def __init__(
                    Severity: Major
                    Found in telegram/_chatmember.py - About 2 hrs to fix

                      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 _value_and_input_files_from_input has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def _value_and_input_files_from_input(  # pylint: disable=too-many-return-statements
                              value: object,
                          ) -> Tuple[object, List[InputFile]]:
                              """Converts `value` into something that we can json-dump. Returns two values:
                              1. the JSON-dumpable value. Maybe be `None` in case the value is an InputFile which must
                      Severity: Minor
                      Found in telegram/request/_requestparameter.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 19 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def __init__(
                      Severity: Major
                      Found in telegram/_chatmember.py - About 2 hrs to fix

                        File _giveaway.py has 261 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        #!/usr/bin/env python
                        #
                        # A library that provides a Python interface to the Telegram Bot API
                        # Copyright (C) 2015-2024
                        # Leandro Toledo de Souza <devs@python-telegram-bot.org>
                        Severity: Minor
                        Found in telegram/_giveaway.py - About 2 hrs to fix

                          Function effective_chat has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def effective_chat(self) -> Optional["Chat"]:
                                  """
                                  :class:`telegram.Chat`: The chat that this update was sent in, no matter what kind of
                                  update this is.
                                  If no chat is associated with this update, this gives :obj:`None`.
                          Severity: Minor
                          Found in telegram/_update.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

                          Severity
                          Category
                          Status
                          Source
                          Language