lib/Receiver.js
Function processPacket
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
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 Receiver.js
has 261 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 processPacket
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
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);
Function Receiver
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function Receiver(extensions) {
var self = this;
['fragmentedBufferPool', 'unfragmentedBufferPool'].forEach(function(x) {
var prevUsed = -1;
Avoid too many return
statements within this function. Open
Open
return this.error(
'control frames cannot have the Per-message Compressed bits', 1002
);
Avoid too many return
statements within this function. Open
Open
return this.error('no handler for opcode ' + this.state.opcode, 1002);
Avoid too many return
statements within this function. Open
Open
return this.error(
'data frames after the initial data frame must have opcode 0', 1002
);