File Definition.js
has 430 lines of code (exceeds 250 allowed). Consider refactoring. Open
const Promise = require('bluebird');
const Collection = require('./Collection');
const utils = require('./utils');
const _ = require('lodash');
const debug = require('debug');
Definition
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
class Definition {
constructor(factory, name, model) {
const creatingFromCopy = factory instanceof Definition;
const defaultRetries = 1;
Function _doCreate
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
_doCreate(saved) {
const isRootCreation = !saved;
let createdModel;
if (isRootCreation) {
Function getValidAssociation
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
getValidAssociation(as, type) {
if (!this.model) {
throw new Error(
'No model defined for factory ' +
this.name +
Function retryCreate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
async retryCreate(saved) {
let tries = 0;
let out;
let reason;
- 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 addOptionsToConfig
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
addOptionsToConfig(options) {
if (!this.model) {
throw new Error(
'No model defined for factory ' +
this.name +
- 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 constructor
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
constructor(factory, name, model) {
const creatingFromCopy = factory instanceof Definition;
const defaultRetries = 1;
this.creationRetries = parseInt(process.env.AFA_RETRIES, 10);
- 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"