dcharbonnier/hydrated-ws

View on GitHub

Showing 4 of 13 total issues

Function addWebSocket has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public addWebSocket(ws: WebSocket): () => void {

        const cablePipe = new Pipe(ws, "WOHC");
        const cable = new Cable(cablePipe);
        const dataPipe = new Pipe(ws, "WOHD");
Severity: Major
Found in src/wormhole/Server.ts - About 3 hrs to fix

    Function checkSubscriptions has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        private checkSubscriptions() {
            if (this.onmessage || (this.listeners.has("message") && this.listeners.get("message").length)) {
                if (!this.subscribed) {
                    this.subscribed = true;
                    if (this.onMessageSubscribe) {
    Severity: Minor
    Found in src/router/RoutedWebSocket.ts - About 1 hr to fix

    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

                    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 });
    Severity: Minor
    Found in src/wormhole/Server.ts - About 1 hr to fix

      Function get has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      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)) {
      Severity: Minor
      Found in src/router/Router.ts - About 35 mins to fix

      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

      Severity
      Category
      Status
      Source
      Language