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

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

                              Duplicated Code

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Tuning

                              This issue has a mass of 120.

                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                              Refactorings

                              Further Reading

                              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

                              Duplicated Code

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Tuning

                              This issue has a mass of 120.

                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                              Refactorings

                              Further Reading

                              Severity
                              Category
                              Status
                              Source
                              Language