noodlefrenzy/node-amqp10

View on GitHub

Showing 105 of 189 total issues

Function readFrame has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

frames.readFrame = function(buffer, options) {
  options = options || { verbose: true };
  if (buffer.length < 8) return undefined;

  var sizeAndDoff = buffer.slice(0, 8);
Severity: Minor
Found in lib/frames.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

Function defineComposite has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function defineComposite(Base, definition) {
  if (definition === undefined) {
    definition = Base;
    Base = Object;
  }
Severity: Major
Found in lib/types/composite_type.js - About 2 hrs to fix

    Function readFrame has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    frames.readFrame = function(buffer, options) {
      options = options || { verbose: true };
      if (buffer.length < 8) return undefined;
    
      var sizeAndDoff = buffer.slice(0, 8);
    Severity: Major
    Found in lib/frames.js - About 2 hrs to fix

      Function _processFrame has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      Sasl.prototype._processFrame = function(frame) {
        var self = this;
        if (frame instanceof frames.SaslMechanismsFrame) {
          var mechanism = this.mechanism;
          var mechanisms = Array.isArray(frame.saslServerMechanisms) ?
      Severity: Minor
      Found in lib/sasl/sasl.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

      Function _readFullValue has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      Codec.prototype._readFullValue = function(buf, offset, doNotConsume, forcedCode) {
        offset = offset || 0;
        var remaining = buf.length - offset;
        if (remaining < 1) return undefined;
      
      
      Severity: Minor
      Found in lib/codec.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

      Function _tryReceiveHeader has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      Connection.prototype._tryReceiveHeader = function(header) {
        header = header || constants.amqpVersion;
        if (this._buffer.length >= header.length) {
          var serverVersion = this._buffer.slice(0, 8);
          this._buffer.consume(8);
      Severity: Minor
      Found in lib/connection.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

      Function _processFrame has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Sasl.prototype._processFrame = function(frame) {
        var self = this;
        if (frame instanceof frames.SaslMechanismsFrame) {
          var mechanism = this.mechanism;
          var mechanisms = Array.isArray(frame.saslServerMechanisms) ?
      Severity: Minor
      Found in lib/sasl/sasl.js - About 1 hr to fix

        Function _sendMessage has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        SenderLink.prototype._sendMessage = function(message, options) {
          // preconditions
          if (this.linkCredit <= 0) {
            throw new errors.OverCapacityError('Cannot send if no link credit.');
          }
        Severity: Minor
        Found in lib/sender_link.js - About 1 hr to fix

          Function _readFullValue has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Codec.prototype._readFullValue = function(buf, offset, doNotConsume, forcedCode) {
            offset = offset || 0;
            var remaining = buf.length - offset;
            if (remaining < 1) return undefined;
          
          
          Severity: Minor
          Found in lib/codec.js - About 1 hr to fix

            Function arrayBuilder has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function arrayBuilder(val, bufb, codec, width) {
              if (!(val instanceof AMQPArray)) {
                throw new errors.EncodingError(val, 'Unsure how to encode non-amqp array as array');
              }
            
            
            Severity: Minor
            Found in lib/types.js - About 1 hr to fix

              Function stateMachine has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              var stateMachine = function(session) {
                function warnBeginState(state) {
                  console.warn('BUG: Tried to call begin() on a session in nonterminal state ' + state);
                }
              
              
              Severity: Minor
              Found in lib/session.js - About 1 hr to fix

                Function bufferEqualsLegacy has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                function bufferEqualsLegacy(lhs, rhs, offset1, offset2, size) {
                  if (offset1 === undefined && offset2 === undefined && size === undefined) {
                    if (lhs.length !== rhs.length) return false;
                  }
                  var slice1 = (offset1 === undefined && size === undefined) ? lhs : lhs.slice(offset1 || 0, size || lhs.length);
                Severity: Minor
                Found in lib/utilities.js - About 1 hr 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 _sendMessage has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                SenderLink.prototype._sendMessage = function(message, options) {
                  // preconditions
                  if (this.linkCredit <= 0) {
                    throw new errors.OverCapacityError('Cannot send if no link credit.');
                  }
                Severity: Minor
                Found in lib/sender_link.js - About 1 hr 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 writeFrame has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                frames.writeFrame = function(frame, stream, options, callback) {
                  if (!(frame instanceof frames.Frame)) {
                    throw new errors.EncodingError(frame, 'unknown frame type');
                  }
                
                
                Severity: Minor
                Found in lib/frames.js - About 1 hr 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 translate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                function translate(input) {
                  if (!Array.isArray(input)) {  // raw value
                    return input;
                  }
                
                
                Severity: Minor
                Found in lib/adapters/translate_encoder.js - About 1 hr 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 createReceiver has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                AMQPClient.prototype.createReceiver = function(address, policyOverrides, session) {
                  if (!this._connection) {
                    throw new Error('Must connect before creating links');
                  }
                
                
                Severity: Minor
                Found in lib/amqp_client.js - About 1 hr to fix

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

                  function deepMerge() {
                    var args = Array.prototype.slice.call(arguments);
                    var helper = function(tgt, src, key) {
                      var s2, t2;
                      if (key === undefined) {
                  Severity: Minor
                  Found in lib/utilities.js - About 1 hr to fix

                    Function _processOpenFrame has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    Connection.prototype._processOpenFrame = function(frame) {
                      this.connSM.openReceived();
                      if (this.connSM.getMachineState() === 'OPEN_RCVD') {
                        this.connSM.sendOpen();
                      }
                    Severity: Minor
                    Found in lib/connection.js - About 1 hr to fix

                      Function mapBuilder has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function mapBuilder(map, bufb, codec, width) {
                        if (typeof map !== 'object') {
                          throw new errors.EncodingError(map, 'Unsure how to encode non-object as map');
                        }
                      
                      
                      Severity: Minor
                      Found in lib/types.js - About 1 hr 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 listBuilder has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function listBuilder(list, bufb, codec, width) {
                        if (!Array.isArray(list)) {
                          throw new errors.EncodingError(list, 'Unsure how to encode non-array as list');
                        }
                      
                      
                      Severity: Minor
                      Found in lib/types.js - About 1 hr 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

                      Severity
                      Category
                      Status
                      Source
                      Language