Function exports
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function(schema, options) {
options = _.defaults(options || {}, DEFAULT_OPTIONS);
var private_paths = getPaths(schema, options);
var refs = getRefs(schema);
- 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 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(schema, options) {
options = _.defaults(options || {}, DEFAULT_OPTIONS);
var private_paths = getPaths(schema, options);
var refs = getRefs(schema);
Function omitPopulated
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function omitPopulated(refs, obj, populated, options) {
for(var i = 0, len = populated.length; i < len; i++) {
var path = populated[i];
var modelName = refs[path] && (_.isArray(refs[path]) ? refs[path][0].ref : refs[path].ref);
var model;
- 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 isPrivate
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function isPrivate(options, node, path) {
if(!node) return false;
// Array case
if(node instanceof Array) {
- 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 too many return
statements within this function. Open
else if(_.includes(options.ignore, path)) return false;
Avoid too many return
statements within this function. Open
else return isPrivate(options, node, path);
Avoid too many return
statements within this function. Open
else return node.private || path[0] === options.prefix;
Avoid too many return
statements within this function. Open
return _.isEmpty(o) ? false : o;
Avoid too many return
statements within this function. Open
else if(node.private === false) return false;