Showing 32 of 82 total issues
Function load
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Enums.prototype.load = function (path) {
try {
// test is a valid path
if (!_.isString(path) || _.isEmpty(path)) {
throw 'Invalid path given.';
Function disconnect
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
YMongoose.prototype.disconnect = function () {
// Create our deferred object, which we will use in our promise chain
var deferred = Q.defer();
// try to disconnect
Function listenEvents
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
RedisUtils.prototype.listenEvents = function () {
// default events
var events = [
{ key : 'connect', message : 'is connecting' },
{ key : 'ready', message : 'is ready' },
Function create
has a Cognitive Complexity of 9 (exceeds 5 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;
- 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 (err) {
// reject with error message
deferred.reject([ '[ Crud.create ] - Indexes creation failed :', err ].join(' '));
} else {
// resolve default statement
Avoid deeply nested control flow statements. Open
if (item.redis) {
// has custom redis expire time define on schema for specific key/method ?
if (!_.isArray(schema.redisExpireTimeByKey)) {
// create default item
schema.redisExpireTimeByKey = [];
Avoid deeply nested control flow statements. Open
if ((item.type === 'post' || item.type === 'pre') &&
_.isString(item.event) && !_.isEmpty(item.event)) {
// debug message
this.logger.debug([ '[ Method.add ] - Adding [', item.type,
' ] hook on current schema for event [', item.event, ']' ].join(' '));
Function add
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Method.prototype.add = function (schema, path, items, modelName, redis) {
Function add
has a Cognitive Complexity of 7 (exceeds 5 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
- 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 get
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Enums.prototype.get = function (name) {
// is a valid string ?
if (_.isString(name) && !_.isEmpty(name)) {
// data is ok so try to get enums from given name
if (_.isArray(this.enums) && !_.isEmpty(this.enums)) {
- 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 load
has a Cognitive Complexity of 6 (exceeds 5 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
- 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 addDefaultIndexes
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
ElasticUtils.prototype.addDefaultIndexes = function (obj) {
// first test
if (!obj || !_.isObject(obj)) {
// default statement
return obj;
- 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"