Showing 65 of 129 total issues
Function resolveCreateMessageData
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function resolveCreateMessageData(input: CreateMessageData): CreateMessageResult {
const data = toJSONValue(input as JSONResolvable<CreateMessageObject>);
// String
if (typeof data === 'string') {
Function toJSONValue
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export function toJSONValue<T extends JSONValue>(
o: JSONResolvable<T>,
locale: string = process.env['LOCALE'] ?? 'unknown'
): T {
if (Array.isArray(o)) {
- 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 toJSONValue
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export function toJSONValue<T extends JSONValue>(
o: JSONResolvable<T>,
locale: string = process.env['LOCALE'] ?? 'unknown'
): T {
if (Array.isArray(o)) {
- 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 onClose
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
private onClose({ code }: CloseEvent) {
if (code === 1000) {
return;
}
Function $slashCommand
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function $slashCommand<T>(options: SlashCommandData<T>) {
const commandOptions = toJSONValue(options.options ?? []);
const autocompleteHandlers = getOptionBuilderAutocompleteHandlers(options.options);
return $merge([
Function load
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
load(id) {
const toInclude = id.split('+').filter(x => hookIDs.includes(x));
if (toInclude.length === 0) {
return `export default []`;
}
Function onRawPacket
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private onRawPacket(buf: string | Uint8Array) {
let raw: Uint8Array | string;
if (this.inflate) {
const l = buf.length;
// TODO: use a single equals check instead of four separate ones.
- 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 deploy
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export async function deploy(options: DeployOptions) {
Logger.info(`Preparing to ${options.delete ? 'delete' : 'deploy'} commands.`);
const config = await loadConfig(options.root);
const token = env.DISCORD_TOKEN;
- 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 prettierConfig
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function prettierConfig(config: ProjectConfig) {
if (config.lang !== 'js') {
// This config is based off of prettier-config-dave
return {
arrowParens: 'avoid',
Function deploy
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function deploy(options: DeployOptions) {
Logger.info(`Preparing to ${options.delete ? 'delete' : 'deploy'} commands.`);
const config = await loadConfig(options.root);
const token = env.DISCORD_TOKEN;
Function mergePresence
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export function mergePresence(presences: PresenceHookData[]): GatewayPresenceUpdateData {
const obj: GatewayPresenceUpdateData = {
afk: false,
activities: [],
since: 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 $messageComponent
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function $messageComponent<
Context,
CreateProps,
ComponentType extends APIMessageActionRowComponent
>(options: MessageComponentOptions<Context, CreateProps, ComponentType>) {
- 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 createViteConfig
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function createViteConfig(config: ResolvedConfig, mode: 'development' | 'production') {
const userViteConfig = await (typeof config.vite === 'function' ? config.vite() : config.vite);
const alias: Record<string, string> = {};
Function runHook
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function runHook<Data, Type extends HookType>(
features: FeatureArrayResolvable,
hook: Hook<Data, Type>,
extraArg?: Data | MergeFunction<Data, unknown>
) {
Function $mentionCommand
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function $mentionCommand(params: MentionCommandData) {
return $merge([
$gatewayEvent('MESSAGE_CREATE', async apiMessage => {
const message = new Message(apiMessage);
Function onRawPacket
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private onRawPacket(buf: string | Uint8Array) {
let raw: Uint8Array | string;
if (this.inflate) {
const l = buf.length;
// TODO: use a single equals check instead of four separate ones.
Function sendIdentify
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private sendIdentify() {
if (this.sessionId) {
debug('sending resume, seq=%s', this.seq);
this.send({
op: GatewayOpcodes.Resume,
Function alias
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
alias: validate<ResolvedConfig['alias']>(def.alias, (input, keypath) => {
if (typeof input !== 'object' || !input) {
throw new Error(`${keypath} should be an object`);
}
- 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 dynamicVirtual
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function dynamicVirtual(name: string, entries: VirtualEntry[]): Plugin {
const log = new Logger('build:dynamic', { debug: true });
const PREFIX = `\0virtual:${name}:`;
return {
name: `purplet-${name}`,
Function runHook
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export async function runHook<Data, Type extends HookType>(
features: FeatureArrayResolvable,
hook: Hook<Data, Type>,
extraArg?: Data | MergeFunction<Data, unknown>
) {
- 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"