holidayextras/jsonapi-store-relationaldb

View on GitHub

Showing 21 of 33 total issues

File sqlHandler.js has 538 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 24 (exceeds 5 allowed). Consider refactoring.
    Open

      constructor (resourceName, joiSchema) {
        this.id = {
          type: DataTypes.UUID,
          defaultValue: DataTypes.UUIDV4,
          primaryKey: true
    Severity: Minor
    Found in lib/modelGenerators/default.js - About 3 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 79 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      constructor (resourceName, joiSchema) {
        this.id = {
          type: DataTypes.UUID,
          defaultValue: DataTypes.UUIDV4,
          primaryKey: true
    Severity: Major
    Found in lib/modelGenerators/default.js - About 3 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 _defineRelationModel has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

          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 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 _buildModels has 31 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 _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 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 find has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        SqlStore.prototype.find = function (request, callback) {
                          var self = this
                        
                          self.baseModel.findOne({
                            where: { id: request.params.id },
                        Severity: Minor
                        Found in lib/sqlHandler.js - About 1 hr 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

                            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

                              Avoid too many return statements within this function.
                              Open

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

                                Function initialise has a Cognitive Complexity of 6 (exceeds 5 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 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

                                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