File helpers.js
has 538 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { dropRight, merge } from 'lodash';
import { getDefaultFormState } from '@department-of-veterans-affairs/react-jsonschema-form/lib/utils';
import dataGet from '../../../../utilities/data/get';
import set from '../../../../utilities/data/set';
import unset from '../../../../utilities/data/unset';
Function updateRequiredFields
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
export function updateRequiredFields(schema, uiSchema, formData, index = null) {
if (!uiSchema) {
return schema;
}
- Read upRead up
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 setHiddenFields
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
export function setHiddenFields(schema, uiSchema, formData, path = []) {
if (!uiSchema) {
return schema;
}
- Read upRead up
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 updateSchemaFromUiSchema
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function updateSchemaFromUiSchema(
schema,
uiSchema,
formData,
index = null,
Function updateSchemaFromUiSchema
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
export function updateSchemaFromUiSchema(
schema,
uiSchema,
formData,
index = null,
- Read upRead up
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 setHiddenFields
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function setHiddenFields(schema, uiSchema, formData, path = []) {
if (!uiSchema) {
return schema;
}
Function createInitialState
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function createInitialState(formConfig) {
let initialState = {
submission: {
status: false,
errorMessage: false,
Function updateRequiredFields
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function updateRequiredFields(schema, uiSchema, formData, index = null) {
if (!uiSchema) {
return schema;
}
Function updateItemsSchema
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function updateItemsSchema(schema, fieldData = null) {
if (schema.type === 'array') {
let newSchema = schema;
// This happens the first time this function is called when
Function replaceRefSchemas
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function replaceRefSchemas(schema, definitions, path = '') {
// this can happen if you import a field that doesn’t exist from a schema
if (!schema) {
throw new Error(`Schema is undefined at ${path}`);
}
Function recalculateSchemaAndData
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function recalculateSchemaAndData(initialState) {
return Object.keys(initialState.pages).reduce((state, pageKey) => {
// on each data change, we need to do the following steps
// Recalculate any required fields, based on the new data
const page = state.pages[pageKey];
Function updateItemsSchema
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export function updateItemsSchema(schema, fieldData = null) {
if (schema.type === 'array') {
let newSchema = schema;
// This happens the first time this function is called when
- Read upRead up
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 updateUiSchema
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function updateUiSchema(schema, uiSchema, formData) {
if (!uiSchema) {
return uiSchema;
}
Function replaceRefSchemas
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export function replaceRefSchemas(schema, definitions, path = '') {
// this can happen if you import a field that doesn’t exist from a schema
if (!schema) {
throw new Error(`Schema is undefined at ${path}`);
}
- Read upRead up
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 removeHiddenData
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function removeHiddenData(schema, data) {
// null is necessary here because Rails 4 will convert empty arrays to null
// In the forms, there's no difference between an empty array and null or undefined
if (isHiddenField(schema) || typeof data === 'undefined' || data === null) {
return undefined;
Function pageAndDataState
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
(state, page) => {
const definitions = {
...(formConfig.defaultDefinitions || {}),
...page.schema.definitions,
};
Function updateUiSchema
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export function updateUiSchema(schema, uiSchema, formData) {
if (!uiSchema) {
return uiSchema;
}
- Read upRead up
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 updateSchemaFromUiSchema
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
schema,
uiSchema,
formData,
index = null,
path = [],
Function removeHiddenData
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export function removeHiddenData(schema, data) {
// null is necessary here because Rails 4 will convert empty arrays to null
// In the forms, there's no difference between an empty array and null or undefined
if (isHiddenField(schema) || typeof data === 'undefined' || data === null) {
return undefined;
- Read upRead up
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 schema;
Avoid too many return
statements within this function. Open
return data;