File validation.js
has 417 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*
___ ___ ___ _ _ _ ___ ___
| __/ __| ___| _ \___ _ _ _ __ (_) |_ /_\ | _ \_ _|
| _|\__ \ / -_) _/ -_) '_| ' \| | _| / _ \| _/| |
Function generateErrorMesage
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
function generateErrorMesage(output){
let errorMessage = '';
const messages = [];
output.errorArray.forEach((error)=>{
Function checkFieldLengths
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
function checkFieldLengths(schema, input, processedFieldErrors, path){
const keys = Object.keys(schema);
keys.forEach((key)=>{
switch (key){
case 'allOf':
Function findField
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function findField(schema, field, func){
const fieldCopy = JSON.parse(JSON.stringify(field));
const schemaKeys = Object.keys(schema);
schemaKeys.forEach((key)=>{
if (key === fieldCopy[0]){
Function checkForIndividualIsCitizen
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function checkForIndividualIsCitizen(input, processedFieldErrors){
if (input.tempOutfitterFields && input.applicantInfo){
if (!input.applicantInfo.orgType || input.applicantInfo.orgType.toUpperCase() === 'PERSON'){
if ((typeof input.tempOutfitterFields.individualIsCitizen) !== 'boolean'){
processedFieldErrors.errorArray.push(makeErrorObj('tempOutfitterFields.individualIsCitizen', 'missing'));
- 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 deeply nested control flow statements. Open
if (maxLength < fieldLength){
processedFieldErrors.errorArray.push(makeErrorObj(field, 'length', maxLength));
}
Function makeErrorObj
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function makeErrorObj(field, errorType, expectedFieldType, enumMessage, dependency, anyOfFields){
Function checkForOrgName
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function checkForOrgName(input, processedFieldErrors){
if (input.applicantInfo){
if (input.applicantInfo.orgType && input.applicantInfo.orgType.toUpperCase() !== 'PERSON'){
if (!input.applicantInfo.organizationName || input.applicantInfo.organizationName.length <= 0){
processedFieldErrors.errorArray.push(makeErrorObj('applicantInfo.organizationName', 'missing'));
- 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 checkForSmallBusiness
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function checkForSmallBusiness(input, processedFieldErrors){
if (input.tempOutfitterFields && input.applicantInfo){
if (input.applicantInfo.orgType && input.applicantInfo.orgType.toUpperCase() !== 'PERSON'){
if ((typeof input.tempOutfitterFields.smallBusiness) !== 'boolean'){
processedFieldErrors.errorArray.push(makeErrorObj('tempOutfitterFields.smallBusiness', 'missing'));
- 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"