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';
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);
- Read upRead up
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';
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;
- Read upRead up
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);
- Read upRead up
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',
- Read upRead up
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];
- Read upRead up
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;
- Read upRead up
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 },
});
- Read upRead up
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
- Read upRead up
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.`);
- Read upRead up
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,
- Read upRead up
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);
- Read upRead up
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();
- Read upRead up
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);
- Read upRead up
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;
- Read upRead up
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) {
- Read upRead up
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,
) => {
- Read upRead up
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;
}
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 => {
- Read upRead up
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"