bbyars/mountebank

View on GitHub

Showing 100 of 386 total issues

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

              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

                    Avoid too many return statements within this function.
                    Open

                                return Promise.reject(exceptions.ValidationError('unrecognized response type',
                                    { source: helpers.clone(responseConfig) }));
                    Severity: Major
                    Found in src/models/responseResolver.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return 'this month';
                      Severity: Major
                      Found in src/util/date.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return '';
                        Severity: Major
                        Found in src/util/date.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return this.inMemory();
                          Severity: Major
                          Found in src/models/impostersRepository.js - About 30 mins to fix

                            Function parseLogConfiguration has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function parseLogConfiguration (args) {
                                // Not defaulted in yargs so we can test yargs value without defaulting interfering.
                                // This is needed for backwards compatibility with older CLI options.
                                const defaultConfig = {
                                    level: 'info',
                            Severity: Minor
                            Found in src/cli/cli.js - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function create (logfile) {
                                function getLogEntries () {
                                    if (!logfile || !fs.existsSync(logfile)) {
                                        return [{ level: 'error', message: 'No logfile' }];
                                    }
                            Severity: Minor
                            Found in src/controllers/logsController.js - About 25 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 rawArgvIndexFor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function rawArgvIndexFor (key) {
                                // Use raw process.argv to ensure user actually passed the parameter, bypassing
                                // yargs defaulting. Also check alias.
                                let index = process.argv.indexOf(`--${key}`);
                                if (index < 0) {
                            Severity: Minor
                            Found in src/cli/cli.js - About 25 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

                            Severity
                            Category
                            Status
                            Source
                            Language