src/bin/commander.ts
Function parseProgram
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private parseProgram(): void {
this.program
.storeOptionsAsProperties()
.name('xdccJS')
.version(version)
Function xdccJSOPTS
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
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 xdccJSOPTS
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
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"
Further reading
Function parseIfNotInt
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
private static parseIfNotInt(numstring: string, optName:'port' | 'throttle' | 'passive-port' | 'retry' | 'wait' | 'timeout'): number {
const cannotBeLessThanZero = (optName === 'retry' || optName === 'throttle' || optName === 'wait' || optName === 'timeout');
const notAnumber = Number.isNaN(parseInt(numstring, 10)) || Number.isNaN(parseFloat(numstring));
if (notAnumber) throw new BinError(`%danger% option --${optName} must be a number`);
- 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 too many return
statements within this function. Open
Open
return false;