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
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) {
- 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 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
};
- 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 initAsClient
has 163 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initAsClient(self, address, protocols, opts) {
var options = {
protocolVersion: protocolVersion,
perMessageDeflate: true
};
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) {
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;
- 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 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;
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) {
- 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 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 &&
- 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 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) {
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')
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);
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);
- 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
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
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 = {};
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';
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
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');
- 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 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');
Consider simplifying this complex logical expression. Open
if(!options.binary) {
options.binary = (
data instanceof ArrayBuffer ||
data instanceof Buffer ||
data instanceof Uint8Array ||