lib/WebSocketServer.js
Function handleUpgrade
has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring. Open
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 handleUpgrade
has 152 lines of code (exceeds 25 allowed). Consider refactoring. Open
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 completeHybiUpgrade2
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
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')
File WebSocketServer.js
has 269 lines of code (exceeds 250 allowed). Consider refactoring. Open
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
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
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');
Avoid too many return
statements within this function. Open
Open
return abortConnection(socket, 401);
Avoid too many return
statements within this function. Open
Open
return this.options.verifyClient(info, function(result, code) {
if(!code) {
code = 401;
}
if(!result) {