Showing 129 of 129 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
async showMessage(message: CreateInteractionMessageData) {
const { message: data, files } = resolveCreateInteractionMessageData(message);
await this.respond({
type: InteractionResponseType.ChannelMessageWithSource,
data,
- 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 88.
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
async updateMessage(message: CreateInteractionMessageData) {
const { message: data, files } = resolveCreateInteractionMessageData(message);
await this.respond({
type: InteractionResponseType.UpdateMessage,
data,
- 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 88.
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 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>) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
async deferMessage(options?: DeferMessageOptions) {
// Note: ephemeral is the only thing we can use (well so can suppress embeds, but can't we set those when we edit?)
await this.respond({
type: InteractionResponseType.DeferredChannelMessageWithSource,
data: {
- 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 83.
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
async deferUpdateMessage(options?: DeferMessageOptions) {
// Note: ephemeral is the only thing we can use (well so can suppress embeds, but can't we set those when we edit?)
await this.respond({
type: InteractionResponseType.DeferredMessageUpdate,
data: {
- 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 83.
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 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)}>
Similar blocks of code found in 2 locations. Consider refactoring. Open
cmd.options = merged.map(x => ({
name: x.name.split(' ')[1],
type: ApplicationCommandOptionType.Subcommand,
description: x.description,
name_localizations: x.name_localizations,
- 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 81.
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
options: merged
.filter(y => y.name.startsWith(name + ' ' + x.name.split(' ')[1] + ' '))
.map(y => ({
name: y.name.split(' ')[2],
type: ApplicationCommandOptionType.Subcommand,
- 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 81.
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 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;
}