Discord-InterChat/InterChat

View on GitHub

Showing 115 of 126 total issues

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

import BaseCommand from '#main/core/BaseCommand.js';
import { logsWithRoleId } from '#main/managers/HubLogManager.js';
import HubManager from '#main/managers/HubManager.js';
import { HubSettingsBits } from '#main/modules/BitFields.js';
import { HubService } from '#main/services/HubService.js';
Severity: Major
Found in src/commands/slash/Main/hub/index.ts - About 1 day to fix

    Function handleStringSelects has 86 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      @RegisterInteractionHandler('connection')
      async handleStringSelects(interaction: StringSelectMenuInteraction) {
        if (!interaction.isStringSelectMenu()) return;
    
        const customId = CustomID.parseCustomId(interaction.customId);
    Severity: Major
    Found in src/commands/slash/Main/connection/edit.ts - About 3 hrs to fix

      Function run has 71 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        protected async run(message: Message<true>, args: string[]) {
          const minServers = parseInt(args[0], 10) || 2;
      
          const alreadyInLobby = await this.lobbyManager.getLobbyByChannelId(message.channelId);
          if (alreadyInLobby) {
      Severity: Major
      Found in src/commands/prefix/connect.ts - About 2 hrs to fix

        Function logAppeals has 67 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const logAppeals = async (
          type: 'user' | 'server',
          hubId: string,
          appealer: User,
          opts: {
        Severity: Major
        Found in src/utils/hub/logger/Appeals.ts - About 2 hrs to fix

          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 61 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async execute(interaction: ChatInputCommandInteraction) {
                const baseEmbed = new EmbedBuilder()
                  .setColor(Constants.Colors.invisible)
                  .setThumbnail(interaction.client.user.displayAvatarURL());
            
            
            Severity: Major
            Found in src/commands/slash/Information/help.ts - About 2 hrs to fix

              Function handleModals has 60 lines of code (exceeds 25 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: Major
              Found in src/commands/slash/Main/connection/edit.ts - About 2 hrs to fix

                Function execute has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async execute(interaction: ChatInputCommandInteraction): Promise<void> {
                    const hideResponse = interaction.options.getBoolean('hidden') ?? true;
                    await interaction.deferReply({ ephemeral: hideResponse });
                
                    const serverId = interaction.options.getString('server', true);
                Severity: Major
                Found in src/commands/slash/Staff/find/server.ts - About 2 hrs to fix

                  Function execute has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    async execute(interaction: ChatInputCommandInteraction) {
                      await interaction.deferReply();
                  
                      const { id: moderatorId } = interaction.user;
                      const { userManager } = interaction.client;
                  Severity: Major
                  Found in src/commands/slash/Main/blacklist/user.ts - About 2 hrs to fix

                    Function execute has 55 lines of code (exceeds 25 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: Major
                    Found in src/commands/slash/Staff/find/user.ts - About 2 hrs to fix

                      Function handleChannelSelects has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        @RegisterInteractionHandler('connection', 'change_channel')
                        async handleChannelSelects(interaction: ChannelSelectMenuInteraction) {
                          if (!interaction.isChannelSelectMenu()) return;
                          await interaction.deferUpdate();
                      
                      
                      Severity: Major
                      Found in src/commands/slash/Main/connection/edit.ts - About 2 hrs to fix

                        Function execute has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          async execute(interaction: ChatInputCommandInteraction) {
                            const creditsEmbed = new InfoEmbed()
                              .setDescription(
                                stripIndents`
                                ### ${emojis.wand} About InterChat
                        Severity: Major
                        Found in src/commands/slash/Information/about.ts - About 2 hrs to fix

                          Function handleCreateSubcommand has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            private async handleCreateSubcommand(
                              interaction: ChatInputCommandInteraction,
                              locale: supportedLocaleCodes,
                            ) {
                              const hubName = interaction.options.getString('hub', true);
                          Severity: Minor
                          Found in src/commands/slash/Main/hub/invite.ts - About 1 hr to fix

                            Function appealReviewButton has 48 lines of code (exceeds 25 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

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

                                private async sendToConnection(
                                  message: Message<true>,
                                  hub: HubManager,
                                  connection: Connection,
                                  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 2 locations. Consider refactoring.
                              Open

                                private getMessageFormat(
                                  message: Message<true>,
                                  connection: Connection,
                                  hub: HubManager,
                                  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

                              Function execute has 46 lines of code (exceeds 25 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

                                Function buildEditEmbed has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                export const buildEditEmbed = async (
                                  channelId: string,
                                  iconURL: string | undefined,
                                  locale: supportedLocaleCodes = 'en',
                                ) => {
                                Severity: Minor
                                Found in src/utils/network/buildConnectionAssets.ts - About 1 hr to fix

                                  Function execute has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    async execute(interaction: ChatInputCommandInteraction<CacheType>) {
                                      const { userManager } = interaction.client;
                                      const locale = await userManager.getUserLocale(interaction.user.id);
                                  
                                      if (await this.isOnCooldown(interaction, locale)) return;
                                  Severity: Minor
                                  Found in src/commands/slash/Main/hub/create.ts - About 1 hr to fix

                                    Function autocomplete has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      async autocomplete(interaction: AutocompleteInteraction): Promise<void> {
                                        const modCmds = ['servers', 'invite', 'announce'];
                                        const managerCmds = [
                                          'edit',
                                          'visibility',
                                    Severity: Minor
                                    Found in src/commands/slash/Main/hub/index.ts - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language