noodlefrenzy/node-amqp10

View on GitHub
lib/connection.js

Summary

Maintainability
F
3 days
Test Coverage

Function Connection has 144 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function Connection(connectPolicy) {
  Connection.super_.call(this);

  var options = connectPolicy.options;
  u.assertArguments(options, ['containerId', 'hostname']);
Severity: Major
Found in lib/connection.js - About 5 hrs to fix

    File connection.js has 365 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    var EventEmitter = require('events').EventEmitter,
        fs = require('fs'),
        util = require('util'),
    
    
    Severity: Minor
    Found in lib/connection.js - About 4 hrs to fix

      Function _receiveAny has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      Connection.prototype._receiveAny = function() {
        var frame = null;
        while (true) {
          if (this.sasl && !this.sasl.receivedHeader) {
            if (!this._tryReceiveHeader(constants.saslVersion)) break;
      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 _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 _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 Connection has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        function Connection(connectPolicy) {
          Connection.super_.call(this);
        
          var options = connectPolicy.options;
          u.assertArguments(options, ['containerId', 'hostname']);
        Severity: Minor
        Found in lib/connection.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 _tryReceiveHeader has 27 lines of code (exceeds 25 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 1 hr to fix

          Function _receiveAny has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Connection.prototype._receiveAny = function() {
            var frame = null;
            while (true) {
              if (this.sasl && !this.sasl.receivedHeader) {
                if (!this._tryReceiveHeader(constants.saslVersion)) break;
          Severity: Minor
          Found in lib/connection.js - About 1 hr to fix

            Function _processOpenFrame has a Cognitive Complexity of 9 (exceeds 5 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 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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              if (this.remote.open.outgoingLocales) {
                valid = valid &&
                  this._ensureLocaleCompatibility(this.local.open.incomingLocales, this.remote.open.outgoingLocales);
              }
            Severity: Major
            Found in lib/connection.js and 1 other location - About 1 hr to fix
            lib/connection.js on lines 452..455

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 63.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              if (this.remote.open.incomingLocales) {
                valid = valid &&
                  this._ensureLocaleCompatibility(this.local.open.outgoingLocales, this.remote.open.incomingLocales);
              }
            Severity: Major
            Found in lib/connection.js and 1 other location - About 1 hr to fix
            lib/connection.js on lines 448..451

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 63.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                if (options.sslOptions.caFile) {
                  this._sslOptions.ca = fs.readFileSync(options.sslOptions.caFile);
                  delete this._sslOptions.caFile;
                }
            Severity: Major
            Found in lib/connection.js and 2 other locations - About 1 hr to fix
            lib/connection.js on lines 162..165
            lib/connection.js on lines 166..169

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 59.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                if (options.sslOptions.certFile) {
                  this._sslOptions.cert = fs.readFileSync(options.sslOptions.certFile);
                  delete this._sslOptions.certFile;
                }
            Severity: Major
            Found in lib/connection.js and 2 other locations - About 1 hr to fix
            lib/connection.js on lines 162..165
            lib/connection.js on lines 170..173

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 59.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                if (options.sslOptions.keyFile) {
                  this._sslOptions.key = fs.readFileSync(options.sslOptions.keyFile);
                  delete this._sslOptions.keyFile;
                }
            Severity: Major
            Found in lib/connection.js and 2 other locations - About 1 hr to fix
            lib/connection.js on lines 166..169
            lib/connection.js on lines 170..173

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 59.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                'HDR_SENT': {
                  validVersion: function() {
                    return this.HDR_EXCH;
                  },
                  invalidVersion: function() {
            Severity: Minor
            Found in lib/connection.js and 1 other location - About 45 mins to fix
            lib/connection.js on lines 240..248

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 50.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                'HDR_EXCH': {
                  sendOpen: function() {
                    self._sendOpenFrame();
                    return this.OPEN_SENT;
                  },
            Severity: Minor
            Found in lib/connection.js and 1 other location - About 45 mins to fix
            lib/connection.js on lines 269..275

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 50.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                'OPEN_SENT': {
                  openReceived: function() {
                    return this.OPENED;
                  },
                  sendClose: function() {
            Severity: Minor
            Found in lib/connection.js and 1 other location - About 45 mins to fix
            lib/connection.js on lines 216..224

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 50.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                'CLOSE_SENT': {
                  closeReceived: function() {
                    self._terminate();
                    return this.DISCONNECTED;
                  },
            Severity: Minor
            Found in lib/connection.js and 1 other location - About 45 mins to fix
            lib/connection.js on lines 225..233

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 50.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            There are no issues that match your filters.

            Category
            Status