nci-ats/fs-middlelayer-api

View on GitHub

Showing 43 of 61 total issues

Function exports has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(sequelize, DataTypes) {
const applications = sequelize.define('applications', {
id: { type: DataTypes.UUID, primaryKey: true, defaultValue: DataTypes.UUIDV4 },
controlNumber: { type: DataTypes.STRING(50), field: 'control_number' },
formName: { type: DataTypes.STRING(100), field: 'form_name' },
Severity: Minor
Found in src/models/applications.js - About 1 hr to fix

    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;
    Severity: Minor
    Found in src/controllers/fileValidation.js - About 1 hr to fix

      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) {
       
       
      Severity: Minor
      Found in src/controllers/index.js - About 1 hr to fix

      Function getApplication has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const getApplication = function(cNum, callback){
       
      models.applications.findOne({
      where: {
      controlNumber: cNum
      Severity: Minor
      Found in src/controllers/db.js - About 1 hr to fix

        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}`;
        Severity: Minor
        Found in src/controllers/basic.js - About 1 hr to fix

          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;
           
           
          Severity: Minor
          Found in src/controllers/index.js - About 1 hr to fix

            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' },
            Severity: Minor
            Found in src/models/files.js - About 1 hr to fix

              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]){
              Severity: Minor
              Found in src/controllers/validation.js - About 1 hr to fix

                Function saveAndUploadFiles has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function saveAndUploadFiles(req, res, possbileFiles, files, controlNumber, application, callback){
                Severity: Major
                Found in src/controllers/index.js - About 50 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                  if (field.fromIntake){
                  splitPath.forEach((sp)=>{
                  if (bodyField[sp]){
                  bodyField = bodyField[sp];
                  }
                  Severity: Major
                  Found in src/controllers/basic.js - About 45 mins to fix

                    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'));
                    Severity: Minor
                    Found in src/controllers/validation.js - About 45 mins to fix

                    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++) {
                    Severity: Major
                    Found in src/routes/api/index.js - About 45 mins to fix

                      Function makeErrorObj has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      function makeErrorObj(field, errorType, expectedFieldType, enumMessage, dependency, anyOfFields){
                      Severity: Minor
                      Found in src/controllers/validation.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                        if (maxLength < fieldLength){
                        processedFieldErrors.errorArray.push(makeErrorObj(field, 'length', maxLength));
                        }
                        Severity: Major
                        Found in src/controllers/validation.js - About 45 mins to fix

                          Function postRequest has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          function postRequest(res, apiCallsObject, fieldsObj, responseKey, requestKey, requestPath){
                          Severity: Minor
                          Found in src/controllers/basic.js - About 45 mins to fix

                            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 {
                            Severity: Major
                            Found in src/controllers/index.js - About 45 mins to fix

                              Function sendError has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              const sendError = function(req, res, code, message, errors){
                              Severity: Minor
                              Found in src/controllers/errors/error.js - About 35 mins to fix

                                Function buildGetResponse has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                function buildGetResponse(cnData, applicationData, schemaData, jsonData, getSchema){
                                Severity: Minor
                                Found in src/controllers/get.js - About 35 mins to fix

                                  Function getTopLevelField has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                  function getTopLevelField(intakeField, cnData, getSchema, jsonData, key){
                                  Severity: Minor
                                  Found in src/controllers/get.js - About 35 mins to fix

                                    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'));
                                    Severity: Minor
                                    Found in src/controllers/validation.js - About 35 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language