lebretr/sequelize-oracle

View on GitHub
lib/dao-factory.js

Summary

Maintainability
F
3 wks
Test Coverage

Function exports has 1225 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = (function() {
  var DAOFactory = function(name, attributes, options) {
    this.options = Utils._.extend({
      timestamps: true,
      createdAt: 'createdAt',
Severity: Major
Found in lib/dao-factory.js - About 6 days to fix

    Function exports has a Cognitive Complexity of 282 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = (function() {
      var DAOFactory = function(name, attributes, options) {
        this.options = Utils._.extend({
          timestamps: true,
          createdAt: 'createdAt',
    Severity: Minor
    Found in lib/dao-factory.js - About 5 days 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 dao-factory.js has 1235 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    var Utils       = require("./utils")
      , DAO         = require("./dao")
      , DataTypes   = require("./data-types")
      , Util        = require('util')
      , sql         = require('sql')
    Severity: Major
    Found in lib/dao-factory.js - About 3 days to fix

      Function bulkCreate has 135 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        DAOFactory.prototype.bulkCreate = function(records, fieldsOrOptions, options) {
          Utils.validateParameter(fieldsOrOptions, Object, { deprecated: Array, optional: true, index: 2, method: 'DAOFactory#bulkCreate' })
          Utils.validateParameter(options, 'undefined', { deprecated: Object, optional: true, index: 3, method: 'DAOFactory#bulkCreate' })
      
          if (!records.length) {
      Severity: Major
      Found in lib/dao-factory.js - About 5 hrs to fix

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

          DAOFactory.prototype.update = function(attrValueHash, where, options) {
            var self  = this
              , query = null
              , tick  = 0
        
        
        Severity: Major
        Found in lib/dao-factory.js - About 4 hrs to fix

          Function init has 94 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            DAOFactory.prototype.init = function(daoFactoryManager) {
              var self = this
          
              this.daoFactoryManager  = daoFactoryManager
              this.primaryKeys        = {}
          Severity: Major
          Found in lib/dao-factory.js - About 3 hrs to fix

            Function destroy has 89 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              DAOFactory.prototype.destroy = function(where, options) {
                options = options || {}
                options.force = options.force === undefined ? false : Boolean(options.force)
                options.type = QueryTypes.BULKDELETE
            
            
            Severity: Major
            Found in lib/dao-factory.js - About 3 hrs to fix

              Function runSave has 75 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    var runSave = function() {
                      self.runHooks(self.options.hooks.beforeBulkUpdate, attrValueHash, where, function(err, attributes, _where) {
                        if (!!err) {
                          return emitter.emit('error', err)
                        }
              Severity: Major
              Found in lib/dao-factory.js - About 3 hrs to fix

                Function validateIncludedAllElement has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  var validateIncludedAllElement = function(includes, include) {
                    // check 'all' attribute provided is valid
                    var all = include.all
                    delete include.all
                
                
                Severity: Major
                Found in lib/dao-factory.js - About 2 hrs to fix

                  Function scope has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    DAOFactory.prototype.scope = function(option) {
                      var self = Object.create(this)
                        , type
                        , options
                        , merge
                  Severity: Major
                  Found in lib/dao-factory.js - About 2 hrs to fix

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

                      DAOFactory.prototype.find = function(options, queryOptions) {
                        var hasJoin = false
                    
                        // no options defined?
                        // return an emitter which emits null
                    Severity: Major
                    Found in lib/dao-factory.js - About 2 hrs to fix

                      Function refreshAttributes has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        DAOFactory.prototype.refreshAttributes = function() {
                          var self = this
                            , attributeManipulation = {};
                      
                          this.DAO.prototype._customGetters = {}
                      Severity: Major
                      Found in lib/dao-factory.js - About 2 hrs to fix

                        Function validateIncludedElement has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          var validateIncludedElement = function(include, tableNames) {
                            if (!include.hasOwnProperty('daoFactory')) {
                              throw new Error('Include malformed. Expected attributes: daoFactory, as!')
                            }
                        
                        
                        Severity: Major
                        Found in lib/dao-factory.js - About 2 hrs to fix

                          Function DAOFactory has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            var DAOFactory = function(name, attributes, options) {
                              this.options = Utils._.extend({
                                timestamps: true,
                                createdAt: 'createdAt',
                                updatedAt: 'updatedAt',
                          Severity: Minor
                          Found in lib/dao-factory.js - About 1 hr to fix

                            Function runQuery has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                    var runQuery = function(err, records) {
                                      if (!!err) {
                                        return emitter.emit('error', err)
                                      }
                            
                            
                            Severity: Minor
                            Found in lib/dao-factory.js - About 1 hr to fix

                              Function runQuery has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                        var runQuery = function(err, records) {
                                          if (!!err) {
                                            return emitter.emit('error', err)
                                          }
                              
                              
                              Severity: Minor
                              Found in lib/dao-factory.js - About 1 hr to fix

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

                                  var validateIncludedElements = function(options, tableNames) {
                                    tableNames = tableNames || {}
                                    options.includeNames = []
                                    options.includeMap = {}
                                    options.hasSingleAssociation = false
                                Severity: Minor
                                Found in lib/dao-factory.js - About 1 hr to fix

                                  Function addDefaultAttributes has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    var addDefaultAttributes = function() {
                                      var self              = this
                                        , tail = {}
                                        , head = {
                                          id: {
                                  Severity: Minor
                                  Found in lib/dao-factory.js - About 1 hr to fix

                                    Function findOrCreate has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      DAOFactory.prototype.findOrCreate = function (where, defaults, options) {
                                        var self   = this
                                          , values = {}
                                    
                                        options = Utils._.extend({
                                    Severity: Minor
                                    Found in lib/dao-factory.js - About 1 hr to fix

                                      Function findOrBuild has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                        DAOFactory.prototype.findOrInitialize = DAOFactory.prototype.findOrBuild = function (params, defaults, options) {
                                          defaults = defaults || {}
                                          options  = options  || {}
                                      
                                          var self          = this
                                      Severity: Minor
                                      Found in lib/dao-factory.js - About 1 hr to fix

                                        Function next has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                              var next = function() {
                                                if (options.hooks === false) {
                                                  return runQuery()
                                                }
                                        
                                        
                                        Severity: Minor
                                        Found in lib/dao-factory.js - About 1 hr to fix

                                          Consider simplifying this complex logical expression.
                                          Open

                                                if (elem instanceof DAOFactory || elem instanceof Utils.col || elem instanceof Utils.literal || elem instanceof Utils.cast || elem instanceof Utils.fn || elem instanceof Utils.and || elem instanceof Utils.or) {
                                                  return elem
                                                }
                                          Severity: Major
                                          Found in lib/dao-factory.js - About 1 hr to fix

                                            Avoid deeply nested control flow statements.
                                            Open

                                                        if (all.indexOf(types[j]) == -1) {
                                                          all.unshift(types[j])
                                                          i++
                                                        }
                                            Severity: Major
                                            Found in lib/dao-factory.js - About 45 mins to fix

                                              Avoid deeply nested control flow statements.
                                              Open

                                                    if (this.primaryKeyCount === 1) {
                                                      where[primaryKeys[keys[0]]] = options;
                                                      options = where;
                                                    } else if (this.primaryKeyCount < 1) {
                                                      // Revert to default behavior which is {where: [int]}
                                              Severity: Major
                                              Found in lib/dao-factory.js - About 45 mins to fix

                                                Consider simplifying this complex logical expression.
                                                Open

                                                      if (columnValues.hasOwnProperty('unique') && columnValues.unique !== true && columnValues.unique !== false) {
                                                        var idxName = columnValues.unique
                                                        if (typeof columnValues.unique === "object") {
                                                          idxName = columnValues.unique.name
                                                        }
                                                Severity: Major
                                                Found in lib/dao-factory.js - About 40 mins to fix

                                                  Similar blocks of code found in 3 locations. Consider refactoring.
                                                  Open

                                                                var next = function(i) {
                                                                  if (i >= records.length) {
                                                                    return runQuery(null, records)
                                                                  }
                                                  
                                                  
                                                  Severity: Major
                                                  Found in lib/dao-factory.js and 2 other locations - About 5 hrs to fix
                                                  lib/dao-factory.js on lines 1060..1075
                                                  lib/dao-factory.js on lines 1147..1162

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 139.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 3 locations. Consider refactoring.
                                                  Open

                                                                  var next = function(i) {
                                                                    if (i >= records.length) {
                                                                      return finished(null, records)
                                                                    }
                                                  
                                                  
                                                  Severity: Major
                                                  Found in lib/dao-factory.js and 2 other locations - About 5 hrs to fix
                                                  lib/dao-factory.js on lines 1060..1075
                                                  lib/dao-factory.js on lines 1178..1193

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 139.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 3 locations. Consider refactoring.
                                                  Open

                                                              var next = function(i) {
                                                                if (i >= records.length) {
                                                                  return runQuery(null, records)
                                                                }
                                                  
                                                  
                                                  Severity: Major
                                                  Found in lib/dao-factory.js and 2 other locations - About 5 hrs to fix
                                                  lib/dao-factory.js on lines 1147..1162
                                                  lib/dao-factory.js on lines 1178..1193

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 139.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 3 locations. Consider refactoring.
                                                  Open

                                                      this.DAO.prototype._isBooleanAttribute = Utils._.memoize(function (key) {
                                                        return self.DAO.prototype.booleanValues.indexOf(key) !== -1
                                                      })
                                                  Severity: Major
                                                  Found in lib/dao-factory.js and 2 other locations - About 1 hr to fix
                                                  lib/dao-factory.js on lines 226..228
                                                  lib/dao-factory.js on lines 298..300

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 66.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 3 locations. Consider refactoring.
                                                  Open

                                                      this.DAO.prototype._isDateAttribute = Utils._.memoize(function (key) {
                                                        return self.DAO.prototype.dateAttributes.indexOf(key) !== -1
                                                      })
                                                  Severity: Major
                                                  Found in lib/dao-factory.js and 2 other locations - About 1 hr to fix
                                                  lib/dao-factory.js on lines 221..223
                                                  lib/dao-factory.js on lines 298..300

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 66.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 3 locations. Consider refactoring.
                                                  Open

                                                      this.DAO.prototype._isAttribute = Utils._.memoize(function (key) {
                                                        return self.DAO.prototype.attributes.indexOf(key) !== -1
                                                      })
                                                  Severity: Major
                                                  Found in lib/dao-factory.js and 2 other locations - About 1 hr to fix
                                                  lib/dao-factory.js on lines 221..223
                                                  lib/dao-factory.js on lines 226..228

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 66.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Identical blocks of code found in 3 locations. Consider refactoring.
                                                  Open

                                                              query.on('sql', function(sql) {
                                                                emitter.emit('sql', sql)
                                                              })
                                                              .error(function(err) {
                                                                emitter.emit('error', err)
                                                  Severity: Major
                                                  Found in lib/dao-factory.js and 2 other locations - About 1 hr to fix
                                                  lib/dao-factory.js on lines 1009..1053
                                                  lib/dao.js on lines 530..544

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 59.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                        if (this.options.updatedAt) {
                                                          this._timestampAttributes.updatedAt = Utils._.underscoredIf(this.options.updatedAt, this.options.underscored)
                                                        }
                                                  Severity: Major
                                                  Found in lib/dao-factory.js and 1 other location - About 1 hr to fix
                                                  lib/dao-factory.js on lines 161..163

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 59.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Identical blocks of code found in 3 locations. Consider refactoring.
                                                  Open

                                                            query.on('sql', function(sql) {
                                                              emitter.emit('sql', sql)
                                                            })
                                                            .error(function(err) {
                                                              emitter.emit('error', err)
                                                  Severity: Major
                                                  Found in lib/dao-factory.js and 2 other locations - About 1 hr to fix
                                                  lib/dao-factory.js on lines 1124..1168
                                                  lib/dao.js on lines 530..544

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 59.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                        if (this.options.createdAt) {
                                                          this._timestampAttributes.createdAt = Utils._.underscoredIf(this.options.createdAt, this.options.underscored)
                                                        }
                                                  Severity: Major
                                                  Found in lib/dao-factory.js and 1 other location - About 1 hr to fix
                                                  lib/dao-factory.js on lines 164..166

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 59.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                            if (createdAtAttr && !values[createdAtAttr]) {
                                                              values[createdAtAttr] = Utils.now(self.daoFactoryManager.sequelize.options.dialect)
                                                            }
                                                  Severity: Minor
                                                  Found in lib/dao-factory.js and 1 other location - About 50 mins to fix
                                                  lib/dao-factory.js on lines 898..900

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 52.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                            if (updatedAtAttr && !values[updatedAtAttr]) {
                                                              values[updatedAtAttr] = Utils.now(self.daoFactoryManager.sequelize.options.dialect)
                                                            }
                                                  Severity: Minor
                                                  Found in lib/dao-factory.js and 1 other location - About 50 mins to fix
                                                  lib/dao-factory.js on lines 894..896

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 52.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                      if (this._timestampAttributes.createdAt) {
                                                        tail[this._timestampAttributes.createdAt] = {type: DataTypes.DATE, allowNull: false}
                                                      }
                                                  Severity: Minor
                                                  Found in lib/dao-factory.js and 1 other location - About 40 mins to fix
                                                  lib/dao-factory.js on lines 1312..1314

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 49.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                      if (this._timestampAttributes.updatedAt) {
                                                        tail[this._timestampAttributes.updatedAt] = {type: DataTypes.DATE, allowNull: false}
                                                      }
                                                  Severity: Minor
                                                  Found in lib/dao-factory.js and 1 other location - About 40 mins to fix
                                                  lib/dao-factory.js on lines 1309..1311

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 49.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 3 locations. Consider refactoring.
                                                  Open

                                                              self.all({where: where}).error(function(err) { emitter.emit('error', err) })
                                                              .success(function(records) {
                                                                if (records === null || records.length < 1) {
                                                                  return runQuery(null)
                                                                }
                                                  Severity: Minor
                                                  Found in lib/dao-factory.js and 2 other locations - About 35 mins to fix
                                                  lib/dao-factory.js on lines 1058..1078
                                                  lib/dao-factory.js on lines 1211..1219

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 46.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 3 locations. Consider refactoring.
                                                  Open

                                                          build.hookValidate({skip: skippedFields}).error(function(err) {
                                                            emitter.emit('error', err)
                                                          }).success(function(attributes) {
                                                            if (!!attributes && !!attributes.dataValues) {
                                                              attrValueHash = Utils._.pick.apply(Utils._, [].concat(attributes.dataValues).concat(Object.keys(attrValueHash)))
                                                  Severity: Minor
                                                  Found in lib/dao-factory.js and 2 other locations - About 35 mins to fix
                                                  lib/dao-factory.js on lines 1058..1078
                                                  lib/dao-factory.js on lines 1172..1196

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 46.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Similar blocks of code found in 3 locations. Consider refactoring.
                                                  Open

                                                            self.all({where: where}).error(function(err) { emitter.emit('error', err) })
                                                            .success(function(records) {
                                                              var next = function(i) {
                                                                if (i >= records.length) {
                                                                  return runQuery(null, records)
                                                  Severity: Minor
                                                  Found in lib/dao-factory.js and 2 other locations - About 35 mins to fix
                                                  lib/dao-factory.js on lines 1172..1196
                                                  lib/dao-factory.js on lines 1211..1219

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 46.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Identical blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                        if (options.hasOwnProperty('include') && options.include) {
                                                          hasJoin = true
                                                  
                                                          validateIncludedElements.call(this, options, tableNames)
                                                        }
                                                  Severity: Minor
                                                  Found in lib/dao-factory.js and 1 other location - About 30 mins to fix
                                                  lib/dao-factory.js on lines 455..459

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 45.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  Identical blocks of code found in 2 locations. Consider refactoring.
                                                  Open

                                                        if (options.hasOwnProperty('include') && options.include) {
                                                          hasJoin = true
                                                  
                                                          validateIncludedElements.call(this, options, tableNames)
                                                        }
                                                  Severity: Minor
                                                  Found in lib/dao-factory.js and 1 other location - About 30 mins to fix
                                                  lib/dao-factory.js on lines 545..549

                                                  Duplicated Code

                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                  Tuning

                                                  This issue has a mass of 45.

                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                  Refactorings

                                                  Further Reading

                                                  There are no issues that match your filters.

                                                  Category
                                                  Status