yoctore/yocto-mongoose

View on GitHub

Showing 32 of 82 total issues

File index.js has 481 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

var logger        = require('yocto-logger');
var mongoose      = require('mongoose');
var _             = require('lodash');
Severity: Minor
Found in src/index.js - About 7 hrs to fix

    Function addModel has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

    YMongoose.prototype.addModel = function (value) {
      // create async
      var deferred = Q.defer();
    
      // is Ready ??
    Severity: Minor
    Found in src/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 addModel has 104 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    YMongoose.prototype.addModel = function (value) {
      // create async
      var deferred = Q.defer();
    
      // is Ready ??
    Severity: Major
    Found in src/index.js - About 4 hrs to fix

      Function add has 103 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Method.prototype.add = function (schema, path, items, modelName, redis) {
        // valid params first
        if (_.isString(path) && _.isArray(items) && !_.isEmpty(path) && !_.isEmpty(items) &&
           _.isObject(schema) && (schema instanceof Schema) &&
           _.isString(modelName) && !_.isEmpty(modelName)) {
      Severity: Major
      Found in src/modules/method/index.js - About 4 hrs to fix

        Function load has 84 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        YMongoose.prototype.load = function () {
          // Create our deferred object, which we will use in our promise chain
          var deferred = Q.defer();
        
          var errors  = [];   // list of errors
        Severity: Major
        Found in src/index.js - About 3 hrs to fix

          Function setPath has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

          YMongoose.prototype.setPath = function (directory, stype) {
            // default type value
            var types = {
              model       : { ext : 'json', name : 'model' },
              validator   : { ext : 'js', name  : 'validator' },
          Severity: Minor
          Found in src/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 exports has 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = function (grunt) {
            // init config
            grunt.initConfig({
              // default package
              pkg       : grunt.file.readJSON('package.json'),
          Severity: Major
          Found in Gruntfile.js - About 2 hrs to fix

            Function connect has 53 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            RedisUtils.prototype.connect = function (hosts, options, defaultExpireTime, cluster) {
              // validation schema
              var schema = joi.array().required().items(
                joi.object().keys({
                  host      : joi.string().required().empty().default('127.0.0.1'),
            Severity: Major
            Found in src/modules/utils/redis.js - About 2 hrs to fix

              Function connect has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

              YMongoose.prototype.connect = function (url, options) {
                // Create our deferred object, which we will use in our promise chain
                var deferred = Q.defer();
              
                // try connect
              Severity: Minor
              Found in src/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

              Function connect has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              YMongoose.prototype.connect = function (url, options) {
                // Create our deferred object, which we will use in our promise chain
                var deferred = Q.defer();
              
                // try connect
              Severity: Minor
              Found in src/index.js - About 1 hr to fix

                Function setPath has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                YMongoose.prototype.setPath = function (directory, stype) {
                  // default type value
                  var types = {
                    model       : { ext : 'json', name : 'model' },
                    validator   : { ext : 'js', name  : 'validator' },
                Severity: Minor
                Found in src/index.js - About 1 hr to fix

                  Function connect has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                  RedisUtils.prototype.connect = function (hosts, options, defaultExpireTime, cluster) {
                    // validation schema
                    var schema = joi.array().required().items(
                      joi.object().keys({
                        host      : joi.string().required().empty().default('127.0.0.1'),
                  Severity: Minor
                  Found in src/modules/utils/redis.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

                  Function create has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  Crud.prototype.create = function (value) {
                    // Create our deferred object, which we will use in our promise chain
                    var deferred = Q.defer();
                    // create default instance model
                    var model = !_.isFunction(this.save) ? new this() : this;
                  Severity: Minor
                  Found in src/modules/crud/index.js - About 1 hr to fix

                    Function add has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    Validator.prototype.add = function (schema, path, name, modelName) {
                      // valid params first
                      if (_.isString(path) && _.isString(name) && !_.isEmpty(path) && !_.isEmpty(name) &&
                         _.isObject(schema) && (schema instanceof Schema) &&
                         _.isString(modelName) && !_.isEmpty(modelName)) {
                    Severity: Minor
                    Found in src/modules/validator/index.js - About 1 hr to fix

                      Consider simplifying this complex logical expression.
                      Open

                        if (_.isString(path) && _.isString(name) && !_.isEmpty(path) && !_.isEmpty(name) &&
                           _.isObject(schema) && (schema instanceof Schema) &&
                           _.isString(modelName) && !_.isEmpty(modelName)) {
                          // retrieving files
                          var files = glob.sync([ '**/', modelName, '.js'].join(''), {
                      Severity: Critical
                      Found in src/modules/validator/index.js - About 1 hr to fix

                        Consider simplifying this complex logical expression.
                        Open

                          if (_.isString(path) && _.isArray(items) && !_.isEmpty(path) && !_.isEmpty(items) &&
                             _.isObject(schema) && (schema instanceof Schema) &&
                             _.isString(modelName) && !_.isEmpty(modelName)) {
                            // retrieving files
                            var files = glob.sync([ '**/', modelName, '.js'].join(''), {
                        Severity: Critical
                        Found in src/modules/method/index.js - About 1 hr to fix

                          Function get has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          Crud.prototype.get = function (conditions, filter, method) {
                            // process redis usage
                            var redis = this[ method === 'findOne' ? 'getOneRedis' : 'getRedis' ];
                          
                            // defined default method name to use
                          Severity: Minor
                          Found in src/modules/crud/index.js - About 1 hr to fix

                            Function add has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            Crud.prototype.add = function (schema, exclude, redisIncludes, redis) {
                              // valid data ?
                              if ((!_.isObject(schema) && !(schema instanceof Schema)) || !_.isArray(exclude)) {
                                this.logger.warning('[ Crud.add ] - Schema or exclude item given is invalid');
                                // invalid statement
                            Severity: Minor
                            Found in src/modules/crud/index.js - About 1 hr to fix

                              Function get has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                              Open

                              Crud.prototype.get = function (conditions, filter, method) {
                                // process redis usage
                                var redis = this[ method === 'findOne' ? 'getOneRedis' : 'getRedis' ];
                              
                                // defined default method name to use
                              Severity: Minor
                              Found in src/modules/crud/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

                              Function isReady has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                              Open

                              YMongoose.prototype.isReady = function (showErrors) {
                                // show errors ?
                                if (showErrors) {
                                  // check connection
                                  if (!this.isConnected()) {
                              Severity: Minor
                              Found in src/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

                              Severity
                              Category
                              Status
                              Source
                              Language