jagql/store-sequelize

View on GitHub

Showing 22 of 34 total issues

File sqlHandler.js has 568 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict'
// http://docs.sequelizejs.com/en/latest/
var Sequelize = require('sequelize')
var DataTypes = Sequelize.DataTypes
var async = require('async')
Severity: Major
Found in lib/sqlHandler.js - About 1 day to fix

    Function constructor has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
    Open

      constructor (resourceConfig, joiSchema) {
        const resourceName = resourceConfig.resource
        switch (resourceConfig.primaryKey) {
          case 'uuid':
            this.id = {
    Severity: Minor
    Found in lib/modelGenerators/default.js - About 7 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

    Function constructor has 113 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      constructor (resourceConfig, joiSchema) {
        const resourceName = resourceConfig.resource
        switch (resourceConfig.primaryKey) {
          case 'uuid':
            this.id = {
    Severity: Major
    Found in lib/modelGenerators/default.js - About 4 hrs to fix

      Function _defineRelationModel has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      SqlStore.prototype._defineRelationModel = function (relation, relationName, many) {
        var self = this
      
        var modelName = self.resourceConfig.resource + '-' + relationName
        var modelProperties = {
      Severity: Major
      Found in lib/sqlHandler.js - About 2 hrs to fix

        Function constructor has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          constructor (resourceName, joiSchema) {
            super(resourceName, joiSchema)
            this.meta = {
              type: DataTypes.JSONB,
              get: function () {
        Severity: Major
        Found in lib/modelGenerators/postgres.js - About 2 hrs to fix

          Function constructor has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            constructor (resourceName, joiSchema) {
              super(resourceName, joiSchema)
              this.meta = {
                type: DataTypes.JSONB,
                get: function () {
          Severity: Minor
          Found in lib/modelGenerators/postgres.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

          Function _generateSearchIncludes has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          SqlStore.prototype._generateSearchIncludes = function (relationships) {
            var self = this
            if (!relationships) {
              return {
                count: [],
          Severity: Minor
          Found in lib/sqlHandler.js - About 1 hr to fix

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

            SqlStore.prototype.update = function (request, partialResource, finishedCallback) {
              var self = this
            
              self._dealWithTransaction(finishedCallback, function (t, finishTransaction) {
                self.baseModel.findOne({
            Severity: Minor
            Found in lib/sqlHandler.js - About 1 hr to fix

              Function search has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              SqlStore.prototype.search = function (request, callback) {
                var self = this
              
                var options = { }
                var where = self._generateSearchBlock(request)
              Severity: Minor
              Found in lib/sqlHandler.js - About 1 hr to fix

                Function _generateSearchIncludes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                SqlStore.prototype._generateSearchIncludes = function (relationships) {
                  var self = this
                  if (!relationships) {
                    return {
                      count: [],
                Severity: Minor
                Found in lib/sqlHandler.js - About 1 hr 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

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

                SqlStore.prototype.find = function (request, callback) {
                  var self = this
                
                  var whereClause = { id: request.params.id }
                  var whereExtras = self._generateSearchBlock(request)
                Severity: Minor
                Found in lib/sqlHandler.js - About 1 hr to fix

                  Function delete has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  SqlStore.prototype.delete = function (request, finishedCallback) {
                    var self = this
                  
                    self._dealWithTransaction(finishedCallback, function (t, finishTransaction) {
                      self.baseModel.findAll({
                  Severity: Minor
                  Found in lib/sqlHandler.js - About 1 hr to fix

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

                    SqlStore.prototype._dealWithTransaction = function (done, callback) {
                      var self = this
                      var transactionOptions = {
                        isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.READ_COMMITTED,
                        autocommit: false
                    Severity: Minor
                    Found in lib/sqlHandler.js - About 1 hr to fix

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

                      SqlStore.prototype._buildModels = function () {
                        var self = this
                      
                        var localAttributes = Object.keys(self.resourceConfig.attributes).filter(function (attributeName) {
                          var settings = self.resourceConfig.attributes[attributeName]._settings
                      Severity: Minor
                      Found in lib/sqlHandler.js - About 1 hr to fix

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

                        SqlStore.prototype.initialise = function (resourceConfig) {
                          var self = this
                          self.resourceConfig = resourceConfig
                        
                          if (self.config.sequelize) {
                        Severity: Minor
                        Found in lib/sqlHandler.js - About 1 hr to fix

                          Function _clearAndSetOne has 7 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          SqlStore.prototype._clearAndSetOne = function (relationModel, prop, theResource, keyName, ucKeyName, t, taskCallback) {
                          Severity: Major
                          Found in lib/sqlHandler.js - About 50 mins to fix

                            Function _clearAndSetMany has 7 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            SqlStore.prototype._clearAndSetMany = function (relationModel, prop, theResource, keyName, ucKeyName, t, taskCallback) {
                            Severity: Major
                            Found in lib/sqlHandler.js - About 50 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                          if (test.name === 'max' || test.name === 'length') {
                                            this[attributeName].type = DataTypes.STRING(test.arg)
                                          }
                              Severity: Major
                              Found in lib/modelGenerators/default.js - About 45 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                    return caseInsensitiveContainsExpression
                                Severity: Major
                                Found in lib/sqlHandler.js - About 30 mins to fix

                                  Function _scalarFilterElementToWhereObj has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  SqlStore.prototype._scalarFilterElementToWhereObj = function (element) {
                                    var self = this
                                  
                                    var value = element.value
                                    var op = element.operator
                                  Severity: Minor
                                  Found in lib/sqlHandler.js - About 25 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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language