packages/gateway/src/Gateway.ts
Function onPacket
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private onPacket(packet: GatewayReceivePayload) {
if (packet.s) {
this.seq = packet.s;
}
Function onClose
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private onClose({ code }: CloseEvent) {
if (code === 1000) {
return;
}
Function onRawPacket
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
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 onRawPacket
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Open
private sendIdentify() {
if (this.sessionId) {
debug('sending resume, seq=%s', this.seq);
this.send({
op: GatewayOpcodes.Resume,
Function onPacket
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
private onPacket(packet: GatewayReceivePayload) {
if (packet.s) {
this.seq = packet.s;
}
- 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
Consider simplifying this complex logical expression. Open
Open
if (this.inflate) {
const l = buf.length;
// TODO: use a single equals check instead of four separate ones.
const flush =
l >= 4 &&
Avoid too many return
statements within this function. Open
Open
return;
Avoid too many return
statements within this function. Open
Open
return;
Avoid too many return
statements within this function. Open
Open
return;