bbyars/mountebank

View on GitHub
src/models/http/httpProxy.js

Summary

Maintainability
D
1 day
Test Coverage
F
12%

Function create has 159 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function create (logger) {
    const BINARY_CONTENT_ENCODINGS = [
        'gzip', 'br', 'compress', 'deflate'
    ];
    const BINARY_MIME_TYPES = [
Severity: Major
Found in src/models/http/httpProxy.js - About 6 hrs to fix

    Function create has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

    function create (logger) {
        const BINARY_CONTENT_ENCODINGS = [
            'gzip', 'br', 'compress', 'deflate'
        ];
        const BINARY_MIME_TYPES = [
    Severity: Minor
    Found in src/models/http/httpProxy.js - About 4 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 getProxyRequest has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function getProxyRequest (baseUrl, originalRequest, proxyOptions, requestDetails) {
            /* eslint complexity: 0 */
            const parts = new URL(baseUrl),
                protocol = parts.protocol === 'https:' ? https : http,
                defaultPort = parts.protocol === 'https:' ? 443 : 80,
    Severity: Minor
    Found in src/models/http/httpProxy.js - About 1 hr to fix

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

          function to (proxyDestination, originalRequest, options, requestDetails) {
      
              addInjectedHeadersTo(originalRequest, options.injectHeaders);
      
              function log (direction, what) {
      Severity: Minor
      Found in src/models/http/httpProxy.js - About 1 hr to fix

        Parsing error: Invalid ecmaVersion.
        Open

        'use strict';
        Severity: Minor
        Found in src/models/http/httpProxy.js by eslint

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

        There are no issues that match your filters.

        Category
        Status