department-of-veterans-affairs/vets-website

View on GitHub
src/applications/disability-benefits/all-claims/utils/index.jsx

Summary

Maintainability
F
3 days
Test Coverage

File index.jsx has 533 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable react/jsx-key */
import PropTypes from 'prop-types';
import React from 'react';
import moment from 'moment';
import * as Sentry from '@sentry/browser';
Severity: Major
Found in src/applications/disability-benefits/all-claims/utils/index.jsx - About 1 day to fix

    Function showSeparationLocation has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const showSeparationLocation = formData => {
      const { serviceInformation = {} } = formData || {};
      const { servicePeriods, reservesNationalGuardService } = serviceInformation;
    
      // moment(undefined) => today
    Severity: Minor
    Found in src/applications/disability-benefits/all-claims/utils/index.jsx - About 1 hr to fix

      Function isBDD has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const isBDD = formData => {
        const isBddDataFlag = Boolean(formData?.['view:isBddData']);
        const servicePeriods = formData?.serviceInformation?.servicePeriods || [];
      
        // separation date entered in the wizard
      Severity: Minor
      Found in src/applications/disability-benefits/all-claims/utils/index.jsx - About 1 hr to fix

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

        export const showSeparationLocation = formData => {
          const { serviceInformation = {} } = formData || {};
          const { servicePeriods, reservesNationalGuardService } = serviceInformation;
        
          // moment(undefined) => today
        Severity: Minor
        Found in src/applications/disability-benefits/all-claims/utils/index.jsx - 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

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

        export const viewifyFields = formData => {
          const newFormData = {};
          Object.keys(formData).forEach(key => {
            const viewKey = /^view:/.test(key) ? key : `view:${key}`;
            // Recurse if necessary
        src/platform/forms-system/src/js/utilities/viewify-fields.js on lines 8..19

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

        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

        export const isAnswering781aQuestions = index => formData =>
          needsToEnter781a(formData) &&
          _.get('view:upload781aChoice', formData, '') === 'answerQuestions' &&
          (_.get(`view:enterAdditionalSecondaryEvents${index - 1}`, formData, false) ||
            index === 0);
        src/applications/disability-benefits/all-claims/utils/index.jsx on lines 423..427

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

        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

        export const isAnswering781Questions = index => formData =>
          needsToEnter781(formData) &&
          _.get('view:upload781Choice', formData, '') === 'answerQuestions' &&
          (_.get(`view:enterAdditionalEvents${index - 1}`, formData, false) ||
            index === 0);
        src/applications/disability-benefits/all-claims/utils/index.jsx on lines 429..433

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

        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 srSubstitute = (srIgnored, substitutionText) => (
          <span>
            <span aria-hidden>{srIgnored}</span>
            <span className="sr-only">{substitutionText}</span>
          </span>
        src/applications/representative-appoint/utilities/helpers.js on lines 74..79
        src/platform/forms-system/src/js/utilities/ui/mask-string.jsx on lines 11..16
        src/applications/edu-benefits/0994/utils.jsx on lines 10..15

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

        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

        export const wantsHelpWithPrivateRecordsSecondary = index => formData =>
          _.get(
            `secondaryIncident${index}.otherSourcesHelp.view:helpPrivateMedicalTreatment`,
            formData,
            '',
        src/applications/disability-benefits/all-claims/utils/index.jsx on lines 489..496

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

        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

        export const wantsHelpRequestingStatementsSecondary = index => formData =>
          _.get(
            `secondaryIncident${index}.otherSourcesHelp.view:helpRequestingStatements`,
            formData,
            '',
        src/applications/disability-benefits/all-claims/utils/index.jsx on lines 480..487

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

        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 formatDate = (date, format = DATE_FORMAT) => {
          const m = moment(date);
          return date && m.isValid() ? m.format(format) : 'Unknown';
        };
        src/applications/representative-appoint/utilities/helpers.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 58.

        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

        export const isAddingIndividuals = index => formData =>
          isAnswering781Questions(index)(formData) &&
          _.get(`view:individualsInvolved${index}`, formData, false);
        Severity: Minor
        Found in src/applications/disability-benefits/all-claims/utils/index.jsx and 1 other location - About 40 mins to fix
        src/applications/disability-benefits/all-claims/utils/index.jsx on lines 435..437

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

        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

        export const isUploading781aSupportingDocuments = index => formData =>
          isAnswering781aQuestions(index)(formData) &&
          _.get(`secondaryIncident${index}.view:uploadSources`, formData, false);
        Severity: Minor
        Found in src/applications/disability-benefits/all-claims/utils/index.jsx and 1 other location - About 40 mins to fix
        src/applications/disability-benefits/all-claims/utils/index.jsx on lines 439..441

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

        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