Showing 46 of 122 total issues
Function constrain
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
constrain(constr) {
// TODO -> Validate this function, so weird values do not destroy.
const check = function(parameter, restr, maxDefault) {
let value;
if (parameter && restr) {
- 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 resTCP
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
async resTCP(res) {
if (res.statusCode != 200) {
this.emit('error', new Error(res));
this.close();
} else {
- 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 constructor
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(store) {
super();
/**
* @param {Collection} store - Session storage
*/
Function fromOptions
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
fromOptions(opt) {
if (opt) {
this.negotiationPingUp = opt.negotiationPingUp ?
opt.negotiationPingUp : defaults.negotiationPingUp;
this.negotiationPingDown = opt.negotiationPingDown ?
- 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 resTCP
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
async resTCP(res) {
if (res.statusCode != 200) {
this.emit('error', new Error(res));
this.close();
} else {
Function reqTCPHandler
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
async reqTCPHandler(req) {
if (this.state === HANDSHAKE_DONE &&
req.method === 'READY' &&
req.headers.Stage === '0') {
this.pinger = Pinger.genServer(this.session.id,
Function constructor
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor() {
super();
/**
* The handshake socket.
* @member {net.Socket}
Function fromClientOps
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async fromClientOps(options) {
let latency = 0;
let jitterUp = 0;
let jitterDown = 0;
let bandwidthUp = 0;
Function fromClientOps
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
static async fromClientOps(options) {
let latency = 0;
let jitterUp = 0;
let jitterDown = 0;
let bandwidthUp = 0;
- 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 measure
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
measure() {
return new Promise((resolve, reject) => {
this.rejectCallback = reject;
this.endFunc = () => {
console.log('Calling end func');
Function updateFromSDP
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
updateFromSDP(sdp) {
const lines = sdp.split('\r\n');
lines.forEach((line) => {
if (line.indexOf('a=public-address:client') === 0) {
const type = parseInt(line.substring(24, 26));
Consider simplifying this complex logical expression. Open
if (this.negotiationPingUp && this.negotiationPingDown &&
this.continuityPingUp && this.continuityPingDown &&
this.negotiationBandwidth && this.windowSizeUp &&
this.windowSizeDown && this.windowSizePctLssUp &&
this.windowSizePctLssDown) {
Function updateWithSDP
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
updateWithSDP(sdp) {
const lines = sdp.split('\r\n');
lines.forEach((line) => {
if (line.indexOf('a=latency:') === 0) {
const res = parseInt(line.substring(10), 10);
Function measure
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
measure() {
return new Promise((resolve, reject) => {
this.endFunc = () => {
this.timeoutId = undefined;
this.sequence = 0;
Function constrain
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
constrain(constr) {
// TODO -> Validate this function, so weird values do not destroy.
const check = function(parameter, restr, maxDefault) {
let value;
if (parameter && restr) {
Function doesMetQuality
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
doesMetQuality(measurement) {
if (typeof this.latency !== 'undefined'&&
typeof measurement.latency !== 'undefined' &&
measurement.latency > this.latency) {
return false;
Function portToSDP
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
portToSDP() {
let sdp = '';
if (this.appClientPorts.TCP) {
sdp = sdp + 'a=flow:app clientListeningPort TCP/' +
this.appClientPorts.TCP + '\r\n';
Function extractFromPinger
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
extractFromPinger(times) {
return new Promise( (resolve, reject) => {
let latencies = [];
let lost = 0;
let i = times.length-1;
Function validate
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
validate() { // TODO: Improve this comprobation when you have the class clear
if (!this.q4sVersion) {
throw new Error('Missing an argument in the start line');
}
if (!METHODS.includes(this.method)) {
- 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 handshakeHandler
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
handshakeHandler(res) {
if (this.state == SENT_HANDSHAKE) {
if (res.statusCode != 200) {
this.emit('error', new Error(res.reasonPhrase));
console.log('recieved', res);