File helpers.js
has 522 lines of code (exceeds 500 allowed). Consider refactoring. Open
'use strict';
const nconf = require('nconf');
const validator = require('validator');
const querystring = require('querystring');
Function formatApiResponse
has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring. Open
helpers.formatApiResponse = async (statusCode, res, payload) => {
if (res.req.method === 'HEAD') {
return res.sendStatus(statusCode);
}
- 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 notAllowed
has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring. Open
helpers.notAllowed = async function (req, res, error) {
({ error } = await plugins.hooks.fire('filter:helpers.notAllowed', { req, res, error }));
await plugins.hooks.fire('response:helpers.notAllowed', { req, res, error });
if (res.headersSent) {
- 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 getCategoryData
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
async function getCategoryData(cids, uid, selectedCid, states, privilege) {
Function redirect
has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring. Open
helpers.redirect = function (res, url, permanent) {
// this is used by sso plugins to redirect to the auth route
// { external: '/auth/sso' } or { external: 'https://domain/auth/sso' }
if (url.hasOwnProperty('external')) {
const redirectUrl = encodeURI(prependRelativePath(url.external));
- 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"