bbyars/mountebank

View on GitHub

Showing 386 of 386 total issues

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

function and (predicate, request, encoding, logger, imposterState) {
Severity: Minor
Found in src/models/predicates.js - About 35 mins to fix

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

    function not (predicate, request, encoding, logger, imposterState) {
    Severity: Minor
    Found in src/models/predicates.js - About 35 mins to fix

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

      async function execute (request, response, behaviors, logger, imposterState) {
      Severity: Minor
      Found in src/models/behaviors.js - About 35 mins to fix

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

        function loadProtocols (options, baseURL, logger, isAllowedConnection, imposters) {
        Severity: Minor
        Found in src/models/protocols.js - About 35 mins to fix

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

          function inject (predicate, request, encoding, logger, imposterState) {
          Severity: Minor
          Found in src/models/predicates.js - About 35 mins to fix

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

                async function proxyAndRecord (responseConfig, request, logger, requestDetails, imposterState) {
            Severity: Minor
            Found in src/models/responseResolver.js - About 35 mins to fix

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

              function or (predicate, request, encoding, logger, imposterState) {
              Severity: Minor
              Found in src/models/predicates.js - About 35 mins to fix

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

                function evaluate (predicate, request, encoding, logger, imposterState) {
                Severity: Minor
                Found in src/models/predicates.js - About 35 mins to fix

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

                      function processResponse (responseConfig, request, logger, imposterState, requestDetails) {
                  Severity: Minor
                  Found in src/models/responseResolver.js - About 35 mins to fix

                    Function select has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function select (selector, possibleJSON, logger) {
                        const isObject = helpers.isObject;
                    
                        try {
                            const json = isObject(possibleJSON) ? possibleJSON : JSON.parse(possibleJSON),
                    Severity: Minor
                    Found in src/models/jsonpath.js - About 35 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 howLongAgo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function howLongAgo (thenText, testNowText) {
                        const nowText = testNowText ? testNowText : new Date(Date.now()).toISOString(), // testNow is just for testing purposes
                            then = toEpochWithoutTime(thenText),
                            now = toEpochWithoutTime(nowText),
                            millisecondsInDay = 24 * 60 * 60 * 1000,
                    Severity: Minor
                    Found in src/util/date.js - About 35 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 getFrom has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function getFrom (obj, from) {
                        const isObject = helpers.isObject;
                    
                        if (typeof obj === 'undefined') {
                            return undefined;
                    Severity: Minor
                    Found in src/models/behaviors.js - About 35 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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function create () {
                        const imposters = {},
                            stubRepos = {};
                    
                        /**
                    Severity: Minor
                    Found in src/models/inMemoryImpostersRepository.js - About 35 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

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                                if (contentEncoding === 'gzip') {
                                    try {
                                        request.body = zlib.gunzipSync(buffer).toString();
                                    }
                                    catch (error) { /* do nothing */ }
                    Severity: Minor
                    Found in src/models/http/httpRequest.js and 1 other location - About 35 mins to fix
                    src/models/http/httpRequest.js on lines 68..76

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 46.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                                else if (contentEncoding === 'br') {
                                    try {
                                        request.body = zlib.brotliDecompressSync(buffer).toString();
                                    }
                                    catch (error) { /* do nothing */ }
                    Severity: Minor
                    Found in src/models/http/httpRequest.js and 1 other location - About 35 mins to fix
                    src/models/http/httpRequest.js on lines 62..76

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 46.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                                    validator = dryRunValidator.create({
                                        testRequest: Protocol.testRequest,
                                        testProxyResponse: Protocol.testProxyResponse,
                                        additionalValidation: Protocol.validate,
                                        allowInjection: allowInjection
                    Severity: Minor
                    Found in src/controllers/impostersController.js and 1 other location - About 35 mins to fix
                    src/controllers/imposterController.js on lines 164..169

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 46.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                                validator = dryRunValidator.create({
                                    testRequest: Protocol.testRequest,
                                    testProxyResponse: Protocol.testProxyResponse,
                                    additionalValidation: Protocol.validate,
                                    allowInjection: allowInjection
                    Severity: Minor
                    Found in src/controllers/imposterController.js and 1 other location - About 35 mins to fix
                    src/controllers/impostersController.js on lines 62..67

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 46.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Avoid too many return statements within this function.
                    Open

                                return predicateSatisfied(expected[fieldName], actual[fieldName], predicateConfig, predicateFn);
                    Severity: Major
                    Found in src/models/predicates.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return value;
                      Severity: Major
                      Found in src/models/predicates.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return testPredicate(expected[fieldName], actual[fieldName], predicateConfig, predicateFn);
                        Severity: Major
                        Found in src/models/predicates.js - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language