src/config/mongoose-deep-populate.js
Function exports
has 237 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports = function (mongoose) {
if (mongoose == null) {
throw new Error('An instance of mongoose needs passing in')
}
Function exports
has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring. Open
Open
module.exports = function (mongoose) {
if (mongoose == null) {
throw new Error('An instance of mongoose needs passing in')
}
- 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 patchQueryPrototype
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function patchQueryPrototype() {
var Query = mongoose.Query
, _exec = Query.prototype.exec
if (mongoose.Query.prototype.deepPopulate != null) {
Function createParams
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function createParams(model, docs, paths, options, lean) {
var rewrite = options.rewrite
, whitelist = options.whitelist
, populate = options.populate
Function populate
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function populate(opts, level, cb) {
var docs = opts.docs
, paths = opts.paths
, lvlPaths = paths.filter(function (path) { return (path.split('.').length - 1) === level })
, remained = lvlPaths.length
Function exec
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Query.prototype.exec = function (op, cb) {
var deepPopulate = this._deepPopulates
if (!deepPopulate) {
return _exec.call(this, op, cb)
}
Function execute
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function execute(model, docs, paths, options, defaultOptions, lean, cb) {
Function createParams
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function createParams(model, docs, paths, options, lean) {
Function deepPopulate
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function deepPopulate(model, docs, paths, options, cb) {