tulir/mautrix-telegram

View on GitHub

Showing 61 of 61 total issues

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

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

    File config.py has 264 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # mautrix-telegram - A Matrix-Telegram puppeting bridge
    # Copyright (C) 2021 Tulir Asokan
    #
    # This program is free software: you can redistribute it and/or modify
    # it under the terms of the GNU Affero General Public License as published by
    Severity: Minor
    Found in mautrix_telegram/config.py - About 2 hrs to fix

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

      def _parse_flag(args: list[str]) -> tuple[str, str]:
          arg = args.pop(0).lower()
          if arg == "--":
              return "", ""
          value = ""
      Severity: Minor
      Found in mautrix_telegram/commands/portal/misc.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 command_handler has 12 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def command_handler(
      Severity: Major
      Found in mautrix_telegram/commands/handler.py - About 1 hr to fix

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

            def __init__(
        Severity: Major
        Found in mautrix_telegram/commands/handler.py - About 1 hr to fix

          Function get_mx_login_response has 10 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def get_mx_login_response(
          Severity: Major
          Found in mautrix_telegram/web/provisioning/__init__.py - About 1 hr to fix

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

                def __init__(
            Severity: Major
            Found in mautrix_telegram/commands/handler.py - About 1 hr to fix

              Function get_login_response has 10 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def get_login_response(
              Severity: Major
              Found in mautrix_telegram/web/provisioning/__init__.py - About 1 hr to fix

                Function get_mx_login_response has 9 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def get_mx_login_response(
                Severity: Major
                Found in mautrix_telegram/web/common/auth_api.py - About 1 hr to fix

                  Function get_mx_login_response has 9 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def get_mx_login_response(
                  Severity: Major
                  Found in mautrix_telegram/web/public/__init__.py - About 1 hr to fix

                    Function get_login_response has 9 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def get_login_response(
                    Severity: Major
                    Found in mautrix_telegram/web/common/auth_api.py - About 1 hr to fix

                      Function new has 9 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def new(
                      Severity: Major
                      Found in mautrix_telegram/db/backfill_queue.py - About 1 hr to fix

                        Function get_login_response has 9 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def get_login_response(
                        Severity: Major
                        Found in mautrix_telegram/web/public/__init__.py - About 1 hr to fix

                          Function __init__ has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              def __init__(self, bridge: "TelegramBridge") -> None:
                                  super().__init__(bridge.loop)
                                  self.secret = bridge.config["appservice.provisioning.shared_secret"]
                                  self.az = bridge.az
                                  self.bridge = bridge
                          Severity: Minor
                          Found in mautrix_telegram/web/provisioning/__init__.py - About 1 hr to fix

                            Function get_displayname has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def get_displayname(cls, info: User | Channel, enable_format: bool = True) -> tuple[str, int]:
                                    if isinstance(info, Channel):
                                        fn, ln = cls._filter_name(info.title), ""
                                    else:
                                        fn = cls._filter_name(info.first_name)
                            Severity: Minor
                            Found in mautrix_telegram/puppet.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 _hash_content has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def _hash_content(self, event: TypeMessage) -> Generator[Any, None, None]:
                                    if not self._always_force_hash:
                                        yield event.id
                                    yield int(event.date.timestamp())
                                    if isinstance(event, MessageService):
                            Severity: Minor
                            Found in mautrix_telegram/portal_util/deduplication.py - About 55 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 _cut_long_message has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def _cut_long_message(
                                message: str, entities: list[TypeMessageEntity]
                            ) -> tuple[str, list[TypeMessageEntity]]:
                                if len(message) > MAX_LENGTH:
                                    message = message[0:CUT_MAX_LENGTH] + CUTOFF_TEXT
                            Severity: Minor
                            Found in mautrix_telegram/formatter/from_matrix/__init__.py - About 55 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 config_add_del has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def config_add_del(
                                evt: CommandEvent, portal: po.Portal, key: str, value: str, cmd: str
                            ) -> Awaitable[EventID]:
                                if not key or value is None:
                                    return evt.reply(f"**Usage:** `$cmdprefix+sp config {cmd} <key> <value>`")
                            Severity: Minor
                            Found in mautrix_telegram/commands/portal/config.py - About 55 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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                def __init__(
                            Severity: Major
                            Found in mautrix_telegram/user.py - About 50 mins to fix

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

                                  def __init__(
                              Severity: Major
                              Found in mautrix_telegram/util/parallel_file_transfer.py - About 50 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language