genediazjr/knexshelf

View on GitHub
lib/index.js

Summary

Maintainability
A
4 hrs
Test Coverage

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 = {};
Severity: Minor
Found in lib/index.js - About 6 hrs to fix

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 {
Severity: Minor
Found in lib/index.js - About 3 hrs to fix

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');

Severity: Minor
Found in lib/index.js - About 3 hrs to fix

    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 = {};
    Severity: Major
    Found in lib/index.js - About 2 hrs to fix

      Function generateHapiPlugin has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Wontfix

      exports.generateHapiPlugin = (packageJson, schemas, opts) => {
      
          opts = opts || {};
      
          return {
      Severity: Major
      Found in lib/index.js - About 2 hrs to fix

        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) {
        Severity: Minor
        Found in lib/index.js - About 2 hrs to fix

        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'));
        Severity: Major
        Found in lib/index.js - About 2 hrs to fix

          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) {
          Severity: Major
          Found in lib/index.js - About 2 hrs to fix

            Function initBookshelf has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Wontfix

            exports.initBookshelf = (param, plugins) => {
            
                let bookshelf;
            
                if (param.knex) {
            Severity: Minor
            Found in lib/index.js - About 1 hr to fix

            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}.`);
                                }
            Severity: Major
            Found in lib/index.js - About 45 mins to fix

              There are no issues that match your filters.

              Category
              Status