leandrotoledo/python-telegram-bot

View on GitHub
telegram/_message.py

Summary

Maintainability
F
2 wks
Test Coverage

File _message.py has 4083 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

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

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

      Function _parse_markdown has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
      Open

          def _parse_markdown(
              cls,
              message_text: Optional[str],
              entities: Dict[MessageEntity, str],
              urled: bool = False,
      Severity: Minor
      Found in telegram/_message.py - About 6 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 _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 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

        Function _quote has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def _quote(
                self, quote: Optional[bool], reply_to_message_id: Optional[int] = None
            ) -> Optional[ReplyParameters]:
                """Modify kwargs for replying with or without quoting."""
                if reply_to_message_id is not None:
        Severity: Minor
        Found in telegram/_message.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 build_reply_arguments has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def build_reply_arguments(
        Severity: Minor
        Found in telegram/_message.py - About 45 mins to fix

          Function _parse_markdown has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def _parse_markdown(
          Severity: Minor
          Found in telegram/_message.py - About 45 mins to fix

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

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

              Function _parse_html has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

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

                Function link has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def link(self) -> Optional[str]:
                        """:obj:`str`: Convenience property. If the chat of the message is not
                        a private chat or normal group, returns a t.me link of the message.
                
                            .. versionchanged:: 20.3
                Severity: Minor
                Found in telegram/_message.py - About 35 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 _de_json has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _de_json(
                        cls, data: Optional[JSONDict], bot: "Bot", api_kwargs: Optional[JSONDict] = None
                    ) -> Optional["MaybeInaccessibleMessage"]:
                        """See :meth:`telegram.TelegramObject.de_json`."""
                        data = cls._parse_data(data)
                Severity: Minor
                Found in telegram/_message.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

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

                    def build_reply_arguments(
                        self,
                        quote: Optional[str] = None,
                        quote_index: Optional[int] = None,
                        target_chat_id: Optional[Union[int, str]] = None,
                Severity: Minor
                Found in telegram/_message.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