department-of-veterans-affairs/vets-website

View on GitHub
src/applications/mhv-medical-records/containers/VitalDetails.jsx

Summary

Maintainability
F
4 days
Test Coverage

Function VitalDetails has 319 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const VitalDetails = props => {
  const { runningUnitTest } = props;
  const records = useSelector(state => state.mr.vitals.vitalDetails);
  const vitalsList = useSelector(state => state.mr.vitals.vitalsList);
  const user = useSelector(state => state.user.profile);
Severity: Major
Found in src/applications/mhv-medical-records/containers/VitalDetails.jsx - About 1 day to fix

    File VitalDetails.jsx has 376 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React, { useEffect, useState, useRef, useMemo } from 'react';
    import PropTypes from 'prop-types';
    import { useDispatch, useSelector } from 'react-redux';
    import { useParams } from 'react-router-dom';
    import { chunk } from 'lodash';
    Severity: Minor
    Found in src/applications/mhv-medical-records/containers/VitalDetails.jsx - About 5 hrs to fix

      Consider simplifying this complex logical expression.
      Open

        if (records?.length) {
          const vitalDisplayName = vitalTypeDisplayNames[records[0].type];
          return (
            <>
              <PrintHeader />
      Severity: Major
      Found in src/applications/mhv-medical-records/containers/VitalDetails.jsx - About 40 mins to fix

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

          const generateVitalsPdf = async () => {
            setDownloadStarted(true);
        
            const { title, subject, preface } = generateVitalsIntro(
              records,
        src/applications/mhv-medical-records/containers/Vaccines.jsx on lines 108..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 109.

        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

                <div className="vads-u-margin-bottom--2 no-print">
                  <VaPagination
                    onPageSelect={e => onPageChange(e.detail.page)}
                    page={currentPage}
                    pages={paginatedVitals.current.length}
        src/applications/mhv-medical-records/components/RecordList/RecordList.jsx on lines 101..110

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

        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

          useEffect(
            () => {
              if (currentPage > 1 && records?.length) {
                focusElement(document.querySelector('#showingRecords'));
                window.scrollTo({
        src/applications/mhv-medical-records/components/RecordList/RecordList.jsx on lines 59..67

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

        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

                        <div className="vads-u-margin-bottom--0p5 vads-u-margin-left--1p5">
                          <h4 className="vads-u-display--inline vads-u-font-size--base vads-u-font-family--sans">
                            Location:{' '}
                          </h4>
                          <p className="vads-u-display--inline" data-dd-privacy="mask">
        src/applications/mhv-medical-records/containers/VitalDetails.jsx on lines 353..360
        src/applications/mhv-medical-records/containers/VitalDetails.jsx on lines 369..376

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

        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

                        <div className="vads-u-margin-bottom--0p5 vads-u-margin-left--1p5">
                          <h4 className="vads-u-display--inline vads-u-font-size--base vads-u-font-family--sans">
                            Measurement:{' '}
                          </h4>
                          <p className="vads-u-display--inline" data-dd-privacy="mask">
        src/applications/mhv-medical-records/containers/VitalDetails.jsx on lines 361..368
        src/applications/mhv-medical-records/containers/VitalDetails.jsx on lines 369..376

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

        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

                        <div className="vads-u-margin-left--1p5">
                          <h4 className="vads-u-display--inline vads-u-font-size--base vads-u-font-family--sans">
                            Provider notes:{' '}
                          </h4>
                          <p className="vads-u-display--inline" data-dd-privacy="mask">
        src/applications/mhv-medical-records/containers/VitalDetails.jsx on lines 353..360
        src/applications/mhv-medical-records/containers/VitalDetails.jsx on lines 361..368

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

        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

          const fromToNums = (page, total) => {
            const from = (page - 1) * perPage + 1;
            const to = Math.min(page * perPage, total);
            return [from, to];
          };
        src/applications/disability-benefits/view-payments/components/view-payments-lists/payments/Payments.jsx on lines 15..20
        src/applications/mhv-medical-records/components/RecordList/RecordList.jsx on lines 43..47

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

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

          useListRefresh({
            listState,
            listCurrentAsOf: vitalsCurrentAsOf,
            refreshStatus: refresh.status,
            extractType: refreshExtractTypes.VPR,
        src/applications/mhv-medical-records/containers/Allergies.jsx on lines 66..73
        src/applications/mhv-medical-records/containers/CareSummariesAndNotes.jsx on lines 39..46
        src/applications/mhv-medical-records/containers/HealthConditions.jsx on lines 32..39
        src/applications/mhv-medical-records/containers/LabsAndTests.jsx on lines 34..41
        src/applications/mhv-medical-records/containers/Vaccines.jsx on lines 66..73
        src/applications/mhv-medical-records/containers/Vitals.jsx on lines 38..45

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

        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