department-of-veterans-affairs/vets-website

View on GitHub
src/applications/gi/actions/index.js

Summary

Maintainability
F
4 days
Test Coverage

File index.js has 489 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import appendQuery from 'append-query';

import { fetchAndUpdateSessionExpiration as fetch } from 'platform/utilities/api';
import mbxGeo from '@mapbox/mapbox-sdk/services/geocoding';
import { api } from '../config';
Severity: Minor
Found in src/applications/gi/actions/index.js - About 7 hrs to fix

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

    export function fetchSearchByLocationCoords(
      location,
      coordinates,
      distance,
      filters,
    Severity: Minor
    Found in src/applications/gi/actions/index.js - About 1 hr to fix

      Function beneficiaryZIPCodeChanged has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function beneficiaryZIPCodeChanged(beneficiaryZIP) {
        // pass input through to reducers if not five digits
        if (!beneficiaryZIPRegExTester.exec(beneficiaryZIP)) {
          return {
            type: BENEFICIARY_ZIP_CODE_CHANGED,
      Severity: Minor
      Found in src/applications/gi/actions/index.js - About 1 hr to fix

        Function fetchSearchByLocationResults has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function fetchSearchByLocationResults(
          location,
          distance,
          filters,
          version,
        Severity: Minor
        Found in src/applications/gi/actions/index.js - About 1 hr to fix

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

          export function fetchCompareDetails(facilityCodes, filters, version) {
            const params = rubyifyKeys({
              facilityCodes,
              ...buildSearchFilters(filters),
            });
          Severity: Minor
          Found in src/applications/gi/actions/index.js - About 1 hr to fix

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

            export function fetchProfile(facilityCode, version) {
              const queryString = version ? `?version=${version}` : '';
              const url = `${api.url}/institutions/${facilityCode}${queryString}`;
            
              return (dispatch, getState) => {
            Severity: Minor
            Found in src/applications/gi/actions/index.js - About 1 hr to fix

              Function fetchSearchByNameResults has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function fetchSearchByNameResults(name, page, filters, version) {
                const params = { name, page, ...rubyifyKeys(buildSearchFilters(filters)) };
                if (version) {
                  params.version = version;
                }
              Severity: Minor
              Found in src/applications/gi/actions/index.js - About 1 hr to fix

                Function fetchNameAutocompleteSuggestions has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function fetchNameAutocompleteSuggestions(name, filterFields, version) {
                  if (name === '' || name === null || name === undefined) {
                    return { type: NAME_AUTOCOMPLETE_SUCCEEDED, payload: [] };
                  }
                
                
                Severity: Minor
                Found in src/applications/gi/actions/index.js - About 1 hr to fix

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

                    location,
                    coordinates,
                    distance,
                    filters,
                    version,
                  Severity: Minor
                  Found in src/applications/gi/actions/index.js - About 35 mins to fix

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

                        return fetch(url, api.settings)
                          .then(res => {
                            if (res.ok) {
                              return res.json();
                            }
                    Severity: Major
                    Found in src/applications/gi/actions/index.js and 1 other location - About 4 hrs to fix
                    src/applications/gi/actions/index.js on lines 142..157

                    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

                        return fetch(url, api.settings)
                          .then(res => {
                            if (res.ok) {
                              return res.json();
                            }
                    Severity: Major
                    Found in src/applications/gi/actions/index.js and 1 other location - About 4 hrs to fix
                    src/applications/gi/actions/index.js on lines 244..263

                    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

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

                        fetch(url, api.settings)
                          .then(res => {
                            if (res.ok) {
                              return res.json();
                            }
                    Severity: Major
                    Found in src/applications/gi/actions/index.js and 1 other location - About 3 hrs to fix
                    src/applications/gi/actions/index.js on lines 300..312

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

                    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

                        fetch(url, api.settings)
                          .then(res => {
                            if (res.ok) {
                              return res.json();
                            }
                    Severity: Major
                    Found in src/applications/gi/actions/index.js and 1 other location - About 3 hrs to fix
                    src/applications/gi/actions/index.js on lines 190..206

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

                    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