Showing 39 of 148 total issues
File model.spec.js
has 854 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* Testing Dependencies */
import sinon from "sinon";
import Database from "almaden";
import Collection from "../lib/collection.js";
import Model from "../../";
Model
has 37 functions (exceeds 20 allowed). Consider refactoring. Open
export default class Model {
/**
* @param {Object.<String,*>} [initialAttributes] Provide default values for attributes by passing a Key-Value Object.
* @constructor
*/
Function argumentsEqual
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
[argumentsEqual](argumentsA, argumentsB) {
if (argumentsA === argumentsB) {
return true;
} else {
if (argumentsA.length === argumentsB.length) {
- 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
File modelFinder.js
has 357 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* Dependencies */
import inflect from "jargon";
import privateData from "incognito";
/* Private Symbols */
Function isPresent
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
export default function isPresent(associationName, callback) {
const model = this;
const defaultErrorMessage = "must be present on " + model.constructor.name;
//apiKey
- 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
File index.js
has 320 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* Component Dependencies */
import Async from "flowsync";
import inflect from "jargon";
import privateData from "incognito";
ModelQuery
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
export class ModelQuery {
constructor(ModelConstructor, options) {
const _ = privateData(this);
_.ModelConstructor = ModelConstructor;
Function saveOrUpdate
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
function saveOrUpdate(callback) {
let now = new Datetime();
const _ = privateData(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
Function isPresent
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function isPresent(associationName, callback) {
const model = this;
const defaultErrorMessage = "must be present on " + model.constructor.name;
//apiKey
Function equalTo
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
equalTo(query) {
const ourChain = this.chain;
const theirChain = query.chain;
let isEqual = true;
- 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 invalidAttributes
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
invalidAttributes(callback) {
const _ = privateData(this);
const attributeNamesWithValidators = Object.keys(_.validations);
const compileInvalidAttributeList = (errors, validatorMessages) => {
- 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 fetchByHasOne
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
function fetchByHasOne(associationName, associations, callback) {
const modelFinder = new ModelFinder(this.database);
const association = associations[associationName];
const ModelClass = association.constructor;
Function addAssociation
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function addAssociation (associationDetails) {
const association = {
parent: this,
type: associationDetails.type,
constructor: associationDetails.constructor
Function invalidAttributes
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
invalidAttributes(callback) {
const _ = privateData(this);
const attributeNamesWithValidators = Object.keys(_.validations);
const compileInvalidAttributeList = (errors, validatorMessages) => {
Function fetchFromDatabase
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
function fetchFromDatabase(fields = [this.primaryKey], callback = undefined) {
let database = this.database;
if (!database) { throw new Error("Cannot fetch without Model.database set."); }
let chain = database
Function saveOrUpdate
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
function saveOrUpdate(callback) {
let now = new Datetime();
const _ = privateData(this);
Function symbols.callDeep
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
[symbols.callDeep] (methodName, predicate, callback) {
const associationNames = Object.keys(this.associations);
Async.mapParallel(
associationNames,
Function fetch
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
fetch(callback) {
function processWhereCondition(value) {
if (typeof value === "string") {
const snakeCasedValue = inflect(value).snake.toString();
return snakeCasedValue;
Function performDelete
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function performDelete(callback) {
const _ = privateData(this);
if (_.mockDelete) {
if(_.softDelete) {
this.deletedAt = new Datetime();
- 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 fetchByHasMany
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function fetchByHasMany(associationName, associations, callback) {
const association = associations[associationName];
if (association.through) {
const throughAssociation = associations[association.through];