tulir/mautrix-telegram

View on GitHub

Showing 61 of 61 total issues

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

    def __init__(
Severity: Minor
Found in mautrix_telegram/db/telethon_session.py - About 45 mins to fix

    Function parse_emoji_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_emoji_data(tone: dict[str, Any], emoji: dict[str, Any]) -> Emoji:
        hex = (tone["non_qualified"] or tone["unified"]).replace("-FE0F", "")
        filename_hex = hex.replace("-", "_").lower()
        filename = f"svg/emoji_u{filename_hex}.svg"
        if emoji["category"] == "Flags" and emoji["subcategory"] in (
    Severity: Minor
    Found in mautrix_telegram/scripts/unicodemojipack/__main__.py - About 45 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 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Minor
    Found in mautrix_telegram/util/parallel_file_transfer.py - About 45 mins to fix

      Consider simplifying this complex logical expression.
      Open

              if is_sticker and tgs_convert and is_tgs:
                  converted_anim = await convert_tgs_to(
                      file, tgs_convert["target"], **tgs_convert["args"]
                  )
                  mime_type = converted_anim.mime
      Severity: Major
      Found in mautrix_telegram/util/file_transfer.py - About 40 mins to fix

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

        def _get_portal_murder_function(
        Severity: Minor
        Found in mautrix_telegram/commands/portal/unbridge.py - About 35 mins to fix

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

              def _entity_values_to_row(
          Severity: Minor
          Found in mautrix_telegram/db/telethon_session.py - About 35 mins to fix

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

            def config_add_del(
            Severity: Minor
            Found in mautrix_telegram/commands/portal/config.py - About 35 mins to fix

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

              def _parse_delta(value: str) -> timedelta | None:
                  match = delta_regex.fullmatch(value)
                  if not match:
                      return None
                  number = int(match.group(1))
              Severity: Minor
              Found in mautrix_telegram/commands/portal/misc.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

              Avoid too many return statements within this function.
              Open

                      return None
              Severity: Major
              Found in mautrix_telegram/commands/portal/misc.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return timedelta(seconds=number)
                Severity: Major
                Found in mautrix_telegram/commands/portal/misc.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return evt.reply(f"Successfully added {_str_value(value)} to the array at `{key}`")
                  Severity: Major
                  Found in mautrix_telegram/commands/portal/config.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return evt.reply(f"Successfully removed {_str_value(value)} from the array at `{key}`")
                    Severity: Major
                    Found in mautrix_telegram/commands/portal/config.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return True
                      Severity: Major
                      Found in mautrix_telegram/portal.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return timedelta(minutes=number)
                        Severity: Major
                        Found in mautrix_telegram/commands/portal/misc.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return evt.reply(f"The array at `{key}` does not contain {_str_value(value)}")
                          Severity: Major
                          Found in mautrix_telegram/commands/portal/config.py - About 30 mins to fix

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

                            def parse_tl_json(val: TypeJSONValue) -> JSON:
                                if isinstance(val, JsonObject):
                                    return {entry.key: parse_tl_json(entry.value) for entry in val.value}
                                elif isinstance(val, JsonArray):
                                    return [parse_tl_json(item) for item in val.value]
                            Severity: Minor
                            Found in mautrix_telegram/util/tl_json.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 recursive_set has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def recursive_set(data: dict[str, Any], key: str, value: Any) -> bool:
                                key, next_key = RecursiveDict.parse_key(key)
                                if next_key is not None:
                                    if key not in data:
                                        data[key] = {}
                            Severity: Minor
                            Found in mautrix_telegram/util/recursive_dict.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

                            Refactor this function to reduce its Cognitive Complexity from 18 to the 15 allowed.
                            Open

                            async def session(evt: CommandEvent) -> EventID:

                            Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

                            See

                            Refactor this function to reduce its Cognitive Complexity from 27 to the 15 allowed.
                            Open

                            def get_base_power_levels(

                            Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

                            See

                            Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed.
                            Open

                            async def edit_filter(evt: CommandEvent) -> EventID:

                            Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

                            See

                            Severity
                            Category
                            Status
                            Source
                            Language