Showing 33 of 53 total issues
Function config
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
config(params: Partial<{
passivePort: number[],
throttle: number,
nickname: string,
chan: string[],
Function config
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
config(params: Partial<{
passivePort: number[],
throttle: number,
nickname: string,
chan: 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"
Further reading
Function checkParams
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
static checkParams(params: Partial<ParamsDL>):ParamsDL {
const testedParams = params;
testedParams.nickname = testedParams.nickname || 'xdccJS';
testedParams.path = Bridge.pathCheck(params.path);
File downloader.ts
has 269 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* eslint-disable max-len */
/* eslint-disable no-param-reassign */
import * as fs from 'fs';
import * as net from 'net';
import { PassThrough } from 'stream';
Function prepareDL
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
private prepareDL(downloadrequest: { fileInfo: FileInfo; candidate: Job }): void {
const { fileInfo } = downloadrequest;
const { candidate } = downloadrequest;
const stream = this.setupStream(fileInfo);
if (fileInfo.port === 0) {
Function postToDiscord
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
function postToDiscord():Promise<void> {
return new Promise((resolve, reject) => {
const discord = new Client({
intents: [GatewayIntentBits.Guilds],
});
Function downloadWith
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private downloadWith(opts: [Params, savedParams]): void {
if (!this.hasProfileAction()) {
if (!this.program.bot && !opts[1].bot) {
throw new BinError('%danger% Missing bot name, eg. %grey%--bot "XDCC|BOT"');
}
- 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 constructor
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(params: ParamsIRC) {
super();
this.nickname = params.nickname;
this.originalNickname = this.nickname;
this.nickRandomized = params.randomizeNick;
Function parseProgram
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private parseProgram(): void {
this.program
.storeOptionsAsProperties()
.name('xdccJS')
.version(version)
Function onError
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private onError(args: Pass, e: Error): void {
if (args.received === args.fileInfo.length) return;
if (e.message === 'cancel') this.emit('debug', 'xdccJS:: TCP_CANCEL');
else this.emit('debug', `xdccJS:: TCP_ERROR @ ${e.message}`);
Function xdccJSOPTS
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected xdccJSOPTS(): Params {
if (!this.program.host) {
if (this.program.saveProfile) throw new BinError('%danger% Saved profile must at least contain a host');
throw new BinError('%danger% a hostname is required, eg. %grey%--host irc.server.net');
}
Function passMessage
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private passMessage(job:Job) {
const listener = (event: MessageEventArgs) => {
if (typeof event.type === 'undefined') return;
const regexp = this.queue ? new RegExp(this.queue) : undefined;
const regex = regexp && regexp.test(event.message);
- 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 nickServAuth
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private nickServAuth():Promise<void> {
return new Promise((resolve, reject) => {
let error = '';
let timeout = setTimeout(() => {});
Function constructor
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(params: Params) {
// eslint-disable-next-line constructor-super
super();
this.irc = new Bridge(params);
this.listenCustomEvents();
Function processDL
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private processDL(
server: net.Server | undefined,
client: net.Socket,
stream: fs.WriteStream | PassThrough,
candidate: Job,
Function onError
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private onError(args: Pass, e: Error): void {
if (args.received === args.fileInfo.length) return;
if (e.message === 'cancel') this.emit('debug', 'xdccJS:: TCP_CANCEL');
else this.emit('debug', `xdccJS:: TCP_ERROR @ ${e.message}`);
- 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 downloadWith
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private downloadWith(opts: [Params, savedParams]): void {
if (!this.hasProfileAction()) {
if (!this.program.bot && !opts[1].bot) {
throw new BinError('%danger% Missing bot name, eg. %grey%--bot "XDCC|BOT"');
}
Function parameters
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected get parameters() {
const {
passivePort,
throttle,
nickname,
Function onNext
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected onNext(): void {
this.on('next', (candidate: Job, verbose:boolean) => {
this.emit('debug', 'xdccJS:: DOWNLOAD_NEXT');
if (candidate.queue.length) {
this.prepareCandidate(candidate);
Function xdccJSOPTS
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected xdccJSOPTS(): Params {
if (!this.program.host) {
if (this.program.saveProfile) throw new BinError('%danger% Saved profile must at least contain a host');
throw new BinError('%danger% a hostname is required, eg. %grey%--host irc.server.net');
}
- 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"