RackHD/on-core

View on GitHub
lib/common/messenger.js

Summary

Maintainability
D
3 days
Test Coverage

Function messengerFactory has 239 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function messengerFactory(
    Constants,
    Promise,
    assert,
    Connection,
Severity: Major
Found in lib/common/messenger.js - About 1 day to fix

    Function messengerFactory has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    function messengerFactory(
        Constants,
        Promise,
        assert,
        Connection,
    Severity: Minor
    Found in lib/common/messenger.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

    File messenger.js has 275 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // Copyright 2015, EMC, Inc.
    
    'use strict';
    
    module.exports = messengerFactory;
    Severity: Minor
    Found in lib/common/messenger.js - About 2 hrs to fix

      Function messengerFactory has 14 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          Constants,
          Promise,
          assert,
          Connection,
          Message,
      Severity: Major
      Found in lib/common/messenger.js - About 1 hr to fix

        Function start has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            Messenger.prototype.start = function () {
                var self = this,
                    configuration = injector.get('Services.Configuration'),
                    uri = configuration.get('amqp', 'amqp://localhost');
        
        
        Severity: Minor
        Found in lib/common/messenger.js - About 1 hr to fix

          Function subscribe has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              Messenger.prototype.subscribe = function (name, routingKey, callback, type) {
                  assert.string(name, 'name');
                  assert.string(routingKey, 'routingKey');
                  assert.func(callback, 'callback');
          
          
          Severity: Minor
          Found in lib/common/messenger.js - About 1 hr to fix

            Function request has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                Messenger.prototype.request = function (name, routingKey, data, type, timeout) {
                    assert.string(name, 'name');
                    assert.string(routingKey, 'routingKey');
                    assert.object(data, 'data');
            
            
            Severity: Minor
            Found in lib/common/messenger.js - About 1 hr to fix

              Function subscribeTimeout has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  Messenger.prototype.subscribeTimeout = function(context, data, headers, deliveryInfo) {
                      clearTimeout(context.timeout);
              
                      this.safeSubscriptionDispose(context);
              
              
              Severity: Minor
              Found in lib/common/messenger.js - About 1 hr to fix

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

                    Messenger.prototype.request = function (name, routingKey, data, type, timeout) {
                Severity: Minor
                Found in lib/common/messenger.js - About 35 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status