department-of-veterans-affairs/vets-website

View on GitHub
src/platform/testing/e2e/cypress/support/form-tester/index.js

Summary

Maintainability
D
2 days
Test Coverage

File index.js has 406 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import path from 'path';

import get from 'platform/utilities/data/get';

import disableFTUXModals from 'platform/user/tests/disableFTUXModals';
Severity: Minor
Found in src/platform/testing/e2e/cypress/support/form-tester/index.js - About 5 hrs to fix

    Function enterData has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function enterData(field) {
      switch (field.type) {
        // Select fields register as having type 'select-one'.
        case 'select-one':
          cy.wrap(field.element)
    Severity: Major
    Found in src/platform/testing/e2e/cypress/support/form-tester/index.js - About 2 hrs to fix

      Function testForm has 73 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const testForm = testConfig => {
        const {
          appName,
          arrayPages = [],
          dataPrefix,
      Severity: Major
      Found in src/platform/testing/e2e/cypress/support/form-tester/index.js - About 2 hrs to fix

        Function enterData has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        function enterData(field) {
          switch (field.type) {
            // Select fields register as having type 'select-one'.
            case 'select-one':
              cy.wrap(field.element)
        Severity: Minor
        Found in src/platform/testing/e2e/cypress/support/form-tester/index.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 fillAvailableFields has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              const fillAvailableFields = () => {
                getFieldSelectors().then(fieldSelector => {
                  cy.get(APP_SELECTOR, NO_LOG_OPTION)
                    .then($form => {
                      // Get the starting number of array items and fields to compare
        Severity: Minor
        Found in src/platform/testing/e2e/cypress/support/form-tester/index.js - About 1 hr to fix

          Function addNewArrayItem has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const addNewArrayItem = $form => {
            // Get all array types on the current page.
            const arrayTypeRoots = $form.find('div[name^="topOfTable_root_"]');
          
            // Find the last entry for each array type, use its index to figure out
          Severity: Minor
          Found in src/platform/testing/e2e/cypress/support/form-tester/index.js - About 1 hr to fix

            Function testForm has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            const testForm = testConfig => {
              const {
                appName,
                arrayPages = [],
                dataPrefix,
            Severity: Minor
            Found in src/platform/testing/e2e/cypress/support/form-tester/index.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

            Function defaultPostHook has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            const defaultPostHook = pathname => {
              // On review pages, check the privacy agreement box if it exists and submit.
              if (pathname.endsWith('/review-and-submit')) {
                return () => {
                  cy.get(APP_SELECTOR, NO_LOG_OPTION).then($form => {
            Severity: Minor
            Found in src/platform/testing/e2e/cypress/support/form-tester/index.js - About 25 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

            There are no issues that match your filters.

            Category
            Status