src/controllers/index.js
Function routeRequest
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
Open
const routeRequest = function(req, res){
const reqPath = `/${req.params[0]}`;
const reqMethod = req.method.toLowerCase();
- Read upRead up
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
Open
/*
___ ___ ___ _ _ _ ___ ___
| __/ __| ___| _ \___ _ _ _ __ (_) |_ /_\ | _ \_ _|
| _|\__ \ / -_) _/ -_) '_| ' \| | _| / _ \| _/| |
Function getControlNumber
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const getControlNumber = function(req, res, reqData){
const pathData = reqData.schema;
const fileTypes = {
'gud': 'guideDocumentation',
'arf': 'acknowledgementOfRiskForm',
Function postApplication
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const postApplication = function(req, res, reqData){
const pathData = reqData.schema;
const body = util.getBody(req);
Function routeRequest
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const routeRequest = function(req, res){
const reqPath = `/${req.params[0]}`;
const reqMethod = req.method.toLowerCase();
Function saveAndUploadFiles
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function saveAndUploadFiles(req, res, possbileFiles, files, controlNumber, application, callback){
const asyncTasks = [];
possbileFiles.forEach((fileConstraints)=>{
Function apiSchemaData
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
function apiSchemaData(apiSchema, reqPath){
if (apiSchema) {
for (const k in apiSchema.paths) {
- Read upRead up
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 getControlNumberFileName
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const getControlNumberFileName = function(req, res, reqData) {
const controlNumber = reqData.matches.controlNumber;
const fileName = reqData.matches.fileName;
Function saveAndUploadFiles
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function saveAndUploadFiles(req, res, possbileFiles, files, controlNumber, application, callback){
Avoid deeply nested control flow statements. Open
Open
if (!apiSchema.paths[apiPath][reqMethod].responses['200']) {
return error.sendError(req, res, 500, 'No endpoint success found.');
}
else {
Avoid too many return
statements within this function. Open
Open
return error.sendError(req, res, 404, 'Invalid endpoint.');