bbyars/mountebank

View on GitHub

Showing 119 of 386 total issues

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

    function validate (behaviors, validationSpec) {
        const errors = [];

        (behaviors || []).forEach(config => {
            const validBehaviors = [],
Severity: Minor
Found in src/models/behaviorsValidator.js - About 1 hr to fix

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

    function create (releases) {
        function createNotice (release) {
            return {
                version: release.version,
                when: date.howLongAgo(release.date)
    Severity: Minor
    Found in src/controllers/homeController.js - About 1 hr to fix

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

          async function proxyAndRecord (responseConfig, request, logger, requestDetails, imposterState) {
              const startTime = new Date(),
                  observeProxyDuration = metrics.proxyDuration.startTimer();
      
              metrics.proxyCount.inc({ imposter: logger.scopePrefix });
      Severity: Minor
      Found in src/models/responseResolver.js - About 1 hr to fix

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

            async function respond (payload, request, clientName, socket) {
                let formattedRequestData = payload.toString(encoding);
                if (formattedRequestData.length > 20) {
                    formattedRequestData = formattedRequestData.substring(0, 20) + '...';
                }
        Severity: Minor
        Found in src/models/tcp/tcpServer.js - About 1 hr to fix

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

              function inject (request, fn, logger, imposterState) {
                  if (request.isDryRun) {
                      return Promise.resolve({});
                  }
          
          
          Severity: Minor
          Found in src/models/responseResolver.js - About 1 hr to fix

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

            function create (config) {
                let callbackURL,
                    proxy;
            
                function setPort (port) {
            Severity: Minor
            Found in src/models/mbConnection.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 resolveWithMetadata has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                          function resolveWithMetadata (possibleJSON) {
                              let metadata = {};
              
                              try {
                                  metadata = JSON.parse(possibleJSON);
              Severity: Minor
              Found in src/models/protocols.js - About 1 hr to fix

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

                function create (config, logger) {
                    if (config.impostersRepository) {
                        const filename = path.resolve(path.relative(process.cwd(), config.impostersRepository));
                
                        if (fs.existsSync(filename)) {
                Severity: Minor
                Found in src/models/impostersRepository.js - About 55 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 xpathSelect has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                function xpathSelect (selectFn, selector, doc) {
                    if (!helpers.defined(doc)) {
                        return [];
                    }
                
                
                Severity: Minor
                Found in src/models/xpath.js - About 55 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 load has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function load (builtInProtocols, customProtocols, options, isAllowedConnection, mbLogger, impostersRepository) {
                Severity: Minor
                Found in src/models/protocols.js - About 45 mins to fix

                  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 decorate has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

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

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

                          function addTypeErrors (fieldSpec, path, field, config, addErrorFn) {
                      Severity: Minor
                      Found in src/models/behaviorsValidator.js - About 35 mins to fix

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

                        async function create (Protocol, creationRequest, baseLogger, config, isAllowedConnection) {
                        Severity: Minor
                        Found in src/models/imposter.js - About 35 mins to fix

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

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

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

                                async function recordMatch (stub, request, response, responseConfig, start) {
                            Severity: Minor
                            Found in src/models/imposter.js - About 35 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 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
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language