nci-ats/fs-middlelayer-api

View on GitHub

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'];
Severity: Minor
Found in src/controllers/basic.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

      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
      Severity: Minor
      Found in src/controllers/db.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 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 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 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 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 (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

                        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

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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language