department-of-veterans-affairs/vets-website

View on GitHub
src/applications/pre-need/components/FileField.jsx

Summary

Maintainability
F
2 wks
Test Coverage

Function FileField has 533 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const FileField = props => {
  const {
    enableShortWorkflow,
    errorSchema,
    formContext,
Severity: Major
Found in src/applications/pre-need/components/FileField.jsx - About 2 days to fix

    File FileField.jsx has 592 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* eslint-disable jsx-a11y/no-noninteractive-element-to-interactive-role */
    import PropTypes from 'prop-types';
    import React, { useEffect, useState, useRef } from 'react';
    import { connect } from 'react-redux';
    import classNames from 'classnames';
    Severity: Major
    Found in src/applications/pre-need/components/FileField.jsx - About 1 day to fix

      Function FileField has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
      Open

      const FileField = props => {
        const {
          enableShortWorkflow,
          errorSchema,
          formContext,
      Severity: Minor
      Found in src/applications/pre-need/components/FileField.jsx - About 1 day 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 onAddFile has 80 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const onAddFile = async (event, index = null, password) => {
          if (event.target?.files?.length) {
            const currentFile = event.target.files[0];
            const allFiles = props.formData || [];
            const addUiOptions = props.uiSchema['ui:options'];
      Severity: Major
      Found in src/applications/pre-need/components/FileField.jsx - About 3 hrs to fix

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

              {// Don't render an upload button on review & submit page while in
              // review mode
              showButtons && (
                <>
                  {(maxItems === null || files.length < maxItems) &&
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 1 other location - About 1 day to fix
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 677..718

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

        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 content = {
            upload: uiOptions.buttonText || 'Upload',
            uploadAnother: uiOptions.addAnotherLabel || 'Upload another',
            ariaLabelAdditionalText: uiOptions.ariaLabelAdditionalText || '',
            passwordLabel: fileName => `Add a password for ${fileName}`,
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 1 other location - About 1 day to fix
        src/applications/simple-forms/40-0247/components/FileField.jsx on lines 114..138

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

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

        FileField.propTypes = {
          schema: PropTypes.object.isRequired,
          onChange: PropTypes.func.isRequired,
          disabled: PropTypes.bool,
          enableShortWorkflow: PropTypes.bool,
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 2 other locations - About 1 day to fix
        src/applications/simple-forms/40-0247/components/FileField.jsx on lines 703..727
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 723..747

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

        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

                    if (hasVisibleError) {
                      setTimeout(() => {
                        scrollToFirstError();
                        if (enableShortWorkflow) {
                          const retryButton = $(`[name="retry_upload_${index}"]`);
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 1 other location - About 1 day to fix
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 485..507

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

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

              setUploadRequest(
                props.formContext.uploadFile(
                  currentFile,
                  addUiOptions,
                  updateProgress,
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 2 other locations - About 6 hrs to fix
        src/applications/simple-forms/40-0247/components/FileField.jsx on lines 304..331
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 291..318

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

        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

                        {!hasVisibleError &&
                          !showPasswordInput &&
                          get('properties.attachmentId', itemSchema) && (
                            <Tag className="schemaform-file-attachment review">
                              <SchemaField
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 3 other locations - About 6 hrs to fix
        src/applications/appeals/shared/components/FileField.jsx on lines 540..559
        src/applications/simple-forms/40-0247/components/FileField.jsx on lines 568..587
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 577..596

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

        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

                        {!hasVisibleError &&
                          !showPasswordInput &&
                          uiOptions.attachmentName && (
                            <Tag className="schemaform-file-attachment review">
                              <SchemaField
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 3 other locations - About 6 hrs to fix
        src/applications/appeals/shared/components/FileField.jsx on lines 560..579
        src/applications/simple-forms/40-0247/components/FileField.jsx on lines 588..607
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 597..616

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

        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

                        {file.uploading && (
                          <div className="schemaform-file-uploading">
                            <strong
                              id={fileNameId}
                              className="dd-privacy-hidden"
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 1 other location - About 6 hrs to fix
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 536..559

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

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

          useEffect(
            () => {
              const prevFiles = previousValue || [];
              fileButtonRef?.current?.classList?.toggle(
                'vads-u-display--none',
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 2 other locations - About 6 hrs to fix
        src/applications/simple-forms/40-0247/components/FileField.jsx on lines 183..203
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 184..204

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

        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

              <VaModal
                clickToClose
                status="warning"
                modalTitle="Are you sure you want to delete this file?"
                primaryButtonText={content.yesButton}
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 1 other location - About 4 hrs to fix
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 416..433

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

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

          const removeFile = (index, focusAddButton = true) => {
            const newFileList = props.formData.filter((__, idx) => index !== idx);
            if (!newFileList.length) {
              props.onChange();
            } else {
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 3 other locations - About 4 hrs to fix
        src/applications/appeals/shared/components/FileField.jsx on lines 297..315
        src/applications/simple-forms/40-0247/components/FileField.jsx on lines 357..375
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 344..362

        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

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

          const closeRemoveModal = ({ remove = false } = {}) => {
            const idx = removeIndex;
            setRemoveIndex(null);
            setShowRemoveModal(false);
            if (remove) {
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 3 other locations - About 3 hrs to fix
        src/applications/appeals/shared/components/FileField.jsx on lines 322..337
        src/applications/simple-forms/40-0247/components/FileField.jsx on lines 382..397
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 369..384

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

        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

          useEffect(
            () => {
              // The File object is not preserved in the save-in-progress data
              // We need to remove these entries; an empty `file` is included in the
              // entry, but if API File Object still exists (within the same session), we
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 2 other locations - About 3 hrs to fix
        src/applications/simple-forms/40-0247/components/FileField.jsx on lines 205..223
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 206..224

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

        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

                        {!file.uploading && (
                          <>
                            <strong
                              id={fileNameId}
                              className="dd-privacy-hidden"
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 3 other locations - About 2 hrs to fix
        src/applications/appeals/shared/components/FileField.jsx on lines 524..535
        src/applications/simple-forms/40-0247/components/FileField.jsx on lines 552..563
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 561..572

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

        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

                                <va-button
                                  secondary
                                  class="delete-upload vads-u-width--auto"
                                  onClick={() => {
                                    if (hasVisibleError) {
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 1 other location - About 2 hrs to fix
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 652..669

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

        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

                              {hasVisibleError && (
                                <va-button
                                  name={`retry_upload_${index}`}
                                  class="retry-upload vads-u-width--auto vads-u-margin-right--2"
                                  onClick={getRetryFunction(
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 1 other location - About 2 hrs to fix
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 634..651

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

        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 checkUploadVisibility = () =>
            !enableShortWorkflow ||
            (enableShortWorkflow &&
              !files.some((file, index) => {
                const errors =
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 2 other locations - About 2 hrs to fix
        src/applications/simple-forms/40-0247/components/FileField.jsx on lines 154..163
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 155..164

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

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

              if (
                currentFile.name?.endsWith('pdf') &&
                !password &&
                checkResults.checkIsEncryptedPdf
              ) {
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 2 other locations - About 2 hrs to fix
        src/applications/simple-forms/40-0247/components/FileField.jsx on lines 288..302
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 275..289

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

        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

          const onAttachmentIdChange = (index, value) => {
            if (!value) {
              props.onChange(unset([index, 'attachmentId'], props.formData));
            } else {
              props.onChange(set([index, 'attachmentId'], value, props.formData));
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 7 other locations - About 1 hr to fix
        src/applications/appeals/shared/components/FileField.jsx on lines 281..287
        src/applications/appeals/shared/components/FileField.jsx on lines 289..295
        src/applications/pre-need/components/FileField.jsx on lines 337..343
        src/applications/simple-forms/40-0247/components/FileField.jsx on lines 341..347
        src/applications/simple-forms/40-0247/components/FileField.jsx on lines 349..355
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 328..334
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 336..342

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

        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

          const onAttachmentNameChange = (index, value) => {
            if (!value) {
              props.onChange(unset([index, 'name'], props.formData));
            } else {
              props.onChange(set([index, 'name'], value, props.formData));
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 7 other locations - About 1 hr to fix
        src/applications/appeals/shared/components/FileField.jsx on lines 281..287
        src/applications/appeals/shared/components/FileField.jsx on lines 289..295
        src/applications/pre-need/components/FileField.jsx on lines 329..335
        src/applications/simple-forms/40-0247/components/FileField.jsx on lines 341..347
        src/applications/simple-forms/40-0247/components/FileField.jsx on lines 349..355
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 328..334
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 336..342

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

        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

              if (currentFile.type === 'testing') {
                // Skip read file for Cypress testing
                checkResults = {
                  checkTypeAndExtensionMatches: true,
                  checkIsEncryptedPdf: false,
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 1 other location - About 1 hr to fix
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 250..262

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

        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

                        {!file.uploading &&
                          hasVisibleError && (
                            <span className="usa-input-error-message" role="alert">
                              <span className="sr-only">Error</span> {errors[0]}
                            </span>
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 3 other locations - About 1 hr to fix
        src/applications/lgy/coe/form/config/chapters/documents/FileField.jsx on lines 458..463
        src/applications/simple-forms/40-0247/components/FileField.jsx on lines 608..613
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 617..622

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

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

          const {
            enableShortWorkflow,
            errorSchema,
            formContext,
            formData = [],
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 2 other locations - About 1 hr to fix
        src/applications/simple-forms/40-0247/components/FileField.jsx on lines 78..89
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 79..90

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

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

              if (!checkResults.checkTypeAndExtensionMatches) {
                allFiles[idx] = {
                  file: currentFile,
                  name: currentFile.name,
                  errorMessage: FILE_TYPE_MISMATCH_ERROR,
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 2 other locations - About 1 hr to fix
        src/applications/simple-forms/40-0247/components/FileField.jsx on lines 277..285
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 264..272

        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

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

          const focusAddAnotherButton = () => {
            // Add a timeout to allow for the upload button to reappear in the DOM
            // before trying to focus on it
            setTimeout(() => {
              // focus on upload button, not the label
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 2 other locations - About 1 hr to fix
        src/applications/simple-forms/40-0247/components/FileField.jsx on lines 165..177
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 166..178

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

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

                    const getUiSchema = innerUiSchema =>
                      typeof innerUiSchema === 'function'
                        ? innerUiSchema({
                            fileId: fileNameId,
                            index,
        Severity: Major
        Found in src/applications/pre-need/components/FileField.jsx and 2 other locations - About 40 mins to fix
        src/applications/appeals/shared/components/FileField.jsx on lines 481..488
        src/platform/forms-system/src/js/fields/FileField.jsx on lines 516..523

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

        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

              if (checkResults.checkIsEncryptedPdf) {
                allFiles[idx] = {
                  file: currentFile,
                  name: currentFile.name,
                  errorMessage:
        Severity: Minor
        Found in src/applications/pre-need/components/FileField.jsx and 1 other location - About 35 mins to fix
        src/applications/simple-forms/40-0247/components/FileField.jsx on lines 267..275

        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