leandrotoledo/python-telegram-bot

View on GitHub

Showing 351 of 351 total issues

Function _parse_html has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    def _parse_html(
        cls,
        message_text: Optional[str],
        entities: Dict[MessageEntity, str],
        urled: bool = False,
Severity: Minor
Found in telegram/_message.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 filter has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    def filter(self, update: Update) -> Union[bool, FilterDataDict]:
        base_output = self.base_filter.check_update(update)
        # We need to check if the filters are data filters and if so return the merged data.
        # If it's not a data filter or an or_filter but no matches return bool
        if self.and_filter:
Severity: Minor
Found in telegram/ext/filters.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 30 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

    File _chatboost.py has 312 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/_chatboost.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

          File sticker.py has 292 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/sticker.py - About 3 hrs to fix

            Function de_json has 69 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

              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

                  File _replykeyboardmarkup.py has 277 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 _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 _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 19 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

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