Showing 65 of 129 total issues
Function transformContents
has a Cognitive Complexity of 75 (exceeds 5 allowed). Consider refactoring. Open
function transformContents({ contents, exportName, filename }) {
const lines = contents.split('\n').concat('## EOF');
let currentEndpoint = null;
let tempMatch = 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
File gen-routes.js
has 290 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env node
import { execSync } from 'child_process';
import { existsSync, readFileSync, writeFileSync } from 'fs';
import { capitalize } from '@paperdave/utils';
Function showHelp
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
_showHelp.call(cli, data => {
const isRoot = data.startsWith('purplet <command>');
const lines = data.split('\n');
Function writeAll
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function writeAll(config: ProjectConfig, templatesRoot: string) {
const { eslint, prettier, root, template } = config;
const require = createRequire(import.meta.url);
Function writeTSConfig
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function writeTSConfig(config: ResolvedConfig) {
const files = await readdir(config.root);
const matched = searchPaths.filter(file => files.includes(file));
const rootRelative = (file: string) => posixify(path.relative(config.root, file));
Function createConfig
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function createConfig(templatesRoot: string) {
const config = {} as ProjectConfig;
// Calculate initial directory based off of if this directory is 'empty' or not
// Empty is a loose check that allows some stuff like `.git`
File serializers.ts
has 270 lines of code (exceeds 250 allowed). Consider refactoring. Open
import type { Dict } from '@paperdave/utils';
import type { BitBuffer } from './BitBuffer';
import { BitSerializer } from './BitSerializer';
import type { Generic } from './utils';
import { fillArray } from './utils';
Function $messageComponent
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
function $messageComponent<
Context,
CreateProps,
ComponentType extends APIMessageActionRowComponent
>(options: MessageComponentOptions<Context, CreateProps, ComponentType>) {
Function Home
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function Home(): JSX.Element {
return (
<Layout title={`Home`} description='Description will go into a meta tag in <head />'>
<header className={clsx('hero hero--primary', styles.heroBanner)}>
<div className={clsx('container', styles.header)}>
Function request
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
async request<Output>(endpoint: string, options: RequestOptionsWithMethod): Promise<Output> {
const query = Object.entries(options.query ?? {})
.filter(([, value]) => value !== undefined)
.map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
.join('&');
- 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 mergeCommands
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function mergeCommands(_list: ApplicationCommandResolvable[]) {
/** I am sorry... */
const list: any[] = _list;
const groups = list.filter(x => 'isSlashCommandGroup' in x && !x.name.includes(' '));
Function handleInteraction
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function handleInteraction(
request: Request,
publicKey: Uint8Array
): Promise<Response> {
const signature = request.headers.get('X-Signature-Ed25519');
Function start
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
async start() {
const spinner = new Spinner({
text: this.firstRun ? 'Initializing development mode...' : 'Reloading...',
});
this.firstRun = false;
Function createRollupConfig
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
export function createRollupConfig({ input, cli = false, plugins = [], cjs = true }) {
const outputRoot = path.resolve('./dist');
let version = '0.0.0-unknown';
let pname = undefined;
- 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 request
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
async request<Output>(endpoint: string, options: RequestOptionsWithMethod): Promise<Output> {
const query = Object.entries(options.query ?? {})
.filter(([, value]) => value !== undefined)
.map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
.join('&');
Function loadConfig
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function loadConfig(root: string) {
const files = await readdir(root);
const matched = searchPaths.filter(file => files.includes(file));
if (matched.length === 0) {
Function dynamicVirtual
has a Cognitive Complexity of 14 (exceeds 5 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}`,
- 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 buildPurpletBot
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function buildPurpletBot(config: ResolvedConfig, spinner?: Spinner) {
const debug = new Logger('build', { debug: true });
config.adapter ??= gateway();
Function onPacket
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
private onPacket(packet: GatewayReceivePayload) {
if (packet.s) {
this.seq = packet.s;
}
Consider simplifying this complex logical expression. Open
if (currentEndpoint) {
const camelCasedName = (
currentEndpoint[1][0].toLowerCase() +
currentEndpoint[1].slice(1).replace(/\s+(\w)/g, (match, p1) => p1.toUpperCase())
)