department-of-veterans-affairs/vets-website

View on GitHub
src/applications/disability-benefits/all-claims/utils/submit.js

Summary

Maintainability
C
1 day
Test Coverage

File submit.js has 341 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import _ from 'platform/utilities/data';
import {
  PTSD_INCIDENT_ITERATION,
  PTSD_CHANGE_LABELS,
  ATTACHMENT_KEYS,
Severity: Minor
Found in src/applications/disability-benefits/all-claims/utils/submit.js - About 4 hrs to fix

    Function addForm0781 has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const addForm0781 = formData => {
      const clonedData = _.cloneDeep(formData);
      const incidentKeys = getFlatIncidentKeys();
      const incidents = incidentKeys
        .filter(incidentKey => clonedData[incidentKey])
    Severity: Minor
    Found in src/applications/disability-benefits/all-claims/utils/submit.js - About 1 hr to fix

      Function customReplacer has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      export function customReplacer(key, value) {
        // clean up empty objects, which we have no reason to send
        if (typeof value === 'object') {
          const fields = Object.keys(value);
          if (
      Severity: Minor
      Found in src/applications/disability-benefits/all-claims/utils/submit.js - About 1 hr 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 addPTSDCause has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      export const addPTSDCause = formData => {
        const clonedData = formData.newDisabilities
          ? _.set(
              'newDisabilities',
              formData.newDisabilities.map(disability => {
      Severity: Minor
      Found in src/applications/disability-benefits/all-claims/utils/submit.js - About 55 mins 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

      Avoid too many return statements within this function.
      Open

        return value;
      Severity: Major
      Found in src/applications/disability-benefits/all-claims/utils/submit.js - About 30 mins to fix

        There are no issues that match your filters.

        Category
        Status