department-of-veterans-affairs/vets-website

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

Summary

Maintainability
C
1 day
Test Coverage

Function Vitals has 136 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const Vitals = () => {
  const dispatch = useDispatch();
  const updatedRecordList = useSelector(state => state.mr.vitals.updatedList);
  const listState = useSelector(state => state.mr.vitals.listState);
  const vitals = useSelector(state => state.mr.vitals.vitalsList);
Severity: Major
Found in src/applications/mhv-medical-records/containers/Vitals.jsx - About 5 hrs to fix

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

      const content = () => {
        if (accessAlert) {
          return (
            <AccessTroubleAlertBox
              alertType={accessAlertTypes.VITALS}
    Severity: Major
    Found in src/applications/mhv-medical-records/containers/Vitals.jsx - About 2 hrs to fix

      Function Vitals has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      const Vitals = () => {
        const dispatch = useDispatch();
        const updatedRecordList = useSelector(state => state.mr.vitals.updatedList);
        const listState = useSelector(state => state.mr.vitals.listState);
        const vitals = useSelector(state => state.mr.vitals.vitalsList);
      Severity: Minor
      Found in src/applications/mhv-medical-records/containers/Vitals.jsx - About 1 hr 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

      Avoid too many return statements within this function.
      Open

          return (
            <div className="vads-u-margin-y--8">
              <va-loading-indicator
                message="We’re loading your records. This could take up to a minute."
                setFocus
      Severity: Major
      Found in src/applications/mhv-medical-records/containers/Vitals.jsx - About 30 mins to fix

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

            if (refresh.initialFhirLoad && !vitalsCurrentAsOf) {
              return (
                <div className="vads-u-margin-y--8">
                  <va-loading-indicator
                    class="hydrated initial-fhir-load"
        Severity: Minor
        Found in src/applications/mhv-medical-records/containers/Vitals.jsx and 1 other location - About 40 mins to fix
        src/applications/mhv-medical-records/components/shared/RecordListSection.jsx on lines 23..34

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

          useListRefresh({
            listState,
            listCurrentAsOf: vitalsCurrentAsOf,
            refreshStatus: refresh.status,
            extractType: refreshExtractTypes.VPR,
        Severity: Major
        Found in src/applications/mhv-medical-records/containers/Vitals.jsx and 6 other locations - About 35 mins to fix
        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/VitalDetails.jsx on lines 83..90

        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