lib/protocols/http/passes/forward.js

Summary

Maintainability
B
4 hrs
Test Coverage

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 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 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 forwardRetryRequest has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function forwardRetryRequest (route, opts, forwardReq, res, done) {
      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 forward (route, opts, req, res, done) {
        Severity: Minor
        Found in lib/protocols/http/passes/forward.js - About 35 mins to fix

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

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

            Function defineHostHeader has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            function defineHostHeader (forwardReq, opts) {
              const forwardHost = opts.forwardHost
              if (!forwardHost) return
            
              const headers = forwardReq.headers
            Severity: Minor
            Found in lib/protocols/http/passes/forward.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

            There are no issues that match your filters.

            Category
            Status