Showing 10 of 10 total issues
Function find
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
Open
find (modelName, criteria, options) {
const Model = this._getModel(modelName)
const modelOptions = _.defaultsDeep({ }, options,
_.get(this.app.config, 'footprints.models.options'))
- 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 FootprintService.js
has 265 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
'use strict'
const _ = require('lodash')
const Service = require('trails/service')
Function find
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
find (modelName, criteria, options) {
const Model = this._getModel(modelName)
const modelOptions = _.defaultsDeep({ }, options,
_.get(this.app.config, 'footprints.models.options'))
Function destroyAssociation
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
destroyAssociation (parentModelName, parentId, childAttributeName, criteria, options) {
const Model = this._getModel(parentModelName)
if (!Model)
return Promise.reject(new Error('No model found'))
Function createAssociation
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
createAssociation (parentModelName, parentId, childAttributeName, values, options) {
const Model = this._getModel(parentModelName)
if (!Model)
return Promise.reject(new Error('No model found'))
Function update
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
update (modelName, criteria, values, options) {
const Model = this._getModel(modelName)
const modelOptions = _.defaultsDeep({ }, options,
_.get(this.app.config, 'footprints.models.options'))
Function findAssociation
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
findAssociation (parentModelName, parentId, childAttributeName, criteria, options) {
const Model = this._getModel(parentModelName)
if (!Model)
return Promise.reject(new Error('No model found'))
Function updateAssociation
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
updateAssociation (parentModelName, parentId, childAttributeName, criteria, values, options) {
const Model = this._getModel(parentModelName)
if (!Model)
return Promise.reject(new Error('No model found'))
Function update
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
update (modelName, criteria, values, options) {
const Model = this._getModel(modelName)
const modelOptions = _.defaultsDeep({ }, options,
_.get(this.app.config, 'footprints.models.options'))
- 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
Open
return this
.find(parentModelName, parentId, options)
.then((record) => {
if (!record)
return Promise.reject(new Error('No parent record found'))