department-of-veterans-affairs/vets-website

View on GitHub
src/applications/gi/containers/search/LocationSearchForm.jsx

Summary

Maintainability
D
1 day
Test Coverage

File LocationSearchForm.jsx has 328 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable react-hooks/exhaustive-deps */
/* eslint-disable react/jsx-no-bind */
/* eslint-disable react/jsx-wrap-multilines */
/* eslint-disable react/prop-types */
import React, { useEffect, useState, createRef } from 'react';
Severity: Minor
Found in src/applications/gi/containers/search/LocationSearchForm.jsx - About 3 hrs to fix

    Function LocationSearchForm has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    export function LocationSearchForm({
      autocomplete,
      dispatchFetchLocationAutocompleteSuggestions,
      dispatchFetchSearchByLocationCoords,
      dispatchFetchSearchByLocationResults,
    Severity: Minor
    Found in src/applications/gi/containers/search/LocationSearchForm.jsx - About 2 hrs 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 doSearch has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const doSearch = event => {
        if (event) {
          event.preventDefault();
          onApplyFilterClick();
          setShowFiltersBeforeSearch(false);
    Severity: Minor
    Found in src/applications/gi/containers/search/LocationSearchForm.jsx - About 1 hr to fix

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

      export function LocationSearchForm({
        autocomplete,
        dispatchFetchLocationAutocompleteSuggestions,
        dispatchFetchSearchByLocationCoords,
        dispatchFetchSearchByLocationResults,
      src/applications/financial-status-report/containers/App.jsx on lines 33..215
      src/applications/gi/components/SearchBenefits.jsx on lines 17..326

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

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

        const distanceDropdownOptions = [
          { optionValue: '5', optionLabel: 'within 5 miles' },
          { optionValue: '15', optionLabel: 'within 15 miles' },
          { optionValue: '25', optionLabel: 'within 25 miles' },
          { optionValue: '50', optionLabel: 'within 50 miles' },
      src/applications/burials-ez/components/NoFormPage.jsx on lines 36..57
      src/applications/discharge-wizard/components/questions/BranchOfService.jsx on lines 27..33
      src/applications/financial-status-report/wizard/pages/Recipients.jsx on lines 11..32
      src/applications/vaos/utils/constants.js on lines 388..409

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

      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

                      onChange={e => {
                        recordEvent({
                          event: 'gibct-form-change',
                          'gibct-form-field': 'locationRadius',
                          'gibct-form-value': e.target.value,
      src/applications/gi/components/SearchBenefits.jsx on lines 267..274

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

      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

        useEffect(
          () => {
            if (focusOnSearch) {
              inputRef.current.focus();
              dispatch({ type: 'RESET_FOCUS' });
      Severity: Minor
      Found in src/applications/gi/containers/search/LocationSearchForm.jsx and 1 other location - About 55 mins to fix
      src/applications/gi/containers/search/NameSearchForm.jsx on lines 97..105

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

      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

      const mapDispatchToProps = {
        dispatchFetchSearchByLocationResults: fetchSearchByLocationResults,
        dispatchFetchLocationAutocompleteSuggestions: fetchLocationAutocompleteSuggestions,
        dispatchFetchSearchByLocationCoords: fetchSearchByLocationCoords,
        dispatchUpdateAutocompleteLocation: updateAutocompleteLocation,
      Severity: Minor
      Found in src/applications/gi/containers/search/LocationSearchForm.jsx and 1 other location - About 40 mins to fix
      src/applications/verify-your-enrollment/reducers/index.js on lines 10..19

      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

                          <div className="use-my-location-link vads-u-display--flex vads-u-align-items--center ">
                            <va-icon size={4} icon="autorenew" aria-hidden="true" />
                            <span aria-live="assertive">
                              Finding your location...
                            </span>
      Severity: Minor
      Found in src/applications/gi/containers/search/LocationSearchForm.jsx and 1 other location - About 30 mins to fix
      src/applications/mhv-medications/components/shared/TrackingInfo.jsx on lines 40..43

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

      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