department-of-veterans-affairs/vets-website

View on GitHub
src/applications/mhv-medical-records/components/shared/NewRecordsIndicator.jsx

Summary

Maintainability
C
1 day
Test Coverage

Function NewRecordsIndicator has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

const NewRecordsIndicator = ({
  refreshState,
  extractType,
  newRecordsFound,
  reloadFunction,

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

  const content = () => {
    if (refreshedOnThisPage) {
      if (refreshPhase === refreshPhases.FAILED) {
        return failedMsg();
      }

    Function failedMsg has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const failedMsg = () => {
        return (
          <va-alert
            status="warning"
            visible

      Avoid too many return statements within this function.
      Open

          return <></>;

        Avoid too many return statements within this function.
        Open

              return (
                <va-card
                  background
                  aria-live="polite"
                  data-testid="new-records-last-updated"

          Avoid too many return statements within this function.
          Open

                return failedMsg();

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

                    {phase0p5Flag ? (
                      <p>
                        If it still doesn’t work, call us at call us at{' '}
                        <va-telephone contact={CONTACTS.MY_HEALTHEVET} /> (
                        <va-telephone tty contact={CONTACTS['711']} />
            src/applications/mhv-medical-records/components/shared/AccessTroubleAlertBox.jsx on lines 35..46
            src/applications/mhv-medical-records/containers/LandingPage.jsx on lines 412..424

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

            NewRecordsIndicator.propTypes = {
              extractType: PropTypes.string,
              newRecordsFound: PropTypes.bool,
              refreshState: PropTypes.object,
              reloadFunction: PropTypes.func,
            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/accredited-representative-portal/containers/SignedInLayout.jsx on lines 44..49
            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/CategorySelect.jsx on lines 100..105
            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 126..131
            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/combined-debt-portal/debt-letters/components/DebtDetailsOnThisPageLinks.jsx on lines 120..125
            src/applications/combined-debt-portal/debt-letters/components/OnThisPageLinks.jsx on lines 106..111
            src/applications/disability-benefits/all-claims/components/ComboBox.jsx on lines 433..438
            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/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 120..125
            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 195..200
            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 31..36
            src/applications/mhv-secure-messaging/components/SectionGuideButton.jsx on lines 32..37
            src/applications/mhv-secure-messaging/components/shared/AlertBackgroundBox.jsx on lines 179..184
            src/applications/personalization/common/components/devtools/DevToolsLoader.jsx on lines 131..136
            src/applications/personalization/dashboard/components/Dashboard.jsx on lines 178..183
            src/applications/personalization/dashboard/components/benefit-application-drafts/ApplicationsInProgress.jsx on lines 208..213
            src/applications/personalization/dashboard/components/benefit-application-drafts/BenefitApplications.jsx on lines 72..77
            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/resources-and-support/components/SearchBar.jsx on lines 235..240
            src/applications/static-pages/events/components/Results/ResultsWhereContent.jsx on lines 98..103
            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