Showing 19 of 24 total issues
Function swaggerUiFrontend
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function swaggerUiFrontend(config = {}) {
if (config.title === undefined) {
config.title = 'nanoexpress - Swagger UI';
}
if (config.path === undefined) {
Function swaggerUiFrontendHandler
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
return async function swaggerUiFrontendHandler(req, res) {
if (config.url === undefined) {
config.url = `//${
req.headers !== undefined ? req.headers.host : req.getHeader('host')
}/docs/swagger.json`;
Function fileUpload
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
export default function fileUpload(config = { limit: '256mb' }) {
const FILE_SIZE_LIMIT = sizeConvert(config.limit);
return async function fileUploadHandler(req, res) {
const contentType =
(req.headers && req.headers['content-type']) ||
- 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 load
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
export default function load(
swaggerObject,
config,
ajvConfig = {
removeAdditional: 'all',
- 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 bodyParser
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
export default function bodyParser(config = {}) {
return async function bodyParseHandler(req) {
const { headers, body } = req;
if (headers && body) {
- 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 graphql
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
export default function graphql(schema, root) {
const cache = {};
// eslint-disable-next-line @typescript-eslint/naming-convention
const jitOptions = { customJSONSerializer: true };
return async function graphqlHandler(req, res) {
- 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 redoc
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function redoc(config = {}) {
config = {
title: 'nanoexpress - ReDoc',
path: '/docs/',
...config
Function staticMiddleware
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
export default function staticMiddleware(path, config) {
// Reduce risk of importing files out-of-folder
if (path.length > 4 && path.charAt(path.length) !== '/') {
path += '/';
}
- 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 graphql
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function graphql(schema, root) {
const cache = {};
// eslint-disable-next-line @typescript-eslint/naming-convention
const jitOptions = { customJSONSerializer: true };
return async function graphqlHandler(req, res) {
Function redocHandler
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
return async function redocHandler(req, res) {
if (config.url === undefined) {
config.url = `http://${
req.headers ? req.headers.origin : req.getHeader('host')
}/docs/swagger.json`;
Function fileUploadHandler
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
return async function fileUploadHandler(req, res) {
const contentType =
(req.headers && req.headers['content-type']) ||
req.getHeader('content-type');
const contentLength =
Function graphqlHandler
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
return async function graphqlHandler(req, res) {
const { headers, body } = req;
if (headers && body) {
const contentType = headers['content-type'];
Function swaggerUiFrontend
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export default function swaggerUiFrontend(config = {}) {
if (config.title === undefined) {
config.title = 'nanoexpress - Swagger UI';
}
if (config.path === undefined) {
- 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 sizeConvert
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function sizeConvert(size) {
let divideRatio = 1;
switch (size.toLowerCase().substr(-2)) {
case 'kb': {
Function importize
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
const importize = ({ path: _path, raw }, directory) => {
if (path && !raw) {
const resolveFile = path.join(directory.substring(1), _path);
const readBuffer = fs.readFileSync(resolveFile, 'utf-8');
- 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 staticMiddleware
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export default function staticMiddleware(path, config) {
// eslint-disable-next-line consistent-return
return async function handleServe(req, res) {
if (!res[resAbortHandler]) {
res.onAborted(() => {
- 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
Consider simplifying this complex logical expression. Open
if (enableSmartFunctions && compiledJson && !this._serialized) {
this._route._middlewares.push(async (req, res) => {
const bodyContentType = req.headers['content-type'] || 'application/json';
const responseContentType = req.headers.accept || bodyContentType;
Function redoc
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export default function redoc(config = {}) {
config = {
title: 'nanoexpress - ReDoc',
path: '/docs/',
...config
- 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 formidable
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export default function formidable(config, initialize) {
const form = Formidable(config ?? { multiples: true });
if (typeof initialize === 'function') {
initialize(form);
}
- 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"