trailsjs/trailpack-mongoose

View on GitHub

Showing 10 of 10 total issues

Function find has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  find (modelName, criteria, options) {
    const Model = this._getModel(modelName)
    const modelOptions = _.defaultsDeep({ }, options,
      _.get(this.app.config, 'footprints.models.options'))

Severity: Minor
Found in api/services/FootprintService.js - About 2 hrs to fix

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

'use strict'

const _ = require('lodash')
const Service = require('trails/service')

Severity: Minor
Found in api/services/FootprintService.js - About 2 hrs to fix

    Function find has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      find (modelName, criteria, options) {
        const Model = this._getModel(modelName)
        const modelOptions = _.defaultsDeep({ }, options,
          _.get(this.app.config, 'footprints.models.options'))
    
    
    Severity: Minor
    Found in api/services/FootprintService.js - About 1 hr to fix

      Function destroyAssociation has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        destroyAssociation (parentModelName, parentId, childAttributeName, criteria, options) {
          const Model = this._getModel(parentModelName)
          if (!Model)
            return Promise.reject(new Error('No model found'))
      
      
      Severity: Minor
      Found in api/services/FootprintService.js - About 1 hr to fix

        Function createAssociation has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          createAssociation (parentModelName, parentId, childAttributeName, values, options) {
            const Model = this._getModel(parentModelName)
            if (!Model)
              return Promise.reject(new Error('No model found'))
        
        
        Severity: Minor
        Found in api/services/FootprintService.js - About 1 hr to fix

          Function update has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            update (modelName, criteria, values, options) {
              const Model = this._getModel(modelName)
              const modelOptions = _.defaultsDeep({ }, options,
                _.get(this.app.config, 'footprints.models.options'))
          
          
          Severity: Minor
          Found in api/services/FootprintService.js - About 1 hr to fix

            Function findAssociation has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              findAssociation (parentModelName, parentId, childAttributeName, criteria, options) {
                const Model = this._getModel(parentModelName)
                if (!Model)
                  return Promise.reject(new Error('No model found'))
            
            
            Severity: Minor
            Found in api/services/FootprintService.js - About 1 hr to fix

              Function updateAssociation has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                updateAssociation (parentModelName, parentId, childAttributeName, criteria, values, options) {
                  const Model = this._getModel(parentModelName)
                  if (!Model)
                    return Promise.reject(new Error('No model found'))
              
              
              Severity: Minor
              Found in api/services/FootprintService.js - About 1 hr to fix

                Function update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  update (modelName, criteria, values, options) {
                    const Model = this._getModel(modelName)
                    const modelOptions = _.defaultsDeep({ }, options,
                      _.get(this.app.config, 'footprints.models.options'))
                
                
                Severity: Minor
                Found in api/services/FootprintService.js - About 35 mins to fix

                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 this
                      .find(parentModelName, parentId, options)
                      .then((record) => {
                        if (!record)
                          return Promise.reject(new Error('No parent record found'))
                Severity: Major
                Found in api/services/FootprintService.js - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language