department-of-veterans-affairs/vets-website

View on GitHub
src/applications/representative-appoint/components/SearchResultsHeader.jsx

Summary

Maintainability
A
2 hrs
Test Coverage

Function SearchResultsHeader has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const SearchResultsHeader = props => {
  const { query, resultCount, inProgress } = props;

  const searchWasPerformed = !!query;

    Function SearchResultsHeader has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    export const SearchResultsHeader = props => {
      const { query, resultCount, inProgress } = props;
    
      const searchWasPerformed = !!query;
    
    

    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

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

    SearchResultsHeader.propTypes = {
      inProgress: PropTypes.bool,
      query: PropTypes.string,
      resultCount: PropTypes.number,
      searchWasPerformed: PropTypes.bool,
    src/applications/_mock-form-ae-design-patterns/patterns/pattern1/ezr/components/DependentList.jsx on lines 185..190
    src/applications/_mock-form-ae-design-patterns/patterns/pattern1/ezr/components/InsurancePolicyList.jsx on lines 172..177
    src/applications/accredited-representative-portal/containers/SignedInLayout.jsx on lines 44..49
    src/applications/appeals/testing/nod-new/components/EditContactInfo.jsx on lines 38..43
    src/applications/ask-va/components/CustomYourQuestionReviewField.jsx on lines 76..81
    src/applications/ask-va/components/FormFields/CountrySelect.jsx on lines 32..37
    src/applications/ask-va/components/PageFieldSummary.jsx on lines 62..67
    src/applications/ask-va/components/RequireSignInModal.jsx on lines 66..71
    src/applications/avs/components/ParagraphBlock.jsx on lines 38..43
    src/applications/caregivers/components/FormPages/FacilityConfirmation.jsx on lines 84..89
    src/applications/claims-status/components/IndexLink.jsx on lines 25..30
    src/applications/claims-status/containers/ClaimsStatusApp.jsx on lines 100..105
    src/applications/claims-status/containers/StemClaimStatusPage.jsx on lines 105..110
    src/applications/combined-debt-portal/combined/components/BalanceCard.jsx on lines 55..60
    src/applications/disability-benefits/all-claims/components/ComboBox.jsx on lines 450..455
    src/applications/edu-benefits/10203/containers/IntroductionPage.jsx on lines 256..261
    src/applications/ezr/components/FormFields/DependentList.jsx on lines 185..190
    src/applications/ezr/components/FormFields/InsurancePolicyList.jsx on lines 172..177
    src/applications/ezr/components/FormPages/FinancialStatusConfirmation.jsx on lines 42..47
    src/applications/facility-locator/components/search-results-items/common/LocationPhoneLink.jsx on lines 103..108
    src/applications/financial-status-report/components/contactInfo/EditContactInfo.jsx on lines 66..71
    src/applications/financial-status-report/components/householdIncome/SpouseTransitionExplainer.jsx on lines 26..31
    src/applications/financial-status-report/components/shared/PreSubmitSignature.jsx on lines 261..266
    src/applications/financial-status-report/components/shared/StreamlinedExplainer.jsx on lines 24..29
    src/applications/gi/components/VaAccordionGi.jsx on lines 27..32
    src/applications/gi/components/vet-tec/VetTecEstimateYourBenefitsForm.jsx on lines 238..243
    src/applications/hca/components/FormFields/DependentList.jsx on lines 177..182
    src/applications/hca/components/FormPages/FinancialInformation.jsx on lines 71..76
    src/applications/hca/components/FormPages/FinancialOnboarding.jsx on lines 73..78
    src/applications/hca/components/FormPages/InsuranceInformation.jsx on lines 63..68
    src/applications/hca/components/IdentityPage/VerificationForm.jsx on lines 61..66
    src/applications/ivc-champva/shared/components/maskSSN.jsx on lines 67..72
    src/applications/mhv-landing-page/components/HeaderLayout.jsx on lines 168..173
    src/applications/mhv-landing-page/components/alerts/AlertMhvRegistration.jsx on lines 64..69
    src/applications/mhv-medications/components/MedicationsList/MedicationsListFilter.jsx on lines 151..156
    src/applications/mhv-medications/components/shared/AllergiesErrorModal.jsx on lines 45..50
    src/applications/mhv-medications/components/shared/TrackingInfo.jsx on lines 88..93
    src/applications/mhv-secure-messaging/components/MessageActionButtons/TrashButton.jsx on lines 93..98
    src/applications/mhv-secure-messaging/components/MessageThread/MessageThreadBody.jsx on lines 31..36
    src/applications/mhv-secure-messaging/components/Modals/DeleteMessageModal.jsx on lines 35..40
    src/applications/mhv-secure-messaging/components/SectionGuideButton.jsx on lines 32..37
    src/applications/mhv-secure-messaging/components/shared/AlertBackgroundBox.jsx on lines 226..231
    src/applications/personalization/common/components/devtools/DevToolsLoader.jsx on lines 131..136
    src/applications/personalization/profile/components/direct-deposit/vye/components/AlertModal.jsx on lines 30..35
    src/applications/personalization/profile/components/proof-of-veteran-status/ProofOfVeteranStatusCard/ProofOfVeteranStatusCard.jsx on lines 52..57
    src/applications/representative-appoint/components/ClaimantTypeForm.jsx on lines 38..43
    src/applications/representative-appoint/components/ContactAccreditedRepresentative.jsx on lines 124..129
    src/applications/representative-appoint/containers/PreSubmitInfo.jsx on lines 167..172
    src/applications/resources-and-support/components/SearchBar.jsx on lines 235..240
    src/applications/search/components/ResultsList.jsx on lines 58..63
    src/applications/static-pages/events/components/Results/ResultsWhereContent.jsx on lines 98..103
    src/applications/vaos/components/layouts/DetailPageLayout.jsx on lines 126..131
    src/applications/vaos/new-appointment/components/ReviewPage/ReviewRequestInfo/ReviewDirectScheduleInfo/ReviewDirectScheduleInfo.jsx on lines 38..43
    src/applications/vaos/new-appointment/components/VAFacilityPage/FacilitiesNotShown.jsx on lines 110..115
    src/applications/vaos/new-appointment/components/VAFacilityPage/NoValidVAFacilitiesV2.jsx on lines 79..84
    src/applications/vaos/new-appointment/components/VAFacilityPage/getEligibilityMessage.js on lines 119..124
    src/applications/vaos/referral-appointments/components/ReferralLayout.jsx on lines 91..96
    src/applications/verify-your-enrollment/components/Alert.jsx on lines 24..29
    src/applications/verify-your-enrollment/components/AlertModal.jsx on lines 29..34
    src/applications/verify-your-enrollment/components/EnrollmentStatus.jsx on lines 28..33
    src/platform/forms-system/src/js/components/ConfirmationView/components.jsx on lines 268..273
    src/platform/forms-system/src/js/review/submit-states/ClientError.jsx on lines 65..70
    src/platform/forms-system/src/js/review/submit-states/Default.jsx on lines 39..44
    src/platform/forms-system/src/js/review/submit-states/GenericError.jsx on lines 67..72
    src/platform/mhv/downtime/components/MHVDown.jsx on lines 44..49
    src/platform/mhv/downtime/components/MHVDowntimeApproaching.jsx on lines 34..39
    src/platform/user/authentication/components/VerifyAccountLink.jsx on lines 45..50
    src/applications/check-in/components/BackButton.jsx on lines 59..64
    src/applications/static-pages/facilities/FacilityMapWidgetDynamic.jsx on lines 126..131
    src/platform/forms-system/src/js/patterns/array-builder/ArrayBuilderSummaryPage.jsx on lines 543..548

    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