Showing 47 of 59 total issues
Function middleware
has 35 lines of code (exceeds 30 allowed). Consider refactoring. Open
middleware () {
this[sRouteTree].sort();
return async (ctx, next) => {
if (ctx.method === 'OPTIONS') {
ctx.status = 200;
Function init
has 33 lines of code (exceeds 30 allowed). Consider refactoring. Open
init () {
// set up websocket on server, with session cookie generation
this.wss = new WebSocket.Server({
noServer: true,
maxPayload: this.ravelApp.get('max websocket payload bytes')
Function scan
has 33 lines of code (exceeds 30 allowed). Consider refactoring. Open
Ravel.prototype.scan = function (...basePaths) {
for (const basePath of basePaths) {
const absPath = upath.toUnix(upath.isAbsolute(basePath)
? basePath
: upath.toUnix(upath.posix.join(this.cwd, basePath)));
Function compare
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
static compare (lNode, rNode) {
// catch-all routes have the lowest priority
if (!lNode.catchAll && rNode.catchAll) {
return -1;
} else if (lNode.catchAll && !rNode.catchAll) {
- 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 getModule
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
getModule (moduleMap, moduleName) {
if (moduleMap[moduleName] !== undefined) {
// if the requested module is in our map of predefined valid stuff
return moduleMap[moduleName];
} else if (this[sRavelInstance][coreSymbols.moduleFactories][moduleName] !== 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 sOpenConnections
has 32 lines of code (exceeds 30 allowed). Consider refactoring. Open
TransactionFactory.prototype[sOpenConnections] = function (providerNames, closers) {
// guarantee provider names are unique
let uniqueProviderNames = new Set();
providerNames.forEach(n => uniqueProviderNames.add(n));
uniqueProviderNames = Array.from(uniqueProviderNames);
Function authconfig
has 31 lines of code (exceeds 30 allowed). Consider refactoring. Open
function authconfig (target) {
Metadata.putClassMeta(target.prototype, '@authconfig', 'enabled', true);
if (!target.prototype.serializeUser) {
target.prototype.serializeUser = function (profile) { // eslint-disable-line no-unused-vars
Function createClient
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function createClient (ravelInstance, restrict = true) {
const localRedis = ravelInstance.get('redis port') === undefined || ravelInstance.get('redis host') === undefined;
ravelInstance.on('post init', () => {
ravelInstance.$log.info(localRedis
? 'Using in-memory key-value store. Please do not scale this app horizontally.'
- 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
} else if (options.okCode === httpCodes.PARTIAL_CONTENT && response.body !== undefined &&
options !== undefined && options.start !== undefined &&
options.end !== undefined && options.count !== undefined) {
response.set('Content-Range', 'items ' + options.start + '-' + options.end + '/' + options.count);
}
Function buildRoute
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function buildRoute (ravelInstance, routes, koaRouter, methodName, meta) {
Function inject
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const inject = function (...rest) {
return function (target) {
if (rest.length === 0) {
throw new $err.NotFound(`Empty @inject supplied on ${typeof target}`);
}
- 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 authenticated
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function authenticated (...args) {
if (args.length === 3 && typeof args[0].constructor === 'function') {
Metadata.putMethodMeta(args[0], args[1], '@authenticated', 'config', Object.create(null));
} else if (args.length === 1 && typeof args[0] === 'function') {
// handle @authenticated at the class-level without arguments
- 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 exports
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function (ravelInstance, router) {
/**
* Retrieve the first registered Module which is decorated with `@authconfig`.
*
* @returns {object} The first `@authconfig` `Module`.
- 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
Avoid too many return
statements within this function. Open
return 1;
Avoid too many return
statements within this function. Open
return 0;
Avoid too many return
statements within this function. Open
return new RouteTreeResult(keyValues, child.middleware, child.composedMiddleware);
Avoid too many return
statements within this function. Open
return 0;
Avoid too many return
statements within this function. Open
return -1;
Avoid too many return
statements within this function. Open
return 1;
Avoid too many return
statements within this function. Open
return;