File socket.ts
has 299 lines of code (exceeds 250 allowed). Consider refactoring. Open
import net from "net";
import { TextEncoder } from "util";
import {
IBApiCreationOptions,
Socket
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
export class Socket {
/**
* Create a new [[Socket]] object.
*
* @param controller The parent [[Controller]] object.
Function onData
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private onData(data: Buffer): void {
if (this.useV100Plus) {
let dataToParse = data;
if (this._v100MessageBuffer.length > 0) {
dataToParse = Buffer.concat([this._v100MessageBuffer, data]);
- 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 onData
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private onData(data: Buffer): void {
if (this.useV100Plus) {
let dataToParse = data;
if (this._v100MessageBuffer.length > 0) {
dataToParse = Buffer.concat([this._v100MessageBuffer, data]);
Function onServerVersion
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private onServerVersion(tokens: string[]): void {
this._status = ConnectionStatus.Connected;
this._serverVersion = parseInt(tokens[0], 10);
this._serverConnectionTime = tokens[1];
Function send
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
send(tokens: unknown[]): void {
// flatten arrays and convert boolean types to 0/1
tokens = this.flattenDeep(tokens);
tokens.forEach((value, i) => {
Function onMessage
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private onMessage(data: string): void {
// tokenize
const dataWithFragment = this.dataFragment + data;
- 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 startAPI
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private startAPI(): void {
// start API
const VERSION = 2;
if (this.serverVersion >= 3) {
- 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 send
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
send(tokens: unknown[]): void {
// flatten arrays and convert boolean types to 0/1
tokens = this.flattenDeep(tokens);
tokens.forEach((value, i) => {
- 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"