noodlefrenzy/node-amqp10

View on GitHub
lib/codec.js

Summary

Maintainability
D
1 day
Test Coverage

Function _encodeObject has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

Codec.prototype._encodeObject = function(value, buffer) {
  if (value instanceof DescribedType) {
    buffer.appendUInt8(0x00);

    // NOTE: Described type constructors are either ulongs or a symbol. Here
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 _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 _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 _encodeObject has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Codec.prototype._encodeObject = function(value, buffer) {
      if (value instanceof DescribedType) {
        buffer.appendUInt8(0x00);
    
        // NOTE: Described type constructors are either ulongs or a symbol. Here
    Severity: Minor
    Found in lib/codec.js - About 1 hr to fix

      Function encode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      Codec.prototype.encode = function(value, buffer, forceType) {
        // Special-case null values
        if (value === null) {
          return types.null.encode(value, buffer);
        }
      Severity: Minor
      Found in lib/codec.js - About 45 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

      Function _readOrPeekFixed has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      Codec.prototype._readOrPeekFixed = function(buf, offset, remaining, doNotConsume, numBytes) {
      Severity: Minor
      Found in lib/codec.js - About 35 mins to fix

        Avoid too many return statements within this function.
        Open

          if (value instanceof Array) return types.list.encode(value, buffer, this);
        Severity: Major
        Found in lib/codec.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

            if (value instanceof ForcedType) return this.encode(value.value, buffer, value.typeName);
          Severity: Major
          Found in lib/codec.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  if (remaining < 5) return false;
            Severity: Major
            Found in lib/codec.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    return this._readOrPeekFixed(buf, offset, remaining, doNotConsume, numBytes);
              Severity: Major
              Found in lib/codec.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return this._readOrPeekFixed(buf, offset, remaining, doNotConsume, numBytes);
                Severity: Major
                Found in lib/codec.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return encoder(value, buffer, this);
                  Severity: Major
                  Found in lib/codec.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                      return types.long.encode(value, buffer);
                    Severity: Major
                    Found in lib/codec.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                        return types.map.encode(value, buffer, this);
                      Severity: Major
                      Found in lib/codec.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                          if (value instanceof Date) return types.timestamp.encode(new Int64(value.getTime()), buffer, this);
                        Severity: Major
                        Found in lib/codec.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                              return value.encode(this, buffer);
                          Severity: Major
                          Found in lib/codec.js - About 30 mins to fix

                            Function _asMostSpecific has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                            Codec.prototype._asMostSpecific = function(buf, forcedCode) {
                              if (buf instanceof Array) {
                                // Described type
                                var descriptor = this._asMostSpecific(buf[0]);
                                var value = this._asMostSpecific(buf[1]);
                            Severity: Minor
                            Found in lib/codec.js - About 25 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

                            Function _encodeNumber has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                            Codec.prototype._encodeNumber = function(value, buffer) {
                              if (isNaN(value) || !isFinite(value)) {
                                throw new errors.EncodingError(value, 'value is not a finite number');
                              }
                            
                            
                            Severity: Minor
                            Found in lib/codec.js - About 25 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

                            There are no issues that match your filters.

                            Category
                            Status