pristineio/wsd

View on GitHub
lib/Receiver.js

Summary

Maintainability
C
1 day
Test Coverage

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);
Severity: Minor
Found in lib/Receiver.js - About 2 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

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
Severity: Minor
Found in lib/Receiver.js - About 2 hrs to fix

    Function processPacket has 50 lines of code (exceeds 25 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);
    Severity: Minor
    Found in lib/Receiver.js - About 2 hrs to fix

      Function Receiver has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function Receiver(extensions) {
        var self = this;
      
        ['fragmentedBufferPool', 'unfragmentedBufferPool'].forEach(function(x) {
          var prevUsed = -1;
      Severity: Minor
      Found in lib/Receiver.js - About 1 hr to fix

        Avoid too many return statements within this function.
        Open

              return this.error(
                'control frames cannot have the Per-message Compressed bits', 1002
              );
        Severity: Major
        Found in lib/Receiver.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return this.error('no handler for opcode ' + this.state.opcode, 1002);
          Severity: Major
          Found in lib/Receiver.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return this.error(
                    'data frames after the initial data frame must have opcode 0', 1002
                  );
            Severity: Major
            Found in lib/Receiver.js - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status