department-of-veterans-affairs/vets-website

View on GitHub
src/applications/health-care-supply-reordering/components/Accessories.jsx

Summary

Maintainability
F
6 days
Test Coverage

Function render has 139 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    const { supplies, order, eligibility } = this.props;
    const currentDate = moment();
    const accessorySupplies = supplies.filter(
      supply => supply.productGroup === ACCESSORY,

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

    Accessories.propTypes = {
      eligibility: PropTypes.object,
      formData: PropTypes.object,
      order: PropTypes.arrayOf(
        PropTypes.shape({
    src/applications/disability-benefits/2346/components/Accessories.jsx on lines 222..244
    src/applications/disability-benefits/2346/components/ApneaSupplies.jsx on lines 223..245
    src/applications/health-care-supply-reordering/components/ApneaSupplies.jsx on lines 209..231

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

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

      handleChecked = (checked, accessorySupply) => {
        const { order, formData } = this.props;
        let updatedOrder;
        const isSupplyChecked = checked ? 'yes' : 'no';
        recordEvent({
    src/applications/disability-benefits/2346/components/Accessories.jsx on lines 26..50
    src/applications/disability-benefits/2346/components/ApneaSupplies.jsx on lines 26..49
    src/applications/health-care-supply-reordering/components/ApneaSupplies.jsx on lines 28..51

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

    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

                  {currentDate.diff(accessorySupply.nextAvailabilityDate, 'days') <
                  0 ? (
                    <va-alert status="warning">
                      <h3 className="usa-alert-heading vads-u-font-family--sans">
                        You can't order this accessory online until{' '}
    src/applications/health-care-supply-reordering/components/Batteries.jsx on lines 150..172

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

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

                  <div className="vads-u-border-color--gray-lightest">
                    <div className="usa-alert-body">
                      <p className="vads-u-margin-y--1p5">
                        <span className="vads-u-font-weight--bold">Quantity: </span>
                        {accessorySupply.quantity}
    src/applications/disability-benefits/2346/components/Accessories.jsx on lines 116..129
    src/applications/disability-benefits/2346/components/ApneaSupplies.jsx on lines 116..129
    src/applications/health-care-supply-reordering/components/ApneaSupplies.jsx on lines 118..131

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

    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

            {accessorySupplies.length > 0 && (
              <va-additional-info
                trigger="What if the accessories I need aren’t listed here?"
                className="vads-u-margin-bottom--2"
              >
    src/applications/disability-benefits/2346/components/Accessories.jsx on lines 174..209

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

            {!haveAccessoriesBeenOrderedInLastTwoYears &&
              !areAccessorySuppliesEligible && (
                <va-alert status="info" visible>
                  <h3 slot="headline">
                    You can’t add accessories to your order at this time
    src/applications/disability-benefits/2346/components/Accessories.jsx on lines 78..97

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

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

    const mapStateToProps = state => ({
      eligibility: state.form?.data?.eligibility,
      formData: state.form?.data,
      order: state.form?.data?.order,
      supplies: state.form?.data?.supplies,
    src/applications/disability-benefits/2346/components/Accessories.jsx on lines 246..251
    src/applications/disability-benefits/2346/components/ApneaSupplies.jsx on lines 247..252
    src/applications/health-care-supply-reordering/components/ApneaSupplies.jsx on lines 233..238

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

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

                <div
                  key={accessorySupply.productId}
                  className={classnames({
                    'vads-u-background-color--gray-lightest vads-u-margin-y--3': true,
                    'vads-u-border-color--primary vads-u-border--3px vads-u-padding--21 dd-privacy-mask': isAccessorySelected(
    src/applications/disability-benefits/2346/components/Accessories.jsx on lines 101..172
    src/applications/disability-benefits/2346/components/Accessories.jsx on lines 153..169
    src/applications/disability-benefits/2346/components/ApneaSupplies.jsx on lines 101..184
    src/applications/disability-benefits/2346/components/ApneaSupplies.jsx on lines 155..168
    src/applications/disability-benefits/2346/components/Batteries.jsx on lines 109..190
    src/applications/health-care-supply-reordering/components/ApneaSupplies.jsx on lines 103..170
    src/applications/health-care-supply-reordering/components/Batteries.jsx on lines 111..173

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

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

      componentDidMount() {
        const areAccessorySuppliesEligible = this.props.eligibility?.accessories;
        if (!areAccessorySuppliesEligible) {
          recordEvent({
            event: 'bam-error',
    src/applications/disability-benefits/2346/components/Accessories.jsx on lines 16..24
    src/applications/disability-benefits/2346/components/ApneaSupplies.jsx on lines 16..24
    src/applications/disability-benefits/2346/components/Batteries.jsx on lines 16..24
    src/applications/health-care-supply-reordering/components/ApneaSupplies.jsx on lines 18..26
    src/applications/health-care-supply-reordering/components/Batteries.jsx on lines 18..26

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

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

        const haveAccessoriesBeenOrderedInLastTwoYears =
          accessorySupplies.length > 0 &&
          accessorySupplies.every(
            accessory => currentDate.diff(accessory.lastOrderDate, 'years') <= 2,
          );
    src/applications/disability-benefits/2346/components/Accessories.jsx on lines 59..63
    src/applications/disability-benefits/2346/components/ApneaSupplies.jsx on lines 58..63
    src/applications/disability-benefits/2346/components/Batteries.jsx on lines 60..64
    src/applications/health-care-supply-reordering/components/ApneaSupplies.jsx on lines 60..65
    src/applications/health-care-supply-reordering/components/Batteries.jsx on lines 62..66

    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

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

        const isAccessorySelected = accessoryProductId => {
          const selectedProductIds = order.map(
            selectedProduct => selectedProduct.productId,
          );
          return selectedProductIds.includes(accessoryProductId);
    src/applications/disability-benefits/2346/components/Accessories.jsx on lines 65..70
    src/applications/disability-benefits/2346/components/ApneaSupplies.jsx on lines 65..70
    src/applications/disability-benefits/2346/components/Batteries.jsx on lines 65..70
    src/applications/health-care-supply-reordering/components/ApneaSupplies.jsx on lines 67..72
    src/applications/health-care-supply-reordering/components/Batteries.jsx on lines 67..72
    src/applications/health-care-supply-reordering/utils/addresses.js on lines 32..35

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

    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