department-of-veterans-affairs/vets-website

View on GitHub
src/applications/disability-benefits/2346/components/ApneaSupplies.jsx

Summary

Maintainability
F
5 days
Test Coverage

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

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

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

    ApneaSupplies.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/health-care-supply-reordering/components/Accessories.jsx on lines 205..227
    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, apneaSupply) => {
        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/health-care-supply-reordering/components/Accessories.jsx on lines 28..52
    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 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>
                        {apneaSupply.quantity}
    src/applications/disability-benefits/2346/components/Accessories.jsx on lines 116..129
    src/applications/health-care-supply-reordering/components/Accessories.jsx on lines 118..131
    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

            {!haveApneaSuppliesBeenOrderedInLastTwoYears &&
              !areApneaSuppliesEligible && (
                <va-alert status="info" visible>
                  <h3 slot="headline">
                    You can’t add CPAP supplies to your order at this time
    src/applications/health-care-supply-reordering/components/ApneaSupplies.jsx on lines 80..99

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

                      {currentDate.diff(apneaSupply.nextAvailabilityDate, 'days') <
                        0 && apneaSupply.availableForReorder ? (
                        <div className="usa-alert usa-alert-warning vads-u-background-color--white vads-u-padding-x--2p5 vads-u-padding-y--2 vads-u-width--full">
                          <div className="usa-alert-body">
                            <h3 className="usa-alert-heading vads-u-font-family--sans">
    src/applications/disability-benefits/2346/components/Accessories.jsx on lines 130..171
    src/applications/disability-benefits/2346/components/Batteries.jsx on lines 148..189

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

    const mapStateToProps = state => ({
      supplies: state.form?.data?.supplies,
      formData: state.form?.data,
      order: state.form?.data?.order,
      eligibility: state.form?.data?.eligibility,
    src/applications/disability-benefits/2346/components/Accessories.jsx on lines 246..251
    src/applications/health-care-supply-reordering/components/Accessories.jsx on lines 229..234
    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 3 locations. Consider refactoring.
    Open

                          <input
                            id={apneaSupply.productId}
                            className="vads-u-margin-left--0"
                            type="checkbox"
                            onChange={e =>
    src/applications/disability-benefits/2346/components/Accessories.jsx on lines 144..152
    src/applications/disability-benefits/2346/components/Batteries.jsx on lines 162..170

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

    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

                  {apneaSupply.availableForReorder ? (
                    <div>
                      {currentDate.diff(apneaSupply.nextAvailabilityDate, 'days') <
                        0 && apneaSupply.availableForReorder ? (
                        <div className="usa-alert usa-alert-warning vads-u-background-color--white vads-u-padding-x--2p5 vads-u-padding-y--2 vads-u-width--full">
    src/applications/health-care-supply-reordering/components/ApneaSupplies.jsx on lines 132..169

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

    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={apneaSupply.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': isApneaSupplySelected(
    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 155..168
    src/applications/disability-benefits/2346/components/Batteries.jsx on lines 109..190
    src/applications/health-care-supply-reordering/components/Accessories.jsx on lines 103..155
    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 8 locations. Consider refactoring.
    Open

                          <label
                            htmlFor={apneaSupply.productId}
                            className={classnames({
                              'usa-button vads-u-font-weight--bold vads-u-border--2px vads-u-border-color--primary vads-u-text-align--left vads-u-padding-x--2': true,
                              'vads-u-color--white': isApneaSupplySelected(
    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/Batteries.jsx on lines 109..190
    src/applications/health-care-supply-reordering/components/Accessories.jsx on lines 103..155
    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 areApneaSuppliesEligible = this.props.eligibility?.apneas;
        if (!areApneaSuppliesEligible) {
          recordEvent({
            event: 'bam-error',
    src/applications/disability-benefits/2346/components/Accessories.jsx on lines 16..24
    src/applications/disability-benefits/2346/components/Batteries.jsx on lines 16..24
    src/applications/health-care-supply-reordering/components/Accessories.jsx on lines 18..26
    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 haveApneaSuppliesBeenOrderedInLastTwoYears =
          apneaSupplies.length > 0 &&
          apneaSupplies.every(
            apneaSupply =>
              currentDate.diff(apneaSupply.lastOrderDate, 'years') <= 2,
    src/applications/disability-benefits/2346/components/Accessories.jsx on lines 59..63
    src/applications/disability-benefits/2346/components/Batteries.jsx on lines 60..64
    src/applications/health-care-supply-reordering/components/Accessories.jsx on lines 61..65
    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 isApneaSupplySelected = apneaProductId => {
          const selectedProductIds = order.map(
            selectedProduct => selectedProduct.productId,
          );
          return selectedProductIds.includes(apneaProductId);
    src/applications/disability-benefits/2346/components/Accessories.jsx on lines 65..70
    src/applications/disability-benefits/2346/components/Batteries.jsx on lines 65..70
    src/applications/health-care-supply-reordering/components/Accessories.jsx on lines 67..72
    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