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';
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);
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) {
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: {
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';
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());
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);
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);
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;
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) {
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();
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
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);
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];
Similar blocks of code found in 2 locations. Consider refactoring. Open
private async sendToConnection(
message: Message<true>,
hub: HubManager,
connection: Connection,
opts: BroadcastOpts & {
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
private getMessageFormat(
message: Message<true>,
connection: Connection,
hub: HubManager,
opts: BroadcastOpts & {
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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.`);
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',
) => {
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;
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',