CRBT-Team/Purplet

View on GitHub
packages/gateway/src/Gateway.ts

Summary

Maintainability
C
1 day
Test Coverage

Function onPacket has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  private onPacket(packet: GatewayReceivePayload) {
    if (packet.s) {
      this.seq = packet.s;
    }

Severity: Minor
Found in packages/gateway/src/Gateway.ts - About 1 hr to fix

    Function onClose has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private onClose({ code }: CloseEvent) {
        if (code === 1000) {
          return;
        }
    
    
    Severity: Minor
    Found in packages/gateway/src/Gateway.ts - About 1 hr to fix

      Function onRawPacket has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      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.
      Severity: Minor
      Found in packages/gateway/src/Gateway.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 onRawPacket has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      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.
      Severity: Minor
      Found in packages/gateway/src/Gateway.ts - About 1 hr to fix

        Function sendIdentify has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private sendIdentify() {
            if (this.sessionId) {
              debug('sending resume, seq=%s', this.seq);
              this.send({
                op: GatewayOpcodes.Resume,
        Severity: Minor
        Found in packages/gateway/src/Gateway.ts - About 1 hr to fix

          Function onPacket has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            private onPacket(packet: GatewayReceivePayload) {
              if (packet.s) {
                this.seq = packet.s;
              }
          
          
          Severity: Minor
          Found in packages/gateway/src/Gateway.ts - About 55 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

          Consider simplifying this complex logical expression.
          Open

              if (this.inflate) {
                const l = buf.length;
                // TODO: use a single equals check instead of four separate ones.
                const flush =
                  l >= 4 &&
          Severity: Major
          Found in packages/gateway/src/Gateway.ts - About 40 mins to fix

            Avoid too many return statements within this function.
            Open

                    return;
            Severity: Major
            Found in packages/gateway/src/Gateway.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return;
              Severity: Major
              Found in packages/gateway/src/Gateway.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return;
                Severity: Major
                Found in packages/gateway/src/Gateway.ts - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status