Function buildShelf
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Wontfix
exports.buildShelf = async (conns, schemas, opts) => {
const shelf = exports.initConns(conns);
shelf.models = {};
shelf.methods = {};
- 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 generateHapiPlugin
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Wontfix
exports.generateHapiPlugin = (packageJson, schemas, opts) => {
opts = opts || {};
return {
- 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 301 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
const Joi = require('@hapi/joi');
const Queries = require('./queries');
Function buildShelf
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
exports.buildShelf = async (conns, schemas, opts) => {
const shelf = exports.initConns(conns);
shelf.models = {};
shelf.methods = {};
Function generateHapiPlugin
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
exports.generateHapiPlugin = (packageJson, schemas, opts) => {
opts = opts || {};
return {
Function createTable
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Wontfix
exports.createTable = async (schema, knex, opts) => {
opts = Object.assign({}, schema.options, opts);
if (knex && knex.knex) {
- 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 register
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
register: async function (server, options) {
if (!options.conns && !opts.conns) {
return Promise.reject(new Error('Missing connections'));
Function createTable
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
exports.createTable = async (schema, knex, opts) => {
opts = Object.assign({}, schema.options, opts);
if (knex && knex.knex) {
Function initBookshelf
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Wontfix
exports.initBookshelf = (param, plugins) => {
let bookshelf;
if (param.knex) {
- 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 deeply nested control flow statements. Open
if (methodNames.indexOf(mkey) > -1) {
throw new Error(`Duplicate method name ${mkey}.`);
}