Showing 43 of 61 total issues
Function createContact
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createContact(fieldsObj, person, apiCallsObject){
return new Promise(function(fulfill, reject){
let contactField, createPersonOrOrgURL, responseKey;
if (person){
contactField = fieldsObj['/contact/person'];
Function generateFileErrors
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function generateFileErrors(output, error, messages){
const reqFile = `${validation.makePathReadable(error.field)} is a required file.`;
const small = `${validation.makePathReadable(error.field)} cannot be an empty file.`;
const large = `${validation.makePathReadable(error.field)} cannot be larger than ${error.expectedFieldType} MB.`;
let invExt, invMime;
Function apiSchemaData
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function apiSchemaData(apiSchema, reqPath){
if (apiSchema) {
for (const k in apiSchema.paths) {
- 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 getApplication
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const getApplication = function(cNum, callback){
models.applications.findOne({
where: {
controlNumber: cNum
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 getControlNumberFileName
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
const getControlNumberFileName = function(req, res, reqData) {
const controlNumber = reqData.matches.controlNumber;
const fileName = reqData.matches.fileName;
Function getFromBasic
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getFromBasic(req, res, controlNumber){
return new Promise(function (fulfill, reject){
const applicationCheck = `${SUDS_API_URL}/application/${controlNumber}`;
Function exports
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(sequelize, DataTypes) {
const files = sequelize.define('files', {
id: { type: DataTypes.UUID, primaryKey: true, defaultValue: DataTypes.UUIDV4 },
applicationId: { type: DataTypes.UUID, field: 'application_id' },
fileType: { type: DataTypes.STRING(10), field: 'file_type' },
Function saveAndUploadFiles
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
function saveAndUploadFiles(req, res, possbileFiles, files, controlNumber, application, callback){
Avoid deeply nested control flow statements. Open
if (apiSchema.paths[k].hasOwnProperty(l)) {
if (apiSchema.paths[k][l].parameters) {
for (let i = 0; i < apiSchema.paths[k][l].parameters.length; i++) {
Function makeErrorObj
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function makeErrorObj(field, errorType, expectedFieldType, enumMessage, dependency, anyOfFields){
Avoid deeply nested control flow statements. Open
if (maxLength < fieldLength){
processedFieldErrors.errorArray.push(makeErrorObj(field, 'length', maxLength));
}
Avoid deeply nested control flow statements. Open
if (field.fromIntake){
splitPath.forEach((sp)=>{
if (bodyField[sp]){
bodyField = bodyField[sp];
}
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
Function postRequest
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function postRequest(res, apiCallsObject, fieldsObj, responseKey, requestKey, requestPath){
Avoid deeply nested control flow statements. Open
if (!apiSchema.paths[apiPath][reqMethod].responses['200']) {
return error.sendError(req, res, 500, 'No endpoint success found.');
}
else {
Function sendError
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
const sendError = function(req, res, code, message, errors){
Function getTopLevelField
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function getTopLevelField(intakeField, cnData, getSchema, jsonData, key){
Function buildGetResponse
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function buildGetResponse(cnData, applicationData, schemaData, jsonData, getSchema){
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"