department-of-veterans-affairs/vets-website

View on GitHub
src/applications/disability-benefits/686c-674/config/address-schema.js

Summary

Maintainability
F
3 wks
Test Coverage

Function addressUISchema has 351 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const addressUISchema = (
  isMilitaryBaseAddress = false,
  path,
  callback,
) => {

    Function returnAddressUI has 346 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      return (function returnAddressUI() {
        return {
          [MILITARY_BASE_PATH]: {
            'ui:title': `${checkBoxTitleState} receive mail outside of the United States on a U.S. military base.`,
            'ui:options': {

      Function addressUISchema has a Cognitive Complexity of 79 (exceeds 5 allowed). Consider refactoring.
      Open

      export const addressUISchema = (
        isMilitaryBaseAddress = false,
        path,
        callback,
      ) => {

      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

      File address-schema.js has 470 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /**
       * The intent for this module is to provide a flexible, reusable address schema and widget that can be used in any form throughout VA.gov.
       * The address uiSchema should be flexible enough to handle these cases:
       * 1. Top level address property (schema.properties.address)
       * 2. Nested address property (schema.properties.someProperty.properties.address)

        Function updateFormDataAddress has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        export const updateFormDataAddress = (
          oldFormData,
          formData,
          path,
          index = null, // this is included in the path, but added as

        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 updateSchema has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                  updateSchema: (formData, schema, uiSchema, index) => {
                    let militaryBasePath = livesOnMilitaryBasePath;
                    let countryPath = path;
                    if (typeof index === 'number') {
                      militaryBasePath = insertArrayIndex(

          Function ui:validations has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                    (errors, city, formData, _schema, _uiSchema, _index) => {
                      // This variable represents whether a veteran checked the "I live on a military base outside of the U.S." checkbox on the page
                      // running this validation. This is stored within `formData` as `view:livesOnMilitaryBase` (`MILITARY_BASE_PATH`), but the path
                      // thereto differs depending on the page running the validation.
                      let livesOnMilitaryBase =

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

            export const validateZipCode = (zipCode, stateCode, errors) => {
              if (stateCode in MILITARY_BASE_ZIP_REGEX) {
                if (!zipCode.match(MILITARY_BASE_ZIP_REGEX[stateCode])) {
                  errors.addError(INVALID_ZIP_ERROR);
                  return false;
            Severity: Minor
            Found in src/applications/disability-benefits/686c-674/config/address-schema.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

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

            export const addressUISchema = (
              isMilitaryBaseAddress = false,
              path,
              callback,
            ) => {
            src/applications/disability-benefits/686c-674-v2/config/address-schema.js on lines 201..607

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

            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

            export const updateFormDataAddress = (
              oldFormData,
              formData,
              path,
              index = null, // this is included in the path, but added as
            src/applications/disability-benefits/686c-674-v2/config/address-schema.js on lines 150..192

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

            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

            export const validateZipCode = (zipCode, stateCode, errors) => {
              if (stateCode in MILITARY_BASE_ZIP_REGEX) {
                if (!zipCode.match(MILITARY_BASE_ZIP_REGEX[stateCode])) {
                  errors.addError(INVALID_ZIP_ERROR);
                  return false;
            src/applications/disability-benefits/686c-674-v2/config/address-schema.js on lines 112..128

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

            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

            export const buildAddressSchema = isMilitaryBaseAddress => {
              const addSchema = fullSchema.definitions.addressSchema;
              if (isMilitaryBaseAddress) return cloneDeep(addSchema);
              const schema = cloneDeep(addSchema);
              delete schema.properties[MILITARY_BASE_PATH];
            src/applications/disability-benefits/686c-674-v2/config/address-schema.js on lines 85..92

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

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

            const MilitaryBaseInfo = () => (
              <div className="vads-u-padding-x--2p5">
                <va-additional-info trigger="Learn more about military base addresses">
                  <span>
                    Addresses on U.S. military bases are considered domestic addresses, even
            src/applications/ask-va/config/chapters/personalInformation/veteransPostalCode.js on lines 14..23
            src/applications/ask-va/config/chapters/personalInformation/yourMailingAddress.js on lines 11..20
            src/applications/ask-va/config/chapters/personalInformation/yourPostalCode.js on lines 14..23
            src/applications/ask-va/config/helpers.jsx on lines 223..232
            src/applications/disability-benefits/2346/schemas/address-schema.js on lines 56..65

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

            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 getOldFormDataPath = (path, index) => {
              const indexToSlice = index !== null ? path.indexOf(index) + 1 : 0;
              return path.slice(indexToSlice);
            };
            src/applications/disability-benefits/686c-674-v2/config/address-schema.js on lines 96..99

            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

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

            const filteredStates = constants.states.USA.filter(
              state => !ADDRESS_DATA.militaryStates.includes(state.value),
            );
            src/applications/disability-benefits/686c-674-v2/config/address-schema.js on lines 40..42

            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

            There are no issues that match your filters.

            Category
            Status