LearnBoost/socket.io

View on GitHub

Showing 58 of 158 total issues

Function parseBinary has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  parseBinary (obj) {
    let view = new Uint8Array(obj);
    let packetId = view[0];
    try {
      let packet = {
Severity: Minor
Found in examples/custom-parsers/src/custom-parser.js - About 1 hr to fix

    Function constructor has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      constructor() {
        this.socket = io(environment.serverUrl);
    
        this.socket.on("connect", () => {
          this.socket.emit("todo:list", (res) => {
    Severity: Minor
    Found in examples/basic-crud-application/angular-client/src/app/store.ts - About 1 hr to fix

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

            value: function emit(ev) {
              if (RESERVED_EVENTS.hasOwnProperty(ev)) {
                throw new Error('"' + ev + '" is a reserved event name');
              }
      
      
      Severity: Minor
      Found in client-dist/socket.io.js - About 1 hr to fix

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

          public of(
            name: string | RegExp | ParentNspNameMatchFn,
            fn?: (
              socket: Socket<ListenEvents, EmitEvents, ServerSideEvents, SocketData>
            ) => void
        Severity: Minor
        Found in lib/index.ts - About 1 hr to fix

          Function sendFile has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            private static sendFile(
              filename: string,
              req: http.IncomingMessage,
              res: http.ServerResponse
            ): void {
          Severity: Minor
          Found in lib/index.ts - About 1 hr to fix

            Function _add has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              _add(
                client: Client<ListenEvents, EmitEvents, ServerSideEvents>,
                query,
                fn?: () => void
              ): Socket<ListenEvents, EmitEvents, ServerSideEvents, SocketData> {
            Severity: Minor
            Found in lib/namespace.ts - About 1 hr to fix

              Function connect has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private connect(name: string, auth: object = {}): void {
                  if (this.server._nsps.has(name)) {
                    debug("connecting to namespace %s", name);
                    return this.doConnect(name, auth);
                  }
              Severity: Minor
              Found in lib/client.ts - About 1 hr to fix

                Function decode has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  var decode$1 = function decode(base64) {
                    var bufferLength = base64.length * 0.75,
                        len = base64.length,
                        i,
                        p = 0,
                Severity: Minor
                Found in client-dist/socket.io.js - About 1 hr to fix

                  Function drawLine has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    function drawLine(x0, y0, x1, y1, color, emit){
                  Severity: Minor
                  Found in examples/whiteboard/public/main.js - About 45 mins to fix

                    Function offAny has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                      public offAny(listener?: (...args: any[]) => void): this {
                        if (!this._anyListeners) {
                          return this;
                        }
                        if (listener) {
                    Severity: Minor
                    Found in lib/socket.ts - About 45 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

                    Function ondecoded has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                      private ondecoded(packet: Packet): void {
                        if (PacketType.CONNECT === packet.type) {
                          if (this.conn.protocol === 3) {
                            const parsed = url.parse(packet.nsp, true);
                            this.connect(parsed.pathname!, parsed.query);
                    Severity: Minor
                    Found in lib/client.ts - About 45 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

                    Avoid too many return statements within this function.
                    Open

                        return data;
                    Severity: Major
                    Found in client-dist/socket.io.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return false;
                      Severity: Major
                      Found in client-dist/socket.io.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                            return callback(PACKET_TYPES[type] + (data || ""));
                        Severity: Major
                        Found in client-dist/socket.io.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return true;
                          Severity: Major
                          Found in client-dist/socket.io.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                  return false;
                            Severity: Major
                            Found in client-dist/socket.io.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                    return hasBinary(obj.toJSON(), true);
                              Severity: Major
                              Found in client-dist/socket.io.js - About 30 mins to fix

                                Function onevent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  private onevent(packet: Packet): void {
                                    const args = packet.data || [];
                                    debug("emitting event %j", args);
                                
                                    if (null != packet.id) {
                                Severity: Minor
                                Found in lib/socket.ts - About 25 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