department-of-veterans-affairs/vets-website

View on GitHub
src/applications/gi/components/SearchBenefits.jsx

Summary

Maintainability
F
4 days
Test Coverage

File SearchBenefits.jsx has 325 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React, { useState } from 'react';
import { useFeatureToggle } from 'platform/utilities/feature-toggles';
import EbenefitsLink from 'platform/site-wide/ebenefits/containers/EbenefitsLink';
import recordEvent from 'platform/monitoring/record-event';
import PropTypes from 'prop-types';
Severity: Minor
Found in src/applications/gi/components/SearchBenefits.jsx - About 3 hrs to fix

    Function SearchBenefits has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    const SearchBenefits = ({
      cumulativeService,
      dispatchShowModal,
      eligForPostGiBill,
      enlistmentService,
    Severity: Minor
    Found in src/applications/gi/components/SearchBenefits.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 preEligibilityChange has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const preEligibilityChange = e => {
        const { value } = e.target;
    
        recordEvent({
          event: 'gibct-form-change',
    Severity: Minor
    Found in src/applications/gi/components/SearchBenefits.jsx - About 1 hr to fix

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

      SearchBenefits.propTypes = {
        cumulativeService: PropTypes.string,
        dispatchShowModal: PropTypes.func,
        eligForPostGiBill: PropTypes.string,
        enlistmentService: PropTypes.string,
      Severity: Major
      Found in src/applications/gi/components/SearchBenefits.jsx and 2 other locations - About 5 hrs to fix
      src/applications/gi/components/profile/BenefitsForm.jsx on lines 324..340
      src/applications/mhv-secure-messaging/components/ComposeForm/ReplyDraftItem.jsx on lines 562..578

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

      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

              options={[
                { optionValue: '1.0', optionLabel: '36+ months: 100%' }, // notice not 1.00
                { optionValue: '0.9', optionLabel: '30 months: 90%' },
                { optionValue: '0.8', optionLabel: '24 months: 80%' },
                { optionValue: '0.7', optionLabel: '18 months: 70%' },
      Severity: Major
      Found in src/applications/gi/components/SearchBenefits.jsx and 1 other location - About 3 hrs to fix
      src/applications/gi/components/profile/BenefitsForm.jsx on lines 91..103

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

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

                <Dropdown
                  label="Is your spouse currently on active duty?"
                  name="spouseActiveDuty"
                  options={[
                    { optionValue: 'yes', optionLabel: 'Yes' },
      Severity: Major
      Found in src/applications/gi/components/SearchBenefits.jsx and 2 other locations - About 3 hrs to fix
      src/applications/gi/components/SearchBenefits.jsx on lines 190..201
      src/applications/gi/components/SearchBenefits.jsx on lines 295..306

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

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

                <Dropdown
                  label="Is your spouse currently on active duty?"
                  name="spouseActiveDuty"
                  options={[
                    { optionValue: 'yes', optionLabel: 'Yes' },
      Severity: Major
      Found in src/applications/gi/components/SearchBenefits.jsx and 2 other locations - About 3 hrs to fix
      src/applications/gi/components/SearchBenefits.jsx on lines 126..137
      src/applications/gi/components/SearchBenefits.jsx on lines 295..306

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

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

            <Dropdown
              label="Are you eligible for the Post-9/11 GI Bill?"
              name="eligForPostGiBill"
              options={[
                { optionValue: 'yes', optionLabel: 'Yes' },
      Severity: Major
      Found in src/applications/gi/components/SearchBenefits.jsx and 2 other locations - About 3 hrs to fix
      src/applications/gi/components/SearchBenefits.jsx on lines 126..137
      src/applications/gi/components/SearchBenefits.jsx on lines 190..201

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

      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

            {militaryStatus === 'active duty' &&
              chapter33Check && (
                <div className="military-status-info warning form-group">
                  <va-icon icon="warning" />
                  <a
      Severity: Major
      Found in src/applications/gi/components/SearchBenefits.jsx and 1 other location - About 2 hrs to fix
      src/applications/gi/components/profile/BenefitsForm.jsx on lines 216..233

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

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

              options={[
                { optionValue: '0', optionLabel: '0 Dependents' },
                { optionValue: '1', optionLabel: '1 Dependent' },
                { optionValue: '2', optionLabel: '2 Dependents' },
                { optionValue: '3', optionLabel: '3 Dependents' },
      Severity: Major
      Found in src/applications/gi/components/SearchBenefits.jsx and 2 other locations - About 2 hrs to fix
      src/applications/gi/components/profile/BenefitsForm.jsx on lines 141..158
      src/applications/gi/components/profile/BenefitsForm.jsx on lines 294..301

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

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

      const SearchBenefits = ({
        cumulativeService,
        dispatchShowModal,
        eligForPostGiBill,
        enlistmentService,
      Severity: Major
      Found in src/applications/gi/components/SearchBenefits.jsx and 2 other locations - About 2 hrs to fix
      src/applications/financial-status-report/containers/App.jsx on lines 33..215
      src/applications/gi/containers/search/LocationSearchForm.jsx on lines 33..345

      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

              onChange={e => {
                recordEvent({
                  event: 'gibct-form-change',
                  'gibct-form-field': 'Cumulative Post-9/11 active-duty service',
                  'gibct-form-value': e.target.value,
      Severity: Major
      Found in src/applications/gi/components/SearchBenefits.jsx and 1 other location - About 1 hr to fix
      src/applications/gi/containers/search/LocationSearchForm.jsx on lines 306..313

      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

      There are no issues that match your filters.

      Category
      Status