Showing 38 of 72 total issues
Function destroy
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Instance.prototype.destroy = Promise.method(function(options) {
const self = this;
options = options || {};
Function _touchTimestamps
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Instance.prototype._touchTimestamps = function(timestamps, options) {
options = options || {};
if ( !this.Model._dataHasObjectStructure()
|| (!this.Model.options.timestamps && !this.Model.options.paranoid)
- 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 insert
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Instance.prototype.insert = Promise.method(function(options) {
const self = this;
let report
, timestampsBck;
Function CouchbaseODM
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function CouchbaseODM(options) {
var defaults = {
key: UUID4Key,
refDocKey: RefDocKey,
Function _touchTimestamps
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Instance.prototype._touchTimestamps = function(timestamps, options) {
options = options || {};
if ( !this.Model._dataHasObjectStructure()
|| (!this.Model.options.timestamps && !this.Model.options.paranoid)
Function runHooks
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Hook.runHooks = function(hookType) {
if ( (typeof hookType === 'string' && !HookType.hasOwnProperty(hookType))
&& HookValues.indexOf(hookType) === -1
) {
Function build
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Model.prototype.build = function(data, options) {
const defaults = {
isNewRecord: true,
sanitize: false
};
Function attachGetByRefDocMethods
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function attachGetByRefDocMethods() {
const self = this;
const getByRefDocPrefix = 'getBy';
const refDocs = this.options.indexes.refDocs;
Function getByIdOrFail
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Model.prototype.getByIdOrFail = Promise.method(function(id, options) {
let key = id;
const actions = [];
const defaults = {
paranoid: 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 validate
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
validate: function(schema, data, parentSchema, dataPath, parentData, prop) {
Function validate
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
validate: function(schema, data, parentSchema, dataPath, parentData, prop) {
Avoid deeply nested control flow statements. Open
if (!_.isEmpty(_schema)) {
_.set(out, ['items'], _schema);
}
Function generate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
RefDocKey.prototype.generate = Promise.method(function(instance) {
let id = "";
let instanceData = instance.getData();
- 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 _cloneData
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Instance.prototype._cloneData = function(customizer) {
return _.cloneDeepWith(this.getData(), function(val) {
if (customizer instanceof Function) {
let resolved = customizer(val);
if (resolved !== undefined) {
- 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
return Promise.reject(reason);
Function removeHook
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Hook.removeHook = function(hookType, name) {
if (HookValues.indexOf(HookType[hookType]) === -1) {
throw new HookError('Attempted to remove hook: ' + name + ' of invalid hook type.');
}
- 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 Model
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function Model(name, schema, options) {
if (!name || (typeof name !== "string" && !(name instanceof String) )) {
throw new ModelError("Model's name must be non-empty string value");
}
- 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 build
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function build(options) {
const defaults = {
_data: true, //data json references
allErrors: false,
verbose: true, //include validated data in 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"