department-of-veterans-affairs/vets-website

View on GitHub
src/applications/personalization/dashboard/components/Dashboard.jsx

Summary

Maintainability
D
2 days
Test Coverage

File Dashboard.jsx has 451 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { connect, useDispatch, useSelector } from 'react-redux';
import isEmpty from 'lodash/isEmpty';

Severity: Minor
Found in src/applications/personalization/dashboard/components/Dashboard.jsx - About 6 hrs to fix

    Function mapStateToProps has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const mapStateToProps = state => {
      const { isReady: hasLoadedScheduledDowntime } = state.scheduledDowntime;
      const isLOA3 = isLOA3Selector(state);
      const isLOA1 = isLOA1Selector(state);
      const isVAPatient = isVAPatientSelector(state);
    Severity: Major
    Found in src/applications/personalization/dashboard/components/Dashboard.jsx - About 2 hrs to fix

      Function mapStateToProps has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      const mapStateToProps = state => {
        const { isReady: hasLoadedScheduledDowntime } = state.scheduledDowntime;
        const isLOA3 = isLOA3Selector(state);
        const isLOA1 = isLOA1Selector(state);
        const isVAPatient = isVAPatientSelector(state);
      Severity: Minor
      Found in src/applications/personalization/dashboard/components/Dashboard.jsx - About 35 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

        payments: PropTypes.arrayOf(
          PropTypes.shape({
            payCheckAmount: PropTypes.string.isRequired,
            payCheckDt: PropTypes.string.isRequired,
            payCheckId: PropTypes.string.isRequired,
      src/applications/personalization/dashboard/components/benefit-payments/BenefitPayments.jsx on lines 144..155

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

      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

            <CTALink
              href="/profile"
              text="Go to your profile"
              className="vads-u-margin-top--2"
              onClick={() => {
      src/applications/personalization/dashboard/components/claims-and-appeals/ClaimsAndAppeals.jsx on lines 80..91

      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

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

      LOA1Content.propTypes = {
        dismissWelcomeModal: PropTypes.func,
        isLOA1: PropTypes.bool,
        isVAPatient: PropTypes.bool,
        welcomeModalVisible: PropTypes.bool,
      src/applications/_mock-form-ae-design-patterns/patterns/pattern1/ezr/components/DependentList.jsx on lines 185..190
      src/applications/_mock-form-ae-design-patterns/patterns/pattern1/ezr/components/InsurancePolicyList.jsx on lines 172..177
      src/applications/appeals/testing/nod-new/components/EditContactInfo.jsx on lines 38..43
      src/applications/ask-va/components/CustomYourQuestionReviewField.jsx on lines 76..81
      src/applications/ask-va/components/FormFields/CountrySelect.jsx on lines 32..37
      src/applications/ask-va/components/PageFieldSummary.jsx on lines 62..67
      src/applications/ask-va/containers/CategorySelectPage.jsx on lines 134..139
      src/applications/ask-va/containers/WhoIsYourQuestionAboutCustomPage.jsx on lines 123..128
      src/applications/avs/components/ParagraphBlock.jsx on lines 38..43
      src/applications/caregivers/components/FormPages/FacilityConfirmation.jsx on lines 81..86
      src/applications/claims-status/components/IndexLink.jsx on lines 25..30
      src/applications/claims-status/containers/ClaimsStatusApp.jsx on lines 100..105
      src/applications/claims-status/containers/StemClaimStatusPage.jsx on lines 105..110
      src/applications/combined-debt-portal/combined/components/BalanceCard.jsx on lines 55..60
      src/applications/disability-benefits/all-claims/components/ComboBox.jsx on lines 447..452
      src/applications/edu-benefits/10203/containers/IntroductionPage.jsx on lines 252..257
      src/applications/ezr/components/FormFields/DependentList.jsx on lines 185..190
      src/applications/ezr/components/FormFields/InsurancePolicyList.jsx on lines 172..177
      src/applications/ezr/components/FormPages/FinancialStatusConfirmation.jsx on lines 42..47
      src/applications/facility-locator/components/search-results-items/common/LocationPhoneLink.jsx on lines 92..97
      src/applications/financial-status-report/components/contactInfo/EditContactInfo.jsx on lines 66..71
      src/applications/financial-status-report/components/householdIncome/SpouseTransitionExplainer.jsx on lines 26..31
      src/applications/financial-status-report/components/shared/PreSubmitSignature.jsx on lines 261..266
      src/applications/financial-status-report/components/shared/StreamlinedExplainer.jsx on lines 24..29
      src/applications/gi/components/VaAccordionGi.jsx on lines 27..32
      src/applications/gi/components/vet-tec/VetTecEstimateYourBenefitsForm.jsx on lines 238..243
      src/applications/hca/components/FormFields/DependentList.jsx on lines 175..180
      src/applications/hca/components/FormPages/FinancialInformation.jsx on lines 71..76
      src/applications/hca/components/FormPages/FinancialOnboarding.jsx on lines 73..78
      src/applications/hca/components/FormPages/InsuranceInformation.jsx on lines 63..68
      src/applications/hca/components/IdentityPage/VerificationForm.jsx on lines 62..67
      src/applications/ivc-champva/shared/components/maskSSN.jsx on lines 67..72
      src/applications/mhv-landing-page/components/HeaderLayout.jsx on lines 168..173
      src/applications/mhv-landing-page/components/alerts/AlertMhvBasicAccount.jsx on lines 102..107
      src/applications/mhv-landing-page/components/alerts/AlertMhvRegistration.jsx on lines 64..69
      src/applications/mhv-medical-records/components/RecordList/RecordList.jsx on lines 121..126
      src/applications/mhv-medical-records/components/shared/NewRecordsIndicator.jsx on lines 197..202
      src/applications/mhv-medical-records/components/shared/PrintDownload.jsx on lines 135..140
      src/applications/mhv-medications/components/shared/AllergiesErrorModal.jsx on lines 45..50
      src/applications/mhv-medications/components/shared/TrackingInfo.jsx on lines 88..93
      src/applications/mhv-secure-messaging/components/ComposeForm/FileInput.jsx on lines 197..202
      src/applications/mhv-secure-messaging/components/MessageActionButtons/TrashButton.jsx on lines 93..98
      src/applications/mhv-secure-messaging/components/MessageThread/MessageThreadBody.jsx on lines 31..36
      src/applications/mhv-secure-messaging/components/Modals/DeleteMessageModal.jsx on lines 35..40
      src/applications/mhv-secure-messaging/components/SectionGuideButton.jsx on lines 32..37
      src/applications/mhv-secure-messaging/components/shared/AlertBackgroundBox.jsx on lines 180..185
      src/applications/personalization/common/components/devtools/DevToolsLoader.jsx on lines 131..136
      src/applications/personalization/profile/components/direct-deposit/vye/components/AlertModal.jsx on lines 30..35
      src/applications/representative-appoint/components/ClaimantTypeForm.jsx on lines 33..38
      src/applications/representative-appoint/components/ContactAccreditedRepresentative.jsx on lines 124..129
      src/applications/representative-appoint/containers/PreSubmitInfo.jsx on lines 138..143
      src/applications/resources-and-support/components/SearchBar.jsx on lines 236..241
      src/applications/search/components/ResultsList.jsx on lines 58..63
      src/applications/static-pages/events/components/Results/ResultsWhereContent.jsx on lines 98..103
      src/applications/vaos/components/layout/DetailPageLayout.jsx on lines 136..141
      src/applications/vaos/new-appointment/components/ReviewPage/ReviewRequestInfo/ReviewDirectScheduleInfo/ReviewDirectScheduleInfo.jsx on lines 40..45
      src/applications/vaos/new-appointment/components/VAFacilityPage/FacilitiesNotShown.jsx on lines 110..115
      src/applications/verify-your-enrollment/components/Alert.jsx on lines 24..29
      src/applications/verify-your-enrollment/components/AlertModal.jsx on lines 29..34
      src/applications/verify-your-enrollment/components/EnrollmentStatus.jsx on lines 28..33
      src/platform/forms-system/src/js/review/submit-states/ClientError.jsx on lines 65..70
      src/platform/forms-system/src/js/review/submit-states/Default.jsx on lines 39..44
      src/platform/forms-system/src/js/review/submit-states/GenericError.jsx on lines 67..72
      src/platform/mhv/downtime/components/MHVDown.jsx on lines 44..49
      src/platform/mhv/downtime/components/MHVDowntimeApproaching.jsx on lines 34..39
      src/platform/user/authentication/components/CreateAccountLink.jsx on lines 56..61
      src/platform/user/authentication/components/VerifyAccountLink.jsx on lines 45..50
      src/applications/check-in/components/BackButton.jsx on lines 59..64
      src/applications/static-pages/facilities/FacilityMapWidgetDynamic.jsx on lines 124..129

      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