department-of-veterans-affairs/vets-website

View on GitHub
src/applications/personalization/profile/mocks/server.js

Summary

Maintainability
F
4 days
Test Coverage

responses has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

const responses = {
  'GET /v0/feature_toggles': (_req, res) => {
    const secondsOfDelay = 0;
    delaySingleResponse(
      () =>
Severity: Minor
Found in src/applications/personalization/profile/mocks/server.js - About 2 hrs to fix

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

    const logRequest = req => {
      const { body, url, method, params, query } = req;
      const historyEntry = {};
      // only add variables to requestHistory if they are not empty
      if (!_.isEmpty(params)) {
    Severity: Major
    Found in src/applications/personalization/profile/mocks/server.js and 1 other location - About 1 day to fix
    src/applications/representative-appoint/mocks/server.js on lines 43..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 239.

    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

    const generateMockResponses = () => {
      boot(mockLocalDSOT);
    
      // set DELAY=1000 when running mock server script
      // to add 1 sec delay to all responses
    Severity: Major
    Found in src/applications/personalization/profile/mocks/server.js and 2 other locations - About 5 hrs to fix
    src/applications/_mock-form-ae-design-patterns/mocks/server.js on lines 210..228
    src/applications/representative-appoint/mocks/server.js on lines 258..276

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

    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

      'PATCH /v0/profile/communication_preferences/:pref': (req, res) => {
        const {
          communicationItem: {
            id: communicationItemId,
            communicationChannel: {
    Severity: Major
    Found in src/applications/personalization/profile/mocks/server.js and 1 other location - About 4 hrs to fix
    src/applications/representative-appoint/mocks/server.js on lines 201..226

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

    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

      'PUT /v0/profile/addresses': (req, res) => {
        // uncomment to test 401 error
        // return res.status(401).json(require('../tests/fixtures/401.json'));
    
        // trigger NO_CHANGES_DETECTED response
    Severity: Major
    Found in src/applications/personalization/profile/mocks/server.js and 2 other locations - About 3 hrs to fix
    src/applications/_mock-form-ae-design-patterns/mocks/server.js on lines 152..188
    src/applications/representative-appoint/mocks/server.js on lines 142..178

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

    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

    const boot = cb => {
      // this runs once when the mock server starts up
      // uses a environment variable to prevent this from running more than once
      if (!process.env.HAS_RUN_AE_MOCKSERVER) {
        debug('BOOT');
    Severity: Major
    Found in src/applications/personalization/profile/mocks/server.js and 1 other location - About 3 hrs to fix
    src/applications/representative-appoint/mocks/server.js on lines 241..253

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

    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

      'PUT /v0/profile/telephones': (req, res) => {
        if (req?.body?.phoneNumber === '1111111') {
          return res.json(phoneNumber.transactions.receivedNoChangesDetected);
        }
        return res.status(200).json(phoneNumber.transactions.received);
    Severity: Major
    Found in src/applications/personalization/profile/mocks/server.js and 1 other location - About 2 hrs to fix
    src/applications/representative-appoint/mocks/server.js on lines 127..132

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

    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

      'GET /v0/profile/communication_preferences': (req, res) => {
        if (req?.query?.error === 'true') {
          return res.status(500).json(genericErrors.error500);
        }
        return delaySingleResponse(() => res.json(maximalSetOfPreferences), 1);
    Severity: Major
    Found in src/applications/personalization/profile/mocks/server.js and 1 other location - About 1 hr to fix
    src/applications/representative-appoint/mocks/server.js on lines 195..200

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

    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

              generateFeatureToggles({
                authExpVbaDowntimeMessage: false,
                profileHideDirectDeposit: false,
                profileShowCredentialRetirementMessaging: true,
                profileShowPaymentsNotificationSetting: true,
    Severity: Major
    Found in src/applications/personalization/profile/mocks/server.js and 1 other location - About 1 hr to fix
    src/applications/personalization/profile/mocks/endpoints/feature-toggles/index.js on lines 5..20

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

    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

    function terminationHandler(signal) {
      debug(`\nReceived ${signal}`);
      process.env.HAS_RUN_AE_MOCKSERVER = false;
      process.exit();
    }
    Severity: Major
    Found in src/applications/personalization/profile/mocks/server.js and 2 other locations - About 45 mins to fix
    src/applications/personalization/common/mocks/script/utils.js on lines 28..32
    src/applications/representative-appoint/mocks/server.js on lines 235..239

    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

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

      'DELETE /v0/profile/addresses': (_req, res) => {
        const secondsOfDelay = 1;
        delaySingleResponse(
          () => res.status(200).json(address.homeAddressDeleteReceived),
          secondsOfDelay,
    Severity: Major
    Found in src/applications/personalization/profile/mocks/server.js and 2 other locations - About 45 mins to fix
    src/applications/_mock-form-ae-design-patterns/mocks/server.js on lines 192..198
    src/applications/representative-appoint/mocks/server.js on lines 182..188

    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

    There are no issues that match your filters.

    Category
    Status