Discord-InterChat/InterChat

View on GitHub

Showing 82 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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        private getMessageFormat(
          message: Message<true>,
          connection: connectedList,
          hub: Hub,
          opts: BroadcastOpts & {
      Severity: Major
      Found in src/services/BroadcastService.ts and 1 other location - About 1 hr to fix
      src/services/BroadcastService.ts on lines 154..179

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 72.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        private async sendToConnection(
          message: Message<true>,
          hub: Hub,
          connection: connectedList,
          opts: BroadcastOpts & {
      Severity: Major
      Found in src/services/BroadcastService.ts and 1 other location - About 1 hr to fix
      src/services/BroadcastService.ts on lines 181..209

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 72.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

          new ButtonBuilder()
            .setCustomId(new CustomID('modPanel:blacklistServer', [author.id, messageId]).toString())
            .setStyle(ButtonStyle.Secondary)
            .setEmoji(emojis.globe_icon)
            .setDisabled(opts.isServerBlacklisted),
      Severity: Major
      Found in src/interactions/ModPanel.ts and 3 other locations - About 1 hr to fix
      src/interactions/ModPanel.ts on lines 155..159
      src/interactions/ModPanel.ts on lines 169..173
      src/interactions/ModPanel.ts on lines 178..182

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 67.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

          new ButtonBuilder()
            .setCustomId(new CustomID('modPanel:deleteMsg', [author.id, messageId]).toString())
            .setStyle(ButtonStyle.Secondary)
            .setEmoji(emojis.deleteDanger_icon)
            .setDisabled(opts.isDeleteInProgress),
      Severity: Major
      Found in src/interactions/ModPanel.ts and 3 other locations - About 1 hr to fix
      src/interactions/ModPanel.ts on lines 155..159
      src/interactions/ModPanel.ts on lines 160..164
      src/interactions/ModPanel.ts on lines 178..182

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 67.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

            new ButtonBuilder()
              .setCustomId(new CustomID('modPanel:banUser', [author.id, messageId]).toString())
              .setStyle(ButtonStyle.Secondary)
              .setEmoji(emojis.blobFastBan)
              .setDisabled(opts.isBanned),
      Severity: Major
      Found in src/interactions/ModPanel.ts and 3 other locations - About 1 hr to fix
      src/interactions/ModPanel.ts on lines 155..159
      src/interactions/ModPanel.ts on lines 160..164
      src/interactions/ModPanel.ts on lines 169..173

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 67.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              new ActionRowBuilder<TextInputBuilder>().addComponents(
                new TextInputBuilder()
                  .setLabel(t('hub.create.modal.banner.label', locale))
                  .setPlaceholder(t('hub.create.modal.banner.placeholder', locale))
                  .setMaxLength(300)
      Severity: Major
      Found in src/commands/slash/Main/hub/create.ts and 1 other location - About 1 hr to fix
      src/commands/slash/Main/hub/create.ts on lines 57..65

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 67.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

          new ButtonBuilder()
            .setCustomId(new CustomID('modPanel:blacklistUser', [author.id, messageId]).toString())
            .setStyle(ButtonStyle.Secondary)
            .setEmoji(emojis.user_icon)
            .setDisabled(opts.isUserBlacklisted),
      Severity: Major
      Found in src/interactions/ModPanel.ts and 3 other locations - About 1 hr to fix
      src/interactions/ModPanel.ts on lines 160..164
      src/interactions/ModPanel.ts on lines 169..173
      src/interactions/ModPanel.ts on lines 178..182

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 67.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              new ActionRowBuilder<TextInputBuilder>().addComponents(
                new TextInputBuilder()
                  .setLabel(t('hub.create.modal.icon.label', locale))
                  .setPlaceholder(t('hub.create.modal.icon.placeholder', locale))
                  .setMaxLength(300)
      Severity: Major
      Found in src/commands/slash/Main/hub/create.ts and 1 other location - About 1 hr to fix
      src/commands/slash/Main/hub/create.ts on lines 66..74

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 67.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

          ) {
            const embed = new EmbedBuilder()
              .setColor('Red')
              .setDescription(`${emojis.no} You do not have permission to use this command.`);
            await message.reply({ embeds: [embed] });
      Severity: Major
      Found in src/commands/prefix/deleteMsg.ts and 1 other location - About 1 hr to fix
      src/commands/prefix/modpanel.ts on lines 39..45

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 62.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

          if (!hub || !isStaffOrHubMod(message.author.id, hub)) {
            const embed = new EmbedBuilder()
              .setColor('Red')
              .setDescription(`${emojis.no} You do not have permission to use this command.`);
            await message.reply({ embeds: [embed] });
      Severity: Major
      Found in src/commands/prefix/modpanel.ts and 1 other location - About 1 hr to fix
      src/commands/prefix/deleteMsg.ts on lines 45..51

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 62.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              const filtered = choices
                .filter(
                  (choice) =>
                    choice.name.toLowerCase().includes(focusedValue) ||
                    choice.value.toLowerCase().includes(focusedValue),
      Severity: Major
      Found in src/commands/slash/Staff/find/index.ts and 1 other location - About 1 hr to fix
      src/commands/slash/Staff/find/index.ts on lines 90..96

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 60.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            new StringSelectMenuBuilder()
              .setCustomId(
                new CustomID()
                  .setIdentifier('hub_edit', 'logsSelect')
                  .addArgs(userId)
      Severity: Major
      Found in src/managers/HubLogManager.ts and 1 other location - About 1 hr to fix
      src/utils/hub/settings.ts on lines 12..30

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 60.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Severity
      Category
      Status
      Source
      Language