department-of-veterans-affairs/vets-website

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

Summary

Maintainability
F
5 days
Test Coverage

Function convertDemographics has 107 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const convertDemographics = info => {
  if (!info) return null;

  return {
    id: info.id,
Severity: Major
Found in src/applications/mhv-medical-records/reducers/blueButton.js - About 4 hrs to fix

    File blueButton.js has 299 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { formatDateLong } from '@department-of-veterans-affairs/platform-utilities/exports';
    import { pharmacyPhoneNumber } from '@department-of-veterans-affairs/mhv/exports';
    import { format, isAfter } from 'date-fns';
    import { capitalize } from 'lodash';
    import { Actions } from '../util/actionTypes';
    Severity: Minor
    Found in src/applications/mhv-medical-records/reducers/blueButton.js - About 3 hrs to fix

      Function blueButtonReducer has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const blueButtonReducer = (state = initialState, action) => {
        switch (action.type) {
          case Actions.BlueButtonReport.GET: {
            const updates = {};
      
      
      Severity: Major
      Found in src/applications/mhv-medical-records/reducers/blueButton.js - About 2 hrs to fix

        Function convertAppointment has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const convertAppointment = appt => {
          if (!appt) return null;
        
          const now = new Date();
          const { attributes } = appt;
        Severity: Minor
        Found in src/applications/mhv-medical-records/reducers/blueButton.js - About 1 hr to fix

          Function blueButtonReducer has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          export const blueButtonReducer = (state = initialState, action) => {
            switch (action.type) {
              case Actions.BlueButtonReport.GET: {
                const updates = {};
          
          
          Severity: Minor
          Found in src/applications/mhv-medical-records/reducers/blueButton.js - 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

          Function convertAccountSummary has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const convertAccountSummary = data => {
            if (!data) return null;
          
            // Extract necessary fields
            const { facilities = [], ipas } = data;
          Severity: Minor
          Found in src/applications/mhv-medical-records/reducers/blueButton.js - About 1 hr to fix

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

            export const convertMedication = med => {
              if (!med) return null;
              if (med.dispStatus?.toLowerCase()?.includes('non-va'))
                return convertNonVaMedication(med);
            
            
            Severity: Minor
            Found in src/applications/mhv-medical-records/reducers/blueButton.js - About 1 hr to fix

              Function convertAccountSummary has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              export const convertAccountSummary = data => {
                if (!data) return null;
              
                // Extract necessary fields
                const { facilities = [], ipas } = data;
              Severity: Minor
              Found in src/applications/mhv-medical-records/reducers/blueButton.js - About 45 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

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

              export const convertMedication = med => {
                if (!med) return null;
                if (med.dispStatus?.toLowerCase()?.includes('non-va'))
                  return convertNonVaMedication(med);
              
              
              Severity: Minor
              Found in src/applications/mhv-medical-records/reducers/blueButton.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

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

              export const convertAppointment = appt => {
                if (!appt) return null;
              
                const now = new Date();
                const { attributes } = appt;
              Severity: Minor
              Found in src/applications/mhv-medical-records/reducers/blueButton.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 2 locations. Consider refactoring.
              Open

                  civilGuardian: {
                    name: info.civilGuardianName || NONE_RECORDED,
                    address: {
                      street:
                        [info.civilGuardianStreet1, info.civilGuardianStreet2]
              Severity: Major
              Found in src/applications/mhv-medical-records/reducers/blueButton.js and 1 other location - About 4 hrs to fix
              src/applications/mhv-medical-records/reducers/blueButton.js on lines 218..231

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

              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

                  vaGuardian: {
                    name: info.vaGuardianName || NONE_RECORDED,
                    address: {
                      street:
                        [info.vaGuardianStreet1, info.vaGuardianStreet2]
              Severity: Major
              Found in src/applications/mhv-medical-records/reducers/blueButton.js and 1 other location - About 4 hrs to fix
              src/applications/mhv-medical-records/reducers/blueButton.js on lines 233..246

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

              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

                  emergencyContact: {
                    name: info.emergencyName || NONE_RECORDED,
                    address: {
                      street:
                        [info.emergencyStreet1, info.emergencyStreet2]
              Severity: Major
              Found in src/applications/mhv-medical-records/reducers/blueButton.js and 1 other location - About 4 hrs to fix
              src/applications/mhv-medical-records/reducers/blueButton.js on lines 189..202

              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

                  primaryNextOfKin: {
                    name: info.nextOfKinName || NONE_RECORDED,
                    address: {
                      street:
                        [info.nextOfKinStreet1, info.nextOfKinStreet2]
              Severity: Major
              Found in src/applications/mhv-medical-records/reducers/blueButton.js and 1 other location - About 4 hrs to fix
              src/applications/mhv-medical-records/reducers/blueButton.js on lines 203..216

              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

                  case Actions.BlueButtonReport.ADD_FAILED: {
                    const failedDomain = action.payload;
              
                    return {
                      ...state,
              Severity: Major
              Found in src/applications/mhv-medical-records/reducers/blueButton.js and 1 other location - About 1 hr to fix
              src/applications/mhv-medical-records/reducers/selfEnteredData.js on lines 883..892

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

              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

                    if (action.appointmentsResponse) {
                      updates.appointmentsList =
                        action.appointmentsResponse.data?.map(appt => {
                          return convertAppointment(appt);
                        }) || [];
              src/applications/mhv-medical-records/reducers/blueButton.js on lines 312..317
              src/applications/mhv-medical-records/reducers/blueButton.js on lines 326..331

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

                    if (action.medicationsResponse) {
                      updates.medicationsList =
                        action.medicationsResponse.data?.map(med => {
                          return convertMedication(med);
                        }) || [];
              src/applications/mhv-medical-records/reducers/blueButton.js on lines 319..324
              src/applications/mhv-medical-records/reducers/blueButton.js on lines 326..331

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

                    if (action.demographicsResponse) {
                      updates.demographics =
                        action.demographicsResponse.content?.map(item => {
                          return convertDemographics(item);
                        }) || [];
              src/applications/mhv-medical-records/reducers/blueButton.js on lines 312..317
              src/applications/mhv-medical-records/reducers/blueButton.js on lines 319..324

              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

              There are no issues that match your filters.

              Category
              Status