Discord-InterChat/InterChat

View on GitHub

Showing 43 of 97 total issues

File index.ts has 580 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import BaseCommand from '#main/core/BaseCommand.js';
import { logsWithRoleId } from '#main/managers/HubLogManager.js';
import { HubSettingsBits } from '#main/modules/BitFields.js';
import db from '#utils/Db.js';
import { escapeRegexChars, handleError, toTitleCase } from '#utils/Utils.js';
Severity: Major
Found in src/commands/slash/Main/hub/index.ts - About 1 day to fix

    Function checkBlockedWords has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

    export async function checkBlockedWords(message: Message<true>, msgBlockList: MessageBlockList[]) {
      if (msgBlockList.length === 0) return Promise.resolve({ passed: true });
    
      for (const rule of msgBlockList) {
        const regex = createRegexFromWords(rule.words);
    Severity: Minor
    Found in src/utils/network/blockwordsRunner.ts - About 4 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 edit.ts has 269 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import Constants, { emojis } from '#utils/Constants.js';
    import { RegisterInteractionHandler } from '#main/decorators/RegisterInteractionHandler.js';
    import { isGuildTextBasedChannel } from '#utils/ChannelUtls.js';
    import { setComponentExpiry } from '#utils/ComponentUtils.js';
    import { updateConnection } from '#utils/ConnectedListUtils.js';
    Severity: Minor
    Found in src/commands/slash/Main/connection/edit.ts - About 2 hrs to fix

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

        async execute(interaction: Interaction<CacheType>) {
          try {
            if (this.isInMaintenance(interaction)) return;
      
            const dbUser = (await interaction.client.userManager.getUser(interaction.user.id)) ?? null;
      Severity: Minor
      Found in src/events/interactionCreate.ts - 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 execute has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        async execute(interaction: ChatInputCommandInteraction<CacheType>) {
          const subcommand = interaction.options.getSubcommand();
      
          const { userManager } = interaction.client;
          const locale = await userManager.getUserLocale(interaction.user.id);
      Severity: Minor
      Found in src/commands/slash/Main/hub/invite.ts - 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 autocomplete has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        async autocomplete(interaction: AutocompleteInteraction): Promise<void> {
          const managerCmds = [
            'edit',
            'visibility',
            'settings',
      Severity: Minor
      Found in src/commands/slash/Main/hub/index.ts - 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 appealReviewButton has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        @RegisterInteractionHandler('appealReview')
        async appealReviewButton(interaction: ButtonInteraction): Promise<void> {
          const customId = CustomID.parseCustomId(interaction.customId);
          const [type, hubId, targetId] = customId.args as ['user' | 'server', string, Snowflake];
      
      
      Severity: Minor
      Found in src/interactions/BlacklistAppeal.ts - 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 execute has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        public async execute(
          reaction: MessageReaction | PartialMessageReaction,
          user: User | PartialUser,
        ) {
          if (user.bot || !reaction.message.inGuild()) return;
      Severity: Minor
      Found in src/events/messageReactionAdd.ts - 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 findMatch has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        async findMatch(serverId: string, preferences: ServerPreferences): Promise<QueuedChannel | null> {
          const serverHistory = await this.db.serverHistory.findUnique({
            where: { serverId },
          });
      
      
      Severity: Minor
      Found in src/services/LobbyMatchingService.ts - 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 createEmbed has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        public createEmbed(iconUrl: string | null, locale: supportedLocaleCodes = 'en') {
          const channelStr = t('hub.manage.logs.config.fields.channel', locale);
          const roleStr = t('hub.manage.logs.config.fields.role', locale);
      
          const logDesc = this.logTypes
      Severity: Minor
      Found in src/managers/HubLogManager.ts - 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 execute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        public async execute(message: Message, args: string[]): Promise<void> {
          try {
            // Check if command is owner-only
            if (this.data.ownerOnly && !isDev(message.author.id)) {
              await message.reply(`${emojis.botdev} This command can only be used by the bot owner.`);
      Severity: Minor
      Found in src/core/BasePrefixCommand.ts - 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 updateMessageComponents has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      const updateMessageComponents = async (
        webhook: WebhookClient,
        messageId: string,
        threadId: string | undefined,
        reactionBtn: ActionRowBuilder<ButtonBuilder> | null,
      Severity: Minor
      Found in src/utils/reaction/actions.ts - 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 handleModals has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        @RegisterInteractionHandler('connectionModal')
        async handleModals(interaction: ModalSubmitInteraction): Promise<void> {
          const customId = CustomID.parseCustomId(interaction.customId);
          const locale = await this.getLocale(interaction);
      
      
      Severity: Minor
      Found in src/commands/slash/Main/connection/edit.ts - 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 listenForReactionButton has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        @RegisterInteractionHandler('reaction_')
        async listenForReactionButton(
          interaction: ButtonInteraction | AnySelectMenuInteraction,
        ): Promise<void> {
          await interaction.deferUpdate();
      Severity: Minor
      Found in src/interactions/NetworkReaction.ts - 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 handleStringSelects has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        @RegisterInteractionHandler('connection')
        async handleStringSelects(interaction: StringSelectMenuInteraction) {
          if (!interaction.isStringSelectMenu()) return;
      
          const customId = CustomID.parseCustomId(interaction.customId);
      Severity: Minor
      Found in src/commands/slash/Main/connection/edit.ts - 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 execute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        async execute(interaction: ChatInputCommandInteraction) {
          await interaction.deferReply();
      
          const { id: moderatorId } = interaction.user;
          const { userManager } = interaction.client;
      Severity: Minor
      Found in src/commands/slash/Main/blacklist/user.ts - 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 execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        async execute(interaction: ChatInputCommandInteraction): Promise<void> {
          const hideResponse = interaction.options.getBoolean('hidden') ?? true;
          const userId = interaction.options.getString('user', true);
          const user = await interaction.client.users.fetch(userId).catch(() => null);
          if (!user) {
      Severity: Minor
      Found in src/commands/slash/Staff/find/user.ts - 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 sendBlacklistNotif has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export const sendBlacklistNotif = async (
        type: 'user' | 'server',
        client: Client,
        opts: BlacklistOpts,
      ) => {
      Severity: Minor
      Found in src/utils/moderation/blacklistUtils.ts - 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

      Avoid deeply nested control flow statements.
      Open

                  if (result.success && result.shouldBlock) {
                    shouldBlock = true;
                    blockReason = result.message;
                  }
      Severity: Major
      Found in src/utils/network/blockwordsRunner.ts - About 45 mins to fix

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

        export const t = <K extends keyof TranslationKeys>(
          phrase: K,
          locale: supportedLocaleCodes,
          variables?: { [Key in TranslationKeys[K]]: string },
        ): string => {
        Severity: Minor
        Found in src/utils/Locale.ts - 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

        Severity
        Category
        Status
        Source
        Language