bbyars/mountebank

View on GitHub
src/models/predicates.js

Summary

Maintainability
C
1 day
Test Coverage
A
97%

File predicates.js has 331 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

const stringify = require('safe-stable-stringify'),
    safeRegex = require('safe-regex'),
    jsonpath = require('./jsonpath.js'),
Severity: Minor
Found in src/models/predicates.js - About 3 hrs to fix

    Function predicateSatisfied has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function predicateSatisfied (expected, actual, predicateConfig, predicateFn) {
        if (!actual) {
            return false;
        }
    
    
    Severity: Minor
    Found in src/models/predicates.js - About 1 hr to fix

      Function selectTransform has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      function selectTransform (config, options, logger) {
          const cloned = helpers.clone(config);
      
          if (config.jsonpath) {
              const stringTransform = options.shouldForceStrings ? forceStrings : combinators.identity;
      Severity: Minor
      Found in src/models/predicates.js - About 1 hr 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 selectJSONPath has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function selectJSONPath (config, encoding, predicateConfig, stringTransform, logger, text) {
      Severity: Minor
      Found in src/models/predicates.js - About 45 mins to fix

        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 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 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

                  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

                        Parsing error: Invalid ecmaVersion.
                        Open

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

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

                        There are no issues that match your filters.

                        Category
                        Status