nci-ats/fs-middlelayer-api

View on GitHub

Showing 43 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

    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 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

    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

    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

        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

        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

                      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 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 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

                            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 validateFile has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                              Open

                              function validateFile(uploadFile, validationConstraints, fileName){
                              
                                  const fileInfo = getFileInfo(uploadFile, validationConstraints);
                                  const constraints = validationConstraints[fileName];
                                  const regex = `(^${constraints.validExtensions.join('$|^')}$)`;
                              Severity: Minor
                              Found in src/controllers/fileValidation.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 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
                                Severity
                                Category
                                Status
                                Source
                                Language