resilient-http/resilient.js

View on GitHub

Showing 48 of 305 total issues

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

function handleMissingServers (resilient, servers, options, getPreviousResponse, cb) {
Severity: Minor
Found in lib/requester.js - About 35 mins to fix

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

    function handleMissingServers (resilient, servers, options, getPreviousResponse, cb) {
    Severity: Minor
    Found in resilient.js - About 35 mins to fix

      Function closePendingRequest has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      function closePendingRequest (client) {
        if (client) {
          if (client.xhr) {
            if (client.xhr.readyState !== 4) {
              closeClient(client.xhr)
      Severity: Minor
      Found in lib/discovery.js - About 35 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 sort has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      Servers.prototype.sort = function (operation, options) {
        var servers = this.servers.slice(0)
        if (servers.length) {
          if (!options.get('disableWeight')) {
            servers.sort(function (x, y) {
      Severity: Minor
      Found in lib/servers.js - About 35 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 a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      function requestHandler (server, operation, options, resolve, nextServer, resilient) {
        var start = _.now()
        return function requestReporter (err, res) {
          var latency = _.now() - start
          resilient.emit('request:incoming', err, res, options, resilient)
      Severity: Minor
      Found in lib/requester.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 mapServer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      function mapServer (data) {
        var server
        if (data instanceof Server) {
          server = data
        } else {
      Severity: Minor
      Found in lib/servers.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 mapOptions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      function mapOptions (options) {
        if (typeof options === 'string') {
          options = { url: options }
        } else {
          options = options || {}
      Severity: Minor
      Found in lib/http.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 roundRobinSort has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      function roundRobinSort (servers, options) {
        var size = 0
        if (options && options.get('roundRobin')) {
          var configSize = +options.get('roundRobinSize')
          size = configSize > servers.length ? servers.length : configSize
      Severity: Minor
      Found in lib/servers.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

      Severity
      Category
      Status
      Source
      Language