Showing 4 of 13 total issues
Function addWebSocket
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public addWebSocket(ws: WebSocket): () => void {
const cablePipe = new Pipe(ws, "WOHC");
const cable = new Cable(cablePipe);
const dataPipe = new Pipe(ws, "WOHD");
Function checkSubscriptions
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
private checkSubscriptions() {
if (this.onmessage || (this.listeners.has("message") && this.listeners.get("message").length)) {
if (!this.subscribed) {
this.subscribed = true;
if (this.onMessageSubscribe) {
- 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 connect
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const connect = () => {
if (!this.clients.has(uuid)) {
const routedCablePipe = new Pipe(targetWs, "WOHC");
const routedDataPipe = new Pipe(targetWs, "WOHD");
this.clients.set(uuid, { data: routedDataPipe, cable: routedCablePipe });
Function get
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
public get(id: string): WebSocket {
if (!this.virtualWebSockets.has(id)) {
const routedWs = this.createRoutedWebsocket(id);
this.virtualWebSockets.set(id, routedWs);
if (this.localWebSockets.has(id)) {
- 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"