department-of-veterans-affairs/vets-website

View on GitHub
src/applications/vaos/new-appointment/redux/actions.js

Summary

Maintainability
F
6 days
Test Coverage

File actions.js has 938 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable camelcase */
import moment from 'moment';
import * as Sentry from '@sentry/browser';
import { recordEvent } from '@department-of-veterans-affairs/platform-monitoring/exports';
import { selectVAPResidentialAddress } from '@department-of-veterans-affairs/platform-user/selectors';
Severity: Major
Found in src/applications/vaos/new-appointment/redux/actions.js - About 2 days to fix

    Function submitAppointmentOrRequest has 162 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function submitAppointmentOrRequest(history) {
      return async (dispatch, getState) => {
        const state = getState();
        const featureVAOSServiceVAAppointments = selectFeatureVAOSServiceVAAppointments(
          state,
    Severity: Major
    Found in src/applications/vaos/new-appointment/redux/actions.js - About 6 hrs to fix

      Function getAppointmentSlots has 79 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function getAppointmentSlots(startDate, endDate, forceFetch = false) {
        return async (dispatch, getState) => {
          const state = getState();
          const siteId = getSiteIdFromFacilityId(getFormData(state).vaFacility);
          const newAppointment = getNewAppointment(state);
      Severity: Major
      Found in src/applications/vaos/new-appointment/redux/actions.js - About 3 hrs to fix

        Function openFacilityPageV2 has 73 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function openFacilityPageV2(page, uiSchema, schema) {
          return async (dispatch, getState) => {
            try {
              const initialState = getState();
              const featureFacilitiesServiceV2 = selectFeatureFacilitiesServiceV2(
        Severity: Major
        Found in src/applications/vaos/new-appointment/redux/actions.js - About 2 hrs to fix

          Function routeToPageInFlow has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function routeToPageInFlow(callback, history, current, action, data) {
            return async (dispatch, getState) => {
              const flow = callback(getState());
          
              dispatch({
          Severity: Major
          Found in src/applications/vaos/new-appointment/redux/actions.js - About 2 hrs to fix

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

            export function updateFacilitySortMethod(sortMethod, uiSchema) {
              return async (dispatch, getState) => {
                let location = null;
                const facilities = getTypeOfCareFacilities(getState());
                const cernerSiteIds = selectRegisteredCernerFacilityIds(getState());
            Severity: Major
            Found in src/applications/vaos/new-appointment/redux/actions.js - About 2 hrs to fix

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

              export function requestProvidersList(address) {
                return async (dispatch, getState) => {
                  try {
                    const featureFacilitiesServiceV2 = selectFeatureFacilitiesServiceV2(
                      getState(),
              Severity: Major
              Found in src/applications/vaos/new-appointment/redux/actions.js - About 2 hrs to fix

                Function checkCommunityCareEligibility has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function checkCommunityCareEligibility() {
                  return async (dispatch, getState) => {
                    const state = getState();
                    const communityCareEnabled = selectFeatureCommunityCare(state);
                
                
                Severity: Minor
                Found in src/applications/vaos/new-appointment/redux/actions.js - About 1 hr to fix

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

                  export function updateCCProviderSortMethod(sortMethod, selectedFacility = {}) {
                    return async (dispatch, getState) => {
                      let location = null;
                      const { currentLocation } = getNewAppointment(getState());
                      const action = {
                  Severity: Minor
                  Found in src/applications/vaos/new-appointment/redux/actions.js - About 1 hr to fix

                    Consider simplifying this complex logical expression.
                    Open

                          if (typeOfCareId) {
                            const siteIds = selectSystemIds(initialState);
                            const cernerSiteIds = selectRegisteredCernerFacilityIds(initialState);
                            let typeOfCareFacilities = getTypeOfCareFacilities(initialState);
                            let siteId = null;
                    Severity: Major
                    Found in src/applications/vaos/new-appointment/redux/actions.js - About 40 mins to fix

                      Function routeToPageInFlow has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      export function routeToPageInFlow(callback, history, current, action, data) {
                      Severity: Minor
                      Found in src/applications/vaos/new-appointment/redux/actions.js - About 35 mins to fix

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

                            if (!forceFetch) {
                              fetchedAppointmentSlotMonths = [
                                ...newAppointment.fetchedAppointmentSlotMonths,
                              ];
                        
                        
                        Severity: Major
                        Found in src/applications/vaos/new-appointment/redux/actions.js and 1 other location - About 1 hr to fix
                        src/applications/vaos/covid-19-vaccine/redux/actions.js on lines 276..284

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

                              if (typeof nextAction === 'string') {
                                nextPage = flow[nextAction];
                                nextStateKey = nextAction;
                              } else {
                                nextStateKey = await nextAction(getState(), dispatch);
                        Severity: Major
                        Found in src/applications/vaos/new-appointment/redux/actions.js and 1 other location - About 1 hr to fix
                        src/applications/vaos/covid-19-vaccine/flow.js on lines 111..117

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

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

                              try {
                                location = await getPreciseLocation();
                                recordEvent({
                                  event: `${GA_PREFIX}-request-current-location-allowed`,
                                });
                        Severity: Major
                        Found in src/applications/vaos/new-appointment/redux/actions.js and 2 other locations - About 55 mins to fix
                        src/applications/vaos/covid-19-vaccine/redux/actions.js on lines 235..252
                        src/applications/vaos/new-appointment/redux/actions.js on lines 412..429

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

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

                              try {
                                location = await getPreciseLocation();
                                recordEvent({
                                  event: `${GA_PREFIX}-request-current-location-allowed`,
                                });
                        Severity: Major
                        Found in src/applications/vaos/new-appointment/redux/actions.js and 2 other locations - About 55 mins to fix
                        src/applications/vaos/covid-19-vaccine/redux/actions.js on lines 235..252
                        src/applications/vaos/new-appointment/redux/actions.js on lines 464..487

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

                        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 function openReasonForAppointment(
                          page,
                          uiSchema,
                          schema,
                          useV2 = false,
                        Severity: Minor
                        Found in src/applications/vaos/new-appointment/redux/actions.js and 1 other location - About 40 mins to fix
                        src/applications/vaos/new-appointment/redux/actions.js on lines 521..534

                        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

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

                        export function updateReasonForAppointmentData(
                          page,
                          uiSchema,
                          data,
                          useV2 = false,
                        Severity: Minor
                        Found in src/applications/vaos/new-appointment/redux/actions.js and 1 other location - About 40 mins to fix
                        src/applications/vaos/new-appointment/redux/actions.js on lines 506..519

                        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