Showing 24 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'];
Similar blocks of code found in 3 locations. Consider refactoring. Open
if (prepareCookiesValidator && req.cookies) {
if (!prepareCookiesValidator(req.cookies)) {
if (!errors) {
errors = {};
}
- Read upRead up
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 64.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
if (prepareQueriesValidator && req.query) {
if (!prepareQueriesValidator(req.query)) {
if (!errors) {
errors = {};
}
- Read upRead up
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 64.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
if (prepareHeadersValidator && req.headers) {
if (!prepareHeadersValidator(req.headers)) {
if (!errors) {
errors = {};
}
- Read upRead up
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 64.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (req.path === config.path) {
return res.end(`
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
- Read upRead up
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 51.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76