nci-ats/fs-middlelayer-api

View on GitHub

Showing 61 of 61 total issues

File validation.js has 417 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 
___ ___ ___ _ _ _ ___ ___
| __/ __| ___| _ \___ _ _ _ __ (_) |_ /_\ | _ \_ _|
| _|\__ \ / -_) _/ -_) '_| ' \| | _| / _ \| _/| |
Severity: Minor
Found in src/controllers/validation.js - About 6 hrs to fix

    Function getAllFileNames has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

    function getAllFileNames() {
     
    const allFilesNames = [];
     
    if (apiSchema) {
    Severity: Minor
    Found in src/routes/api/index.js - About 5 hrs to fix

    Function routeRequest has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

    const routeRequest = function(req, res){
     
    const reqPath = `/${req.params[0]}`;
    const reqMethod = req.method.toLowerCase();
     
     
    Severity: Minor
    Found in src/controllers/index.js - About 5 hrs to fix

    File basic.js has 348 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     
    ___ ___ ___ _ _ _ ___ ___
    | __/ __| ___| _ \___ _ _ _ __ (_) |_ /_\ | _ \_ _|
    | _|\__ \ / -_) _/ -_) '_| ' \| | _| / _ \| _/| |
    Severity: Minor
    Found in src/controllers/basic.js - About 4 hrs to fix

      Function postToBasic has 100 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function postToBasic(req, res, sch, body){
       
      return new Promise(function (fulfill, reject){
       
      const apiCallsObject = {
      Severity: Major
      Found in src/controllers/basic.js - About 4 hrs to fix

        Function getBasicFields has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

        function getBasicFields(fieldsToBasic, body, autoPopValues){
        const postObjs = {}, requestsObj = {};
        fieldsToBasic.forEach((field)=>{
        const key = Object.keys(field)[0];
        const whereToStore = field[key].store;
        Severity: Minor
        Found in src/controllers/basic.js - About 3 hrs to fix

        File index.js has 286 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /*
         
        ___ ___ ___ _ _ _ ___ ___
        | __/ __| ___| _ \___ _ _ _ __ (_) |_ /_\ | _ \_ _|
        | _|\__ \ / -_) _/ -_) '_| ' \| | _| / _ \| _/| |
        Severity: Minor
        Found in src/controllers/index.js - About 2 hrs to fix

          Function getControlNumber has 68 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const getControlNumber = function(req, res, reqData){
          const pathData = reqData.schema;
          const fileTypes = {
          'gud': 'guideDocumentation',
          'arf': 'acknowledgementOfRiskForm',
          Severity: Major
          Found in src/controllers/index.js - About 2 hrs to fix

            Function postApplication has 62 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const postApplication = function(req, res, reqData){
             
            const pathData = reqData.schema;
             
            const body = util.getBody(req);
            Severity: Major
            Found in src/controllers/index.js - About 2 hrs to fix

              Function getBasicFields has 56 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function getBasicFields(fieldsToBasic, body, autoPopValues){
              const postObjs = {}, requestsObj = {};
              fieldsToBasic.forEach((field)=>{
              const key = Object.keys(field)[0];
              const whereToStore = field[key].store;
              Severity: Major
              Found in src/controllers/basic.js - About 2 hrs to fix

                Function getFilesZip has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function getFilesZip(controlNumber, dbFiles, res, callback){
                const zipper = new s3zipper(config.getStoreConfig());
                 
                const filePath = `${controlNumber}`;
                 
                 
                Severity: Major
                Found in src/controllers/store.js - About 2 hrs to fix

                  Function routeRequest has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const routeRequest = function(req, res){
                   
                  const reqPath = `/${req.params[0]}`;
                  const reqMethod = req.method.toLowerCase();
                   
                   
                  Severity: Minor
                  Found in src/controllers/index.js - About 1 hr to fix

                    Function generateErrorMesage has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function generateErrorMesage(output){
                     
                    let errorMessage = '';
                    const messages = [];
                    output.errorArray.forEach((error)=>{
                    Severity: Minor
                    Found in src/controllers/validation.js - About 1 hr to fix

                      Function buildGetResponse has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function buildGetResponse(cnData, applicationData, schemaData, jsonData, getSchema){
                       
                      let key;
                      for (key in schemaData){
                      Severity: Minor
                      Found in src/controllers/get.js - About 1 hr to fix

                      Function buildAutoPopulatedFields has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function buildAutoPopulatedFields(fieldsToBuild, body){
                      const output = {};
                      fieldsToBuild.forEach((field)=>{
                      const key = Object.keys(field)[0];
                      const fieldMakeUp = [];
                      Severity: Minor
                      Found in src/controllers/basic.js - About 1 hr to fix

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

                          Function getFieldsToStore has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function getFieldsToStore(schema, fieldsToStore, path, saveLocation){
                          const keys = Object.keys(schema);
                          keys.forEach((key)=>{
                          switch (key){
                          case 'allOf':
                          Severity: Minor
                          Found in src/controllers/db.js - About 1 hr to fix

                            Function saveAndUploadFiles has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function saveAndUploadFiles(req, res, possbileFiles, files, controlNumber, application, callback){
                             
                            const asyncTasks = [];
                             
                            possbileFiles.forEach((fileConstraints)=>{
                            Severity: Minor
                            Found in src/controllers/index.js - About 1 hr to fix

                              Identical blocks of code found in 2 locations. Consider refactoring.
                              Open

                              request(getApplicationOptions)
                              .then(function(response){
                              return fulfill(response);
                              })
                              .catch(function(err){
                              Severity: Major
                              Found in src/controllers/basic.js and 1 other location - About 1 hr to fix
                              src/controllers/basic.js on lines 391..458

                              Identical blocks of code found in 2 locations. Consider refactoring.
                              Open

                              request(getContactOptions)
                              .then(function(res){
                              if (person){
                              apiCallsObject.GET['/contact/lastname/{lastName}'].response = res;
                              }
                              Severity: Major
                              Found in src/controllers/basic.js and 1 other location - About 1 hr to fix
                              src/controllers/basic.js on lines 328..344
                              Severity
                              Category
                              Status
                              Source
                              Language