CodeCharmLtd/http-master

View on GitHub
modules/middleware/proxy.js

Summary

Maintainability
B
6 hrs
Test Coverage

Function ProxyMiddleware has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function ProxyMiddleware(config, portConfig, di) {
  var {httpAgent, httpsAgent} = getAgent(config, portConfig);
  var proxyHttp = httpProxy.createProxyServer({xfwd: true, agent: httpAgent});
  var proxyHttps = httpProxy.createProxyServer({xfwd: true, agent: httpsAgent, secure: false});
  proxyHttp.on('error', function(err, req, res) {
Severity: Minor
Found in modules/middleware/proxy.js - About 2 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 ProxyMiddleware has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function ProxyMiddleware(config, portConfig, di) {
  var {httpAgent, httpsAgent} = getAgent(config, portConfig);
  var proxyHttp = httpProxy.createProxyServer({xfwd: true, agent: httpAgent});
  var proxyHttps = httpProxy.createProxyServer({xfwd: true, agent: httpsAgent, secure: false});
  proxyHttp.on('error', function(err, req, res) {
Severity: Major
Found in modules/middleware/proxy.js - About 2 hrs to fix

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

        requestHandler: function(req, res, next, dispatchTarget) {
          req.next = next;
          // workaround for node-http-proxy/#591
          if(!req.headers.host) {
            req.headers.host = '';
    Severity: Minor
    Found in modules/middleware/proxy.js - About 1 hr to fix

      There are no issues that match your filters.

      Category
      Status