pristineio/wsd

View on GitHub

Showing 54 of 60 total issues

File WebSocket.js has 577 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';
//
// wsd
// Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
// MIT Licensed
Severity: Major
Found in lib/WebSocket.js - About 1 day to fix

    Function handleUpgrade has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
    Open

    WebSocketServer.prototype.handleUpgrade = function(req, socket, u, cb) {
      var upgradeHead = u;
      if(this.options.path) {
        u = url.parse(req.url);
        if(u && u.pathname !== this.options.path) {
    Severity: Minor
    Found in lib/WebSocketServer.js - About 7 hrs 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 initAsClient has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
    Open

    function initAsClient(self, address, protocols, opts) {
      var options = {
        protocolVersion: protocolVersion,
        perMessageDeflate: true
      };
    Severity: Minor
    Found in lib/WebSocket.js - About 6 hrs 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 initAsClient has 163 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function initAsClient(self, address, protocols, opts) {
      var options = {
        protocolVersion: protocolVersion,
        perMessageDeflate: true
      };
    Severity: Major
    Found in lib/WebSocket.js - About 6 hrs to fix

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

      WebSocketServer.prototype.handleUpgrade = function(req, socket, u, cb) {
        var upgradeHead = u;
        if(this.options.path) {
          u = url.parse(req.url);
          if(u && u.pathname !== this.options.path) {
      Severity: Major
      Found in lib/WebSocketServer.js - About 6 hrs to fix

        Function frameAndSend has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
        Open

        Sender.prototype.frameAndSend = function(opcode, data, f, m, c, cb) {
          var finalFragment = f;
          var maskData = m;
          var compressed = c;
          var canModifyData = false;
        Severity: Minor
        Found in lib/Sender.js - About 5 hrs 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 frameAndSend has 87 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Sender.prototype.frameAndSend = function(opcode, data, f, m, c, cb) {
          var finalFragment = f;
          var maskData = m;
          var compressed = c;
          var canModifyData = false;
        Severity: Major
        Found in lib/Sender.js - About 3 hrs to fix

          Function normalizeParams has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

          PerMessageDeflate.prototype.normalizeParams = function(paramsList) {
            return paramsList.map(function(params) {
              Object.keys(params).forEach(function(key) {
                var value = params[key];
                if(value.length > 1) {
          Severity: Minor
          Found in lib/PerMessageDeflate.js - About 3 hrs 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 acceptAsServer has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

          PerMessageDeflate.prototype.acceptAsServer = function(paramsList) {
            var accepted = {};
            var result = paramsList.some(function(params) {
              accepted = {};
              if(this.options.serverNoContextTakeover === false &&
          Severity: Minor
          Found in lib/PerMessageDeflate.js - About 3 hrs 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 finish has 81 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Handler.prototype.finish = function(mask, data) {
            var self = this;
            var packet = self.receiver.unmask(mask, data, true) || new Buffer(0);
            var state = clone(self.receiver.state);
            self.receiver.messageHandlers.push(function(callback) {
          Severity: Major
          Found in lib/Handler.js - About 3 hrs to fix

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

              var completeHybiUpgrade2 = function(protocol) {
                var originalKey = req.headers['sec-websocket-key'];
                var clientKey = originalKey;
                var key = crypto.createHash('sha1')
                  .update(originalKey + '258EAFA5-E914-47DA-95CA-C5AB0DC85B11')
            Severity: Major
            Found in lib/WebSocketServer.js - About 2 hrs to fix

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

              function establishConnection(self, ReceiverClass, SenderClass, socket, u) {
                var upgradeHead = u;
                var called = false;
              
                socket.setTimeout(0);
              Severity: Major
              Found in lib/WebSocket.js - About 2 hrs to fix

                Function processPacket has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                Receiver.prototype.processPacket = function(data) {
                  var datum = data[0];
                  if(this.extensions[PerMessageDeflate.extensionName]) {
                    if((datum & 0x30) !== 0) {
                      return this.error('reserved fields (2, 3) must be empty', 1002);
                Severity: Minor
                Found in lib/Receiver.js - About 2 hrs 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

                File WebSocketServer.js has 269 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                'use strict';
                //
                // wsd
                // Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
                // MIT Licensed
                Severity: Minor
                Found in lib/WebSocketServer.js - About 2 hrs to fix

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

                  WebSocket.prototype.send = function send(data, options, cb) {
                    var self = this;
                    if(typeof options === 'function') {
                      cb = options;
                      options = {};
                  Severity: Major
                  Found in lib/WebSocket.js - About 2 hrs to fix

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

                      PerMessageDeflate.prototype[method] = function(data, fin, callback) {
                        var self = this;
                        var buffers = [];
                        var endpoint = this.isServer ? 'client' : 'server';
                        var inflateOrDeflate = method === 'decompress' ? 'inflate' : 'deflate';
                    Severity: Major
                    Found in lib/PerMessageDeflate.js - About 2 hrs to fix

                      File Receiver.js has 261 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      'use strict';
                      //
                      // wsd
                      // Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
                      // MIT Licensed
                      Severity: Minor
                      Found in lib/Receiver.js - About 2 hrs to fix

                        Function WebSocketServer has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function WebSocketServer(options, callback) {
                          options.perMessageDeflate = true;
                        
                          if(!('port' in options) && !('server' in options) && !options.noServer) {
                            throw new TypeError('`port` or a `server` must be provided');
                        Severity: Minor
                        Found in lib/WebSocketServer.js - About 2 hrs 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 WebSocketServer has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function WebSocketServer(options, callback) {
                          options.perMessageDeflate = true;
                        
                          if(!('port' in options) && !('server' in options) && !options.noServer) {
                            throw new TypeError('`port` or a `server` must be provided');
                        Severity: Major
                        Found in lib/WebSocketServer.js - About 2 hrs to fix

                          Consider simplifying this complex logical expression.
                          Open

                            if(!options.binary) {
                              options.binary = (
                                data instanceof ArrayBuffer ||
                                data instanceof Buffer ||
                                data instanceof Uint8Array ||
                          Severity: Critical
                          Found in lib/WebSocket.js - About 2 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language