Showing 30 of 111 total issues

File http.js has 1088 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const fs = require('fs')
const http = require('http')
const crypto = require('crypto')
const connect = require('connect')
const sinon = require('sinon')
Severity: Major
Found in test/http.js - About 2 days to fix

    Function responseBody has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = function responseBody (middleware, filter) {
      return function (req, res, next) {
        // Apply request filter, if present
        if (filter && !helpers.filterRequest(filter, res)) {
          return next()
    Severity: Minor
    Found in lib/middleware/response-body.js - About 1 day 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 responseBody has 100 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function responseBody (middleware, filter) {
      return function (req, res, next) {
        // Apply request filter, if present
        if (filter && !helpers.filterRequest(filter, res)) {
          return next()
    Severity: Major
    Found in lib/middleware/response-body.js - About 4 hrs to fix

      Function requestBody has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports = function requestBody (middleware, filter) {
        return function (req, res, next) {
          // Ignore HTTP verbs that does not support bodies
          if (req.method === 'GET' || req.method === 'HEAD') {
            return next()
      Severity: Minor
      Found in lib/middleware/request-body.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

      Function requestBody has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function requestBody (middleware, filter) {
        return function (req, res, next) {
          // Ignore HTTP verbs that does not support bodies
          if (req.method === 'GET' || req.method === 'HEAD') {
            return next()
      Severity: Minor
      Found in lib/middleware/request-body.js - About 1 hr to fix

        Function forward has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function forward (route, opts, req, res, done) {
          // Clone request object to avoid side-effects on mutations
          const forwardReq = helpers.cloneRequest(req, opts)
        
          // Run the forward phase middleware
        Severity: Minor
        Found in lib/protocols/http/passes/forward.js - About 1 hr to fix

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

          module.exports = function eachSeries (arr, iterator, cb) {
            cb = cb || noop
            if (!Array.isArray(arr) || !arr.length) return cb()
          
            const stack = arr.slice()
          Severity: Minor
          Found in lib/helpers/each-series.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 eachConcurrently has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports = function eachConcurrently (arr, iterator, cb) {
            cb = cb || noop
            if (!Array.isArray(arr) || !arr.length) return cb()
          
            var errors = []
          Severity: Minor
          Found in lib/helpers/each-concurrently.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 forward has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports = function forward (route, opts, req, res, done) {
            // Clone request object to avoid side-effects on mutations
            const forwardReq = helpers.cloneRequest(req, opts)
          
            // Run the forward phase middleware
          Severity: Minor
          Found in lib/protocols/http/passes/forward.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 retryRequest has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          function retryRequest (route, params, opts, req, res, handler) {
          Severity: Minor
          Found in lib/protocols/http/passes/replay.js - About 45 mins to fix

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

            module.exports = function (query) {
              return function (req, res, next) {
                const parsedUrl = url.parse(req.url, true)
            
                if (!req.query) {
            Severity: Minor
            Found in lib/middleware/query.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 replayHandler has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function replayHandler (route, params, opts, req, next) {
            Severity: Minor
            Found in lib/protocols/http/passes/replay.js - About 35 mins to fix

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

              module.exports = function wsProxy (opts, req, socket, head, done) {
              Severity: Minor
              Found in lib/protocols/ws/proxy.js - About 35 mins to fix

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

                module.exports = function (opts, req, socket, head, done) {
                Severity: Minor
                Found in lib/protocols/ws/passes/forward.js - About 35 mins to fix

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

                      rockyStub.mw = { run: function (a, b, c, d, next) { next() } }
                  Severity: Minor
                  Found in test/server/server.js - About 35 mins to fix

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

                    function replayer (route, replayReq, replayRes, opts, next) {
                    Severity: Minor
                    Found in lib/protocols/http/passes/replay.js - About 35 mins to fix

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

                      exports.concurrently = function (opts, req, socket, head, done) {
                      Severity: Minor
                      Found in lib/protocols/ws/passes/index.js - About 35 mins to fix

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

                            rockyStub.mw = { run: function (a, b, c, d, next) { next() } }
                        Severity: Minor
                        Found in test/server/server.js - About 35 mins to fix

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

                          function forwardStrategy (route, opts, req, res, resolver) {
                          Severity: Minor
                          Found in lib/protocols/http/passes/forward.js - About 35 mins to fix

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

                            module.exports = function replay (route, opts, req, res, next) {
                            Severity: Minor
                            Found in lib/protocols/http/passes/replay.js - About 35 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language