department-of-veterans-affairs/vets-website

View on GitHub
src/applications/vaos/referral-appointments/components/DateAndTimeContent.jsx

Summary

Maintainability
D
2 days
Test Coverage

Function DateAndTimeContent has 231 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const DateAndTimeContent = props => {
  const { currentReferral, provider, appointmentsByMonth } = props;
  const dispatch = useDispatch();
  const history = useHistory();

    File DateAndTimeContent.jsx has 255 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React, { useCallback, useEffect, useState } from 'react';
    import PropTypes from 'prop-types';
    import { useDispatch, useSelector } from 'react-redux';
    import { useHistory } from 'react-router-dom';
    import { format, addMinutes, isWithinInterval } from 'date-fns';

      Function DateAndTimeContent has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      export const DateAndTimeContent = props => {
        const { currentReferral, provider, appointmentsByMonth } = props;
        const dispatch = useDispatch();
        const history = useHistory();
      
      

      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 hasConflict has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          () => {
            let conflict = false;
            const selectedMonth = format(new Date(selectedDate), 'yyyy-MM');
            if (!(selectedMonth in appointmentsByMonth)) {
              return conflict;

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

          const fullAddress = addressObject => {
            let addressString = addressObject.street1;
            if (addressObject.street2) {
              addressString = `${addressString}, ${addressObject.street2}`;
            }
        src/applications/check-in/components/AddressBlock.jsx on lines 28..40

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

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

        DateAndTimeContent.propTypes = {
          appointmentsByMonth: PropTypes.object.isRequired,
          currentReferral: PropTypes.object.isRequired,
          provider: PropTypes.object.isRequired,
        };
        src/applications/_mock-form-ae-design-patterns/patterns/pattern2/TaskGray/form/components/statuses/Pending.jsx on lines 33..37
        src/applications/claims-status/components/appeals-v2/NextEvent.jsx on lines 12..16
        src/applications/combined-debt-portal/medical-copays/components/DownloadStatement.jsx on lines 62..66
        src/applications/dhp-connected-devices/components/DevicesToConnectSection.jsx on lines 102..106
        src/applications/dhp-connected-devices/components/DisconnectModal.jsx on lines 31..35
        src/applications/discharge-wizard/containers/FormPage.jsx on lines 32..36
        src/applications/financial-status-report/components/householdIncome/SpousePayrollDeductionInputList.jsx on lines 248..252
        src/applications/gi/components/profile/ProfileSection.jsx on lines 12..16
        src/applications/gi/components/profile/Programs.jsx on lines 35..39
        src/applications/gi/components/profile/VeteranProgramsAndSupport.jsx on lines 151..155
        src/applications/gi/components/profile/schoolRatings/RatingHeading.jsx on lines 27..31
        src/applications/gi/components/search/SearchTabs.jsx on lines 76..80
        src/applications/gi/containers/Modals.jsx on lines 1057..1061
        src/applications/lgy/coe/form/components/statuses/Pending.jsx on lines 33..37
        src/applications/my-education-benefits/components/confirmation/UnderReviewChapter1606.jsx on lines 92..96
        src/applications/my-education-benefits/components/confirmation/UnderReviewChapter30.jsx on lines 91..95
        src/applications/personalization/profile/components/connected-apps/AppDeletedAlert.jsx on lines 32..36
        src/applications/representative-search/components/results/PaginationWrapper.jsx on lines 29..33
        src/applications/sco/components/HubRail/shared/liSpanAndVaLinkAndPTag.jsx on lines 11..15
        src/applications/sco/components/HubRail/shared/liVaIconAndVaLink.jsx on lines 10..14
        src/applications/static-pages/events/components/Search/FilterBy.jsx on lines 31..35
        src/applications/vaos/appointment-list/components/PastAppointmentsList/PastAppointmentsDateDropdown.jsx on lines 43..47
        src/applications/vaos/new-appointment/components/CommunityCareProviderSelectionPage/ProviderSelectionField.jsx on lines 71..75
        src/applications/vaos/referral-appointments/components/PendingReferralCard.jsx on lines 82..86

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

        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