department-of-veterans-affairs/vets-website

View on GitHub
src/applications/mhv-medical-records/reducers/careSummariesAndNotes.js

Summary

Maintainability
D
2 days
Test Coverage

Function careSummariesAndNotesReducer has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const careSummariesAndNotesReducer = (state = initialState, action) => {
  switch (action.type) {
    case Actions.CareSummariesAndNotes.GET: {
      return {
        ...state,

    File careSummariesAndNotes.js has 262 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { formatDateLong } from '@department-of-veterans-affairs/platform-utilities/exports';
    import { Actions } from '../util/actionTypes';
    import {
      EMPTY_FIELD,
      loincCodes,

      Function careSummariesAndNotesReducer has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      export const careSummariesAndNotesReducer = (state = initialState, action) => {
        switch (action.type) {
          case Actions.CareSummariesAndNotes.GET: {
            return {
              ...state,

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

      export const convertAdmissionAndDischargeDetails = record => {
        const summary = getNote(record);
      
        const admissionDate = getAdmissionDate(record, summary);
        const dischargeDate = getDischargeDate(record, summary);

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

        export const convertAdmissionAndDischargeDetails = record => {
          const summary = getNote(record);
        
          const admissionDate = getAdmissionDate(record, summary);
          const dischargeDate = getDischargeDate(record, summary);
        Severity: Minor
        Found in src/applications/mhv-medical-records/reducers/careSummariesAndNotes.js - 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

        Avoid too many return statements within this function.
        Open

              return {
                ...state,
                careSummariesAndNotesDetails: undefined,
              };
        Severity: Major
        Found in src/applications/mhv-medical-records/reducers/careSummariesAndNotes.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return {
                  ...state,
                  listState: action.payload,
                };
          Severity: Major
          Found in src/applications/mhv-medical-records/reducers/careSummariesAndNotes.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return {
                    ...state,
                  };
            Severity: Major
            Found in src/applications/mhv-medical-records/reducers/careSummariesAndNotes.js - About 30 mins to fix

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

              export const getDateSigned = record => {
                if (isArrayAndHasItems(record.authenticator?.extension)) {
                  const ext = record.authenticator.extension.find(e => e.valueDateTime);
                  if (ext) {
                    const formattedDate = formatDateLong(ext.valueDateTime);
              Severity: Minor
              Found in src/applications/mhv-medical-records/reducers/careSummariesAndNotes.js - 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

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

                  case Actions.CareSummariesAndNotes.COPY_UPDATED_LIST: {
                    const originalList = state.careSummariesAndNotesList;
                    const { updatedList } = state;
                    if (
                      Array.isArray(originalList) &&
              src/applications/mhv-medical-records/reducers/allergies.js on lines 112..129
              src/applications/mhv-medical-records/reducers/conditions.js on lines 127..144
              src/applications/mhv-medical-records/reducers/labsAndTests.js on lines 447..464
              src/applications/mhv-medical-records/reducers/vaccines.js on lines 152..169
              src/applications/mhv-medical-records/reducers/vitals.js on lines 119..136

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

              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 getAdmissionDate = (record, noteSummary) => {
                let admissionDate = record.context?.period?.start
                  ? new Date(record.context.period.start)
                  : null;
                if (!admissionDate) {
              src/applications/mhv-medical-records/reducers/careSummariesAndNotes.js on lines 146..154

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

              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 getDischargeDate = (record, noteSummary) => {
                let dischargeDate = record.context?.period?.end
                  ? new Date(record.context.period.end)
                  : null;
                if (!dischargeDate) {
              src/applications/mhv-medical-records/reducers/careSummariesAndNotes.js on lines 136..144

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

              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 convertCareSummariesAndNotesRecord = record => {
                const type = getRecordType(record);
                const convertRecord = notesAndSummariesConverterMap[type];
                return convertRecord
                  ? convertRecord(record)
              src/applications/mhv-medical-records/reducers/labsAndTests.js on lines 395..401

              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

                if (admissionDate) {
                  sortByField = dischargeSummarySortFields.ADMISSION_DATE;
                } else if (dischargeDate) {
                  sortByField = dischargeSummarySortFields.DISCHARGE_DATE;
                } else if (dateEntered) {
              src/platform/user/profile/vap-svc/selectors.js on lines 141..147

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

              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

              const initialState = {
                /**
                 * The last time that the list was fetched and known to be up-to-date
                 * @type {Date}
                 */
              src/applications/mhv-medical-records/reducers/allergies.js on lines 10..34
              src/applications/mhv-medical-records/reducers/labsAndTests.js on lines 21..46
              src/applications/mhv-medical-records/reducers/vitals.js on lines 17..42

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

              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