department-of-veterans-affairs/vets-website

View on GitHub
src/applications/_mock-form-ae-design-patterns/utils/data/task-gray/profile.js

Summary

Maintainability
F
2 wks
Test Coverage

File profile.js has 339 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React from 'react';
import PropTypes from 'prop-types';

import {
  isValidEmail,

    Function getMissingInfo has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

    export const getMissingInfo = ({ data, keys, content, requiredKeys = [] }) => {
      const missingInfo = [];
      // If both home & mobile selected, make only one phone required
      const phones = [keys.homePhone, '|', keys.mobilePhone];
      const eitherPhone =

    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

    Consider simplifying this complex logical expression.
    Open

      if (keys.address && requiredKeys.includes(keys.address)) {
        const addressObject = data[keys.address] || {};
    
        const isUS = addressObject.addressType !== ADDRESS_TYPES.international;
        const hasRequiredAddressFields =

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

      export const contactInfoPropTypes = {
        contactInfoPageKey: PropTypes.string,
        content: PropTypes.shape({
          address1: PropTypes.string, // review & submit address line 1 entry
          address2: PropTypes.string, // review & submit address line 2 entry
      src/applications/_mock-form-ae-design-patterns/utils/data/task-blue/profile.js on lines 410..489
      src/applications/_mock-form-ae-design-patterns/utils/data/task-purple/profile.js on lines 422..501
      src/platform/forms-system/src/js/utilities/data/profile.js on lines 422..501

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

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

      export const getMissingInfo = ({ data, keys, content, requiredKeys = [] }) => {
        const missingInfo = [];
        // If both home & mobile selected, make only one phone required
        const phones = [keys.homePhone, '|', keys.mobilePhone];
        const eitherPhone =
      src/applications/_mock-form-ae-design-patterns/utils/data/task-blue/profile.js on lines 350..390
      src/applications/_mock-form-ae-design-patterns/utils/data/task-purple/profile.js on lines 362..402
      src/platform/forms-system/src/js/utilities/data/profile.js on lines 362..402

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

      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

      export const getContent = (appName = 'application') => ({
        title: 'Contact information',
        description: (
          <>
            <p>
      src/applications/_mock-form-ae-design-patterns/utils/data/task-purple/profile.js on lines 56..118
      src/platform/forms-system/src/js/utilities/data/profile.js on lines 56..118

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

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

      export const profileAddressSchema = {
        type: 'object',
        oneOf: [
          // Schema for international addresses
          {
      src/applications/_mock-form-ae-design-patterns/utils/data/task-blue/profile.js on lines 166..235
      src/applications/_mock-form-ae-design-patterns/utils/data/task-purple/profile.js on lines 178..247
      src/platform/forms-system/src/js/utilities/data/profile.js on lines 178..247

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

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

      export const standardPhoneSchema = isRequired => ({
        type: 'object',
        properties: {
          countryCode: {
            type: 'string',
      src/applications/_mock-form-ae-design-patterns/utils/data/task-blue/profile.js on lines 120..149
      src/applications/_mock-form-ae-design-patterns/utils/data/task-purple/profile.js on lines 132..161
      src/platform/forms-system/src/js/utilities/data/profile.js on lines 132..161

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

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

      export const validateZipcode = (content, zipcode) => {
        const processedZipcode = (zipcode || '').trim();
        if (!processedZipcode) {
          return content.missingZipError(true);
        }
      src/applications/_mock-form-ae-design-patterns/utils/data/task-blue/profile.js on lines 310..319
      src/applications/_mock-form-ae-design-patterns/utils/data/task-purple/profile.js on lines 322..331
      src/platform/forms-system/src/js/utilities/data/profile.js on lines 322..331

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

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

      export const validateEmail = (content, email) => {
        const processedEmail = (email || '').trim();
        if (!processedEmail) {
          return content.missingEmailError;
        }
      src/applications/_mock-form-ae-design-patterns/utils/data/task-blue/profile.js on lines 276..285
      src/applications/_mock-form-ae-design-patterns/utils/data/task-purple/profile.js on lines 288..297
      src/platform/forms-system/src/js/utilities/data/profile.js on lines 288..297

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

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

      export const renderTelephone = (phoneObject = {}) => {
        const phoneString = getPhoneString(phoneObject);
        return phoneString ? (
          <va-telephone
            contact={phoneString}
      src/applications/_mock-form-ae-design-patterns/utils/data/task-blue/profile.js on lines 259..268
      src/applications/_mock-form-ae-design-patterns/utils/data/task-purple/profile.js on lines 271..280
      src/platform/forms-system/src/js/utilities/data/profile.js on lines 271..280

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

      export const validatePhone = (content, phoneObject) => {
        const processedPhoneString = getPhoneString(phoneObject);
        if (!processedPhoneString) {
          return content.missingPhoneError;
        }
      src/applications/_mock-form-ae-design-patterns/utils/data/task-blue/profile.js on lines 293..302
      src/applications/_mock-form-ae-design-patterns/utils/data/task-purple/profile.js on lines 305..314
      src/platform/forms-system/src/js/utilities/data/profile.js on lines 305..314

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

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

      export const convertNullishObjectValuesToEmptyString = object =>
        Object.entries(object || {}).reduce(
          (result, [key, value]) => ({ ...result, [key]: value ?? '' }),
          {},
        );
      src/applications/_mock-form-ae-design-patterns/utils/data/task-blue/profile.js on lines 326..330
      src/applications/_mock-form-ae-design-patterns/utils/data/task-purple/profile.js on lines 338..342
      src/platform/forms-system/src/js/utilities/data/profile.js on lines 338..342

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

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

      export const getPhoneString = (phoneObject = {}) =>
        `${phoneObject?.areaCode || ''}${phoneObject?.phoneNumber || ''}`.trim();
      src/applications/_mock-form-ae-design-patterns/utils/data/task-blue/profile.js on lines 251..252
      src/applications/_mock-form-ae-design-patterns/utils/data/task-purple/profile.js on lines 263..264
      src/platform/forms-system/src/js/utilities/data/profile.js on lines 263..264

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

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

      export const setReturnState = (key = '', state = '') =>
        window.sessionStorage.setItem(CONTACT_EDIT, `${key},${state}`);
      src/applications/_mock-form-ae-design-patterns/utils/data/task-blue/profile.js on lines 399..400
      src/applications/_mock-form-ae-design-patterns/utils/data/task-purple/profile.js on lines 411..412
      src/applications/financial-status-report/utils/contactInformation.js on lines 83..84
      src/platform/forms-system/src/js/utilities/data/profile.js on lines 411..412

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

      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