bbyars/mountebank

View on GitHub
src/util/middleware.js

Summary

Maintainability
B
5 hrs
Test Coverage
B
82%

Function useAbsoluteUrls has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function useAbsoluteUrls (port) {
    return function (request, response, next) {
        const setHeaderOriginal = response.setHeader,
            sendOriginal = response.send,
            host = request.headers.host || `localhost:${port}`,
Severity: Major
Found in src/util/middleware.js - About 2 hrs to fix

    Function send has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            response.send = function () {
                const args = Array.prototype.slice.call(arguments),
                    body = args[0],
                    changeLinks = function (obj) {
                        if (obj._links) {
    Severity: Minor
    Found in src/util/middleware.js - About 1 hr to fix

      Function json has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function json (log) {
          return function (request, response, next) {
              // Disable body parsing, if already parsed
              if (request.headers['content-type'] === 'application/json' && helpers.isObject(request.body)) {
                  next();
      Severity: Minor
      Found in src/util/middleware.js - About 1 hr to fix

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

        function validateApiKey (expectedApiKey, log) {
            return function (request, response, next) {
                if (!expectedApiKey) {
                    next();
                    return;
        Severity: Minor
        Found in src/util/middleware.js - About 1 hr to fix

          Parsing error: Invalid ecmaVersion.
          Open

          'use strict';
          Severity: Minor
          Found in src/util/middleware.js by eslint

          For more information visit Source: http://eslint.org/docs/rules/

          There are no issues that match your filters.

          Category
          Status