resilient-http/resilient.js

View on GitHub

Showing 48 of 305 total issues

Function 9 has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

},{"./client":2,"./defaults":3,"./http":7,"./options":10,"./resilient":12}],9:[function(require,module,exports){
var _ = require('./utils')
var midware = require('midware')

var hooks = ['in', 'out']
Severity: Major
Found in resilient.js - About 2 hrs to fix

    Function 17 has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    },{}],17:[function(require,module,exports){
    var balancerOptions = require('./defaults').balancer
    
    module.exports = Server
    
    
    Severity: Major
    Found in resilient.js - About 2 hrs to fix

      Function ServersDiscovery has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function ServersDiscovery (resilient, options, servers) {
        var requester = Requester(resilient)
        var middleware = resilient._middleware
      
        function getOptions () {
      Severity: Major
      Found in resilient.js - About 2 hrs to fix

        Function ServersDiscovery has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function ServersDiscovery (resilient, options, servers) {
          var requester = Requester(resilient)
          var middleware = resilient._middleware
        
          function getOptions () {
        Severity: Major
        Found in lib/discovery.js - About 2 hrs to fix

          Function midware has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function midware(ctx) {
              var calls = use.stack = []
              ctx = ctx || null
                 
              function use() {
          Severity: Minor
          Found in resilient.js - About 2 hrs to fix

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

            module.exports = function(config) {
              var customLaunchers = {
                sl_chrome: {
                  base: 'SauceLabs',
                  browserName: 'chrome',
            Severity: Minor
            Found in karma.conf.js - About 1 hr to fix

              Function ServiceResolve has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              function ServiceResolve (resilient) {
                var middleware = resilient._middleware
                var options = resilient.options('discovery')
              
                function isCacheEnabled () {
              Severity: Minor
              Found in lib/resolvers/service.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 14 has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              },{"./discovery":4,"./error":5,"./requester":11,"./resolvers/discovery":14,"./servers":18,"./utils":20}],14:[function(require,module,exports){
              var ResilientError = require('../error')
              var Requester = require('../requester')
              var ServersDiscovery = require('../discovery')
              var ServiceResolve = require('./service')
              Severity: Minor
              Found in resilient.js - About 1 hr to fix

                Function 19 has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                },{"./roundrobin":16,"./server":17,"./utils":20}],19:[function(require,module,exports){
                var isArr = require('./utils').isArr
                
                module.exports = Sync
                
                
                Severity: Minor
                Found in resilient.js - About 1 hr to fix

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

                  function roundRobin (n, ps) {
                    var k
                    var j
                    var i
                    var rs = [] // rs = round array
                  Severity: Minor
                  Found in lib/roundrobin.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 16 has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  },{"../error":5,"../utils":20}],16:[function(require,module,exports){
                  module.exports = roundRobinSerie
                  
                  function roundRobinSerie (arr, size) {
                    var max = +size < 2 ? 2 : size
                  Severity: Minor
                  Found in resilient.js - About 1 hr to fix

                    Function 1 has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.resilient = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
                    var _ = require('./utils')
                    
                    module.exports = Cache
                    
                    
                    Severity: Minor
                    Found in resilient.js - About 1 hr to fix

                      Function 5 has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      },{"./error":5,"./requester":11,"./servers":18,"./utils":20}],5:[function(require,module,exports){
                      module.exports = ResilientError
                      
                      var MESSAGES = {
                        1000: 'All requests failed. No servers available',
                      Severity: Minor
                      Found in resilient.js - About 1 hr to fix

                        Function omit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                        exports.omit = function (obj, keys) {
                          var key = null
                          var buf = {}
                          if (_.isObj(obj)) {
                            for (key in obj) if (hasOwn.call(obj, key)) {
                        Severity: Minor
                        Found in lib/utils.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 ServersDiscovery has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function ServersDiscovery (resilient, options, servers) {
                          var requester = Requester(resilient)
                          var middleware = resilient._middleware
                        
                          function getOptions () {
                        Severity: Minor
                        Found in lib/discovery.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

                        Function ResilientError has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function ResilientError (status, error) {
                          if (error instanceof Error) {
                            Error.call(this)
                            this.error = error
                            if (error.code) this.code = error.code
                        Severity: Minor
                        Found in lib/error.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

                        Function each has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                        exports.each = function (obj, fn) {
                          var i = null
                          var l = 0
                          if (_.isArr(obj)) {
                            for (i = 0, l = obj.length; i < l; i += 1) fn(obj[i], i)
                        Severity: Minor
                        Found in lib/utils.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

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

                        Options.prototype.set = function (key, value) {
                          if (_.isObj(key)) {
                            _.each(key, _.bind(this, this.set))
                          } else if (value !== undefined) {
                            if (key === 'servers') {
                        Severity: Minor
                        Found in lib/options.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 requestHandler has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        function requestHandler (server, operation, options, resolve, nextServer, resilient) {
                        Severity: Minor
                        Found in lib/requester.js - About 45 mins to fix

                          Function requestHandler has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          function requestHandler (server, operation, options, resolve, nextServer, resilient) {
                          Severity: Minor
                          Found in resilient.js - About 45 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language