bbyars/mountebank

View on GitHub

Showing 386 of 386 total issues

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

                proxyServer.on('error', err => {
                    logger.warn('SERVER PROXY ERROR: [%s] %s', err.code, err.message);
                    logger.debug('%s', err.stack);
                });
Severity: Major
Found in src/models/http/baseHttpServer.js and 1 other location - About 1 hr to fix
src/models/http/baseHttpServer.js on lines 81..84

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

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

    return {
        get,
        del,
        resetProxies,
        resetRequests,
Severity: Minor
Found in src/controllers/imposterController.js and 1 other location - About 55 mins to fix
src/models/inMemoryImpostersRepository.js on lines 404..415

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

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

    return {
        add,
        get,
        all,
        exists,
Severity: Minor
Found in src/models/inMemoryImpostersRepository.js and 1 other location - About 55 mins to fix
src/controllers/imposterController.js on lines 314..325

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

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

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

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

        response.format({
            json: () => response.send(json),
            html: () => response.render('imposter', { imposter: json })
        });
Severity: Major
Found in src/controllers/imposterController.js and 2 other locations - About 50 mins to fix
src/controllers/imposterController.js on lines 44..47
src/controllers/imposterController.js on lines 65..68

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

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 3 locations. Consider refactoring.
Open

        response.format({
            json: () => response.send(json),
            html: () => response.render('imposter', { imposter: json })
        });
Severity: Major
Found in src/controllers/imposterController.js and 2 other locations - About 50 mins to fix
src/controllers/imposterController.js on lines 44..47
src/controllers/imposterController.js on lines 84..87

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

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 3 locations. Consider refactoring.
Open

        response.format({
            json: () => response.send(json),
            html: () => response.render('imposter', { imposter: json })
        });
Severity: Major
Found in src/controllers/imposterController.js and 2 other locations - About 50 mins to fix
src/controllers/imposterController.js on lines 65..68
src/controllers/imposterController.js on lines 84..87

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

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

        allStubs.forEach(stub => {
            stub.responses = stub.responses.filter(response => !isRecordedResponse(response));
        });
Severity: Minor
Found in src/models/inMemoryImpostersRepository.js and 1 other location - About 45 mins to fix
src/models/filesystemBackedImpostersRepository.js on lines 636..638

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

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

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

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

                  allStubs.forEach(stub => {
                      stub.responses = stub.responses.filter(response => !isRecordedResponse(response));
                  });
      Severity: Minor
      Found in src/models/filesystemBackedImpostersRepository.js and 1 other location - About 45 mins to fix
      src/models/inMemoryImpostersRepository.js on lines 226..228

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

      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 3 locations. Consider refactoring.
      Open

                  Object.keys(server.metadata).forEach(key => {
                      result[key] = server.metadata[key];
                  });
      Severity: Minor
      Found in src/models/imposterPrinter.js and 2 other locations - About 40 mins to fix
      src/models/compatibility.js on lines 124..126
      src/models/filesystemBackedImpostersRepository.js on lines 729..731

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

      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 3 locations. Consider refactoring.
      Open

              Object.keys(config.request).forEach(key => {
                  config[key] = config.request[key];
              });
      Severity: Minor
      Found in src/models/compatibility.js and 2 other locations - About 40 mins to fix
      src/models/filesystemBackedImpostersRepository.js on lines 729..731
      src/models/imposterPrinter.js on lines 26..28

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

      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 3 locations. Consider refactoring.
      Open

              Object.keys(imposterFns[id]).forEach(key => {
                  imposter[key] = imposterFns[id][key];
              });
      Severity: Minor
      Found in src/models/filesystemBackedImpostersRepository.js and 2 other locations - About 40 mins to fix
      src/models/compatibility.js on lines 124..126
      src/models/imposterPrinter.js on lines 26..28

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

      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

      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
                Severity
                Category
                Status
                Source
                Language