department-of-veterans-affairs/vets-website

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

Summary

Maintainability
F
4 days
Test Coverage

File LocationSearchResults.jsx has 693 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable react/jsx-no-bind */
/* eslint-disable react-hooks/exhaustive-deps */
/* eslint-disable react/prop-types */
/* eslint-disable jsx-a11y/no-noninteractive-tabindex */

Severity: Major
Found in src/applications/gi/containers/search/LocationSearchResults.jsx - About 1 day to fix

    Function LocationSearchResults has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

    function LocationSearchResults({
      search,
      filters,
      preview,
      dispatchUpdateEligibilityAndFilters,
    Severity: Minor
    Found in src/applications/gi/containers/search/LocationSearchResults.jsx - About 5 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

    Consider simplifying this complex logical expression.
    Open

        if (showTuitionAndFilters) {
          return (
            <>
              {!smallScreen && (
                <>
    Severity: Critical
    Found in src/applications/gi/containers/search/LocationSearchResults.jsx - About 1 hr to fix

      Function resultCards has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          (institution, index) => {
            const { distance, name } = institution;
            const miles = Number.parseFloat(distance).toFixed(2);
            const { currentPage } = pagination;
      
      
      Severity: Minor
      Found in src/applications/gi/containers/search/LocationSearchResults.jsx - About 1 hr to fix

        Function noResultsFound has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          const noResultsFound = cnt => {
            const noResultsNoFilters = cnt === 0 && !usedFilters;
            const noResultsWithFilters = cnt === 0 && usedFilters;
        
            return (
        Severity: Minor
        Found in src/applications/gi/containers/search/LocationSearchResults.jsx - About 1 hr to fix

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

            const mapElement = (visible = true) => {
              const containerClassNames = classNames({
                'vads-u-display--none': !visible,
              });
              const isMobileDevice = smallScreen || landscape;
          Severity: Minor
          Found in src/applications/gi/containers/search/LocationSearchResults.jsx - About 1 hr to fix

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

              const setupMap = () => {
                if (map.current) return; // initialize map only once
                const container = document.getElementById('mapbox-gl-container');
                if (!container) return;
            
            
            Severity: Minor
            Found in src/applications/gi/containers/search/LocationSearchResults.jsx - About 1 hr to fix

              Function searchResults has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                const searchResults = (cnt, visible = true) => {
                  if (cnt > 0) {
                    const containerClassNames = classNames(
                      'location-search-results-container',
                      'usa-grid',
              Severity: Minor
              Found in src/applications/gi/containers/search/LocationSearchResults.jsx - About 1 hr to fix

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

                  const addMapMarker = (institution, index, locationBounds, mapMarkers) => {
                    const { latitude, longitude, name } = institution;
                    const lngLat = new mapboxgl.LngLat(longitude, latitude);
                
                    const markerElement = document.createElement('div');
                Severity: Minor
                Found in src/applications/gi/containers/search/LocationSearchResults.jsx - About 1 hr to fix

                  Function getTab has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    const getTab = tabName => {
                      const activeTab = tabName === mobileTab;
                      const tabClasses = classNames(
                        {
                          'active-results-tab': activeTab,
                  Severity: Minor
                  Found in src/applications/gi/containers/search/LocationSearchResults.jsx - About 1 hr to fix

                    Function eligibilityAndFilters has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      const eligibilityAndFilters = cnt => {
                        const showTuitionAndFilters = cnt > 0 || usedFilters;
                    
                        if (showTuitionAndFilters) {
                          return (
                    Severity: Minor
                    Found in src/applications/gi/containers/search/LocationSearchResults.jsx - About 1 hr to fix

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

                      LocationSearchResults.propTypes = {
                        dispatchFetchSearchByLocationCoords: PropTypes.func,
                        dispatchMapChanged: PropTypes.func,
                        dispatchUpdateEligibilityAndFilters: PropTypes.func,
                        filters: PropTypes.object,
                      src/applications/_mock-form-ae-design-patterns/patterns/pattern1/TaskPurple/EditContactInfo.jsx on lines 112..121
                      src/applications/education-letters/containers/InboxPage.jsx on lines 102..111
                      src/applications/mhv-secure-messaging/components/Search/FilterBox.jsx on lines 165..174
                      src/applications/mhv-secure-messaging/components/ThreadList/ThreadsList.jsx on lines 116..125
                      src/applications/personalization/dashboard/components/CTALink.jsx on lines 43..52
                      src/applications/personalization/view-dependents/layouts/ViewDependentsLayout.jsx on lines 72..81
                      src/applications/personalization/view-dependents/manage-dependents/containers/ManageDependentsApp.jsx on lines 148..157
                      src/applications/toe/containers/SponsorsSelectionPage.jsx on lines 98..107
                      src/applications/travel-pay/components/TravelPayClaimFilters.jsx on lines 58..67
                      src/platform/forms/components/review/FormSaveErrorMessage.jsx on lines 129..138

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

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

                                  <ul>
                                    <li>
                                      <strong>Zoom in or out</strong> to view a different area of the
                                      map, or
                                    </li>
                      src/applications/hca/components/FormDescriptions/HealthEnrollmentDescription.jsx on lines 34..46
                      src/applications/hca/components/IntroductionPage/GetStarted/ProcessTimeline.jsx on lines 83..94
                      src/applications/ivc-champva/10-10D/components/Applicant/applicantFileUpload.js on lines 562..570
                      src/applications/ivc-champva/10-10D/containers/IntroductionPage.jsx on lines 65..74
                      src/applications/ivc-champva/10-7959C/containers/IntroductionPage.jsx on lines 37..50
                      src/applications/ivc-champva/10-7959f-2/components/PaymentSelection.jsx on lines 10..21
                      src/applications/mhv-secure-messaging/components/Alerts/CernerTransitioningFacilityAlert.jsx on lines 69..79
                      src/applications/static-pages/health-care-manage-benefits/refill-track-prescriptions-page/components/AuthContent/index.js on lines 170..177
                      src/applications/static-pages/health-care-manage-benefits/view-test-and-lab-results-page/components/AuthContent/index.js on lines 184..196
                      src/applications/static-pages/health-care-manage-benefits/view-test-and-lab-results-page/components/UnauthContent/index.js on lines 79..90

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

                      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