department-of-veterans-affairs/vets-website

View on GitHub
src/applications/gi/components/profile/CalculateYourBenefitsForm.jsx

Summary

Maintainability
F
1 wk
Test Coverage

File CalculateYourBenefitsForm.jsx has 1145 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import PropTypes from 'prop-types';
import React, { useState } from 'react';
import _ from 'lodash';
import classNames from 'classnames';

Severity: Major
Found in src/applications/gi/components/profile/CalculateYourBenefitsForm.jsx - About 2 days to fix

    Function CalculateYourBenefitsForm has a Cognitive Complexity of 110 (exceeds 5 allowed). Consider refactoring.
    Open

    function CalculateYourBenefitsForm({
      calculatorInputChange,
      displayedInputs,
      eligibility,
      eligibilityChange,
    Severity: Minor
    Found in src/applications/gi/components/profile/CalculateYourBenefitsForm.jsx - About 2 days 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 renderExtensionBeneficiaryZIP has 126 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const renderExtensionBeneficiaryZIP = () => {
        if (!displayedInputs.beneficiaryLocationQuestion) {
          return null;
        }
        const extensions = getExtensions();
    Severity: Major
    Found in src/applications/gi/components/profile/CalculateYourBenefitsForm.jsx - About 5 hrs to fix

      Function renderYellowRibbon has 101 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const renderYellowRibbon = () => {
          if (!displayedInputs.yellowRibbon) return null;
      
          let {
            yellowRibbonDegreeLevelOptions,
      Severity: Major
      Found in src/applications/gi/components/profile/CalculateYourBenefitsForm.jsx - About 4 hrs to fix

        Function renderCalendar has 72 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          const renderCalendar = () => {
            if (!displayedInputs.calendar) return null;
        
            const dependentDropdowns = (
              <div>
        Severity: Major
        Found in src/applications/gi/components/profile/CalculateYourBenefitsForm.jsx - About 2 hrs to fix

          Function renderEnrolled has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            const renderEnrolled = () => {
              const {
                enrolled: shouldRenderEnrolled,
                enrolledOld: shouldRenderEnrolledOld,
              } = displayedInputs;

            Function renderKicker has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              const renderKicker = () => {
                if (!displayedInputs.kicker) return null;
                const radioButtonsLabelText = 'Eligible for kicker bonus?';
                const kickerAmountId = 'kickerAmount';
                const kickerFieldId = `${kickerAmountId}-field`;

              Function renderBuyUp has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                const renderBuyUp = () => {
                  if (!displayedInputs.buyUp) return null;
              
                  const buyUpAmountId = 'buyUpAmount';
                  const buyUpFieldId = `${buyUpAmountId}-field`;

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

                  const renderWorking = () => {
                    if (!displayedInputs.working) return null;
                    return (
                      <Dropdown
                        label={learnMoreLabel({

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

                    const handleInputChange = (event, target, name) => {
                      const { value } = event ? event.target : target.detail;
                      const field = event ? event.target.name : name;
                      calculatorInputChange({ field, value });
                  
                  

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

                      const renderInState = () => {
                        if (!displayedInputs.inState) return null;
                        const { inStateTuitionInformation } = profile.attributes;
                        const radioButtonsLabelText = 'Are you an in-state student?';
                        const options = [

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

                        const renderMilitaryDetails = () => {
                          const name = 'Your military details';
                      
                          return (
                            <AccordionItem

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

                          const renderTuitionAssist = () => {
                            if (!displayedInputs.tuitionAssist) return null;
                            const tuitionAssistId = 'tuitionAssist';
                            const tuitionAssistFieldId = `${tuitionAssistId}-field`;
                            return (

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

                            const renderTuition = () => {
                              if (!displayedInputs.tuition) return null;
                          
                              const tuitionFeesId = 'tuitionFees';
                              const tuitionFeesFieldId = `${tuitionFeesId}-field`;

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

                              const renderScholarships = () => {
                                if (!displayedInputs.scholarships) return null;
                                const scholarshipsId = 'scholarships';
                                const scholarshipsFieldId = `${scholarshipsId}-field`;
                                return (

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

                                const renderTuitionAssist = () => {
                                  if (!displayedInputs.tuitionAssist) return null;
                                  const tuitionAssistId = 'tuitionAssist';
                                  const tuitionAssistFieldId = `${tuitionAssistId}-field`;
                                  return (
                              src/applications/gi/components/profile/CalculateYourBenefitsForm.jsx on lines 556..583

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

                              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 renderScholarships = () => {
                                  if (!displayedInputs.scholarships) return null;
                                  const scholarshipsId = 'scholarships';
                                  const scholarshipsFieldId = `${scholarshipsId}-field`;
                                  return (
                              src/applications/gi/components/profile/CalculateYourBenefitsForm.jsx on lines 585..612

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

                              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 renderSchoolCostsAndCalendar = () => {
                                  if (hideSchoolCostsAndCalendar()) return null;
                              
                                  const name = 'School costs and calendar';
                                  return (
                              src/applications/gi/components/profile/CalculateYourBenefitsForm.jsx on lines 1181..1204

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

                              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 renderScholarshipsAndOtherVAFunding = () => {
                                  if (hideScholarshipsAndOtherVAFunding()) return null;
                                  const name = 'Scholarships and other VA funding';
                              
                                  return (
                              src/applications/gi/components/profile/CalculateYourBenefitsForm.jsx on lines 1123..1144

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

                              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 amountInput = (
                                    <div id={kickerFieldId}>
                                      <label htmlFor={kickerAmountId}>How much is your kicker?</label>
                                      <input
                                        inputMode="decimal"
                              src/applications/gi/components/profile/CalculateYourBenefitsForm.jsx on lines 939..956

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

                              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 amountInput = (
                                    <div id={buyUpFieldId}>
                                      <label htmlFor={buyUpAmountId}>
                                        How much did you pay toward buy-up (up to $600)?
                                      </label>
                              src/applications/gi/components/profile/CalculateYourBenefitsForm.jsx on lines 754..769

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

                              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

                                      <VARadioButton
                                        radioLabel="Participate in buy-up program?"
                                        name="buyUp"
                                        initialValue={inputs.buyUp}
                                        options={[
                              src/applications/gi/components/profile/CalculateYourBenefitsForm.jsx on lines 479..490

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

                                        <VARadioButton
                                          radioLabel=""
                                          name="yellowRibbonRecipient"
                                          initialValue={inputs.yellowRibbonRecipient}
                                          options={[
                              src/applications/gi/components/profile/CalculateYourBenefitsForm.jsx on lines 960..971

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

                              function CalculateYourBenefitsForm({
                                calculatorInputChange,
                                displayedInputs,
                                eligibility,
                                eligibilityChange,
                              src/applications/appeals/995/containers/App.jsx on lines 41..183
                              src/applications/appeals/testing/sc/containers/App.jsx on lines 41..183
                              src/applications/gi/containers/ProfilePage.jsx on lines 17..122
                              src/applications/gi/containers/search/FilterBeforeResults.jsx on lines 306..875
                              src/applications/mhv-secure-messaging/components/shared/RouteLeavingGuard.jsx on lines 7..96
                              src/applications/pact-act/containers/questions/CheckboxGroup.jsx on lines 24..118
                              src/applications/vaos/components/calendar/CalendarOptionsSlots.jsx on lines 39..146
                              src/platform/forms-system/src/js/widgets/SelectWidget.jsx on lines 18..71
                              src/applications/disability-benefits/all-claims/Form526EZApp.jsx on lines 85..250

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

                              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

                                      label={learnMoreLabel({
                                        text: 'Will be working',
                                        modal: 'calcWorking',
                                        ariaLabel: ariaLabels.learnMore.calcWorking,
                                        labelFor: 'working',
                              src/applications/gi/components/profile/CalculateYourBenefitsForm.jsx on lines 719..725

                              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

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

                                          label={learnMoreLabel({
                                            text: 'School Calendar',
                                            modal: 'calcSchoolCalendar',
                                            ariaLabel: ariaLabels.learnMore.calcSchoolCalendar,
                                            labelFor: 'calendar',
                              src/applications/gi/components/profile/CalculateYourBenefitsForm.jsx on lines 981..987

                              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