department-of-veterans-affairs/vets-website

View on GitHub
src/applications/representative-appoint/prefill-transformer.js

Summary

Maintainability
D
2 days
Test Coverage

Function prefillTransformer has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
Open

export function prefillTransformer(pages, formData, metadata) {
  const prefillPersonalInformation = data => {
    const newData = _.omit(['personalInformation'], data);
    const { personalInformation } = data;

Severity: Minor
Found in src/applications/representative-appoint/prefill-transformer.js - 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 prefillTransformer has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function prefillTransformer(pages, formData, metadata) {
  const prefillPersonalInformation = data => {
    const newData = _.omit(['personalInformation'], data);
    const { personalInformation } = data;

Severity: Major
Found in src/applications/representative-appoint/prefill-transformer.js - About 3 hrs to fix

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

      const prefillContactInformation = data => {
        const newData = _.omit(['contactInformation', 'avaProfile'], data);
        const { contactInformation, avaProfile } = data;
    
        if (contactInformation) {
    Severity: Minor
    Found in src/applications/representative-appoint/prefill-transformer.js - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

            if (address) {
              const { militaryAddress } = address;
              newData.address = {
                street: address.street || '',
                unitNumber: address.unitNumber || '',
      Severity: Critical
      Found in src/applications/representative-appoint/prefill-transformer.js - About 1 hr to fix

        Function prefillPersonalInformation has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          const prefillPersonalInformation = data => {
            const newData = _.omit(['personalInformation'], data);
            const { personalInformation } = data;
        
            if (personalInformation) {
        Severity: Minor
        Found in src/applications/representative-appoint/prefill-transformer.js - About 1 hr to fix

          There are no issues that match your filters.

          Category
          Status