pristineio/wsd

View on GitHub
lib/PerMessageDeflate.js

Summary

Maintainability
D
1 day
Test Coverage

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 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 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

    Function acceptAsServer has 48 lines of code (exceeds 25 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 1 hr to fix

      Function result has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        var result = paramsList.some(function(params) {
          accepted = {};
          if(this.options.serverNoContextTakeover === false &&
            params.server_no_context_takeover) {
            return;
      Severity: Minor
      Found in lib/PerMessageDeflate.js - About 1 hr to fix

        Function normalizeParams has 36 lines of code (exceeds 25 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 1 hr to fix

          Function acceptAsClient has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          PerMessageDeflate.prototype.acceptAsClient = function(paramsList) {
            var params = paramsList[0];
            if('clientNoContextTakeover' in this.options) {
              if(this.options.clientNoContextTakeover === false &&
                params.client_no_context_takeover) {
          Severity: Minor
          Found in lib/PerMessageDeflate.js - About 55 mins 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

          Avoid too many return statements within this function.
          Open

              return true;
          Severity: Major
          Found in lib/PerMessageDeflate.js - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status