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');
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 ??
- 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 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 ??
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)) {
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
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' },
- 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 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'),
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'),
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
- 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 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
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' },
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'),
- 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 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;
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)) {
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(''), {
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(''), {
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
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
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
- 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 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()) {
- 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"