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')
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 = {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
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 = {
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 = {
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 () {
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 () {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
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: [],
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({
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)
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: [],
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
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)
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({
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
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
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) {
Function _clearAndSetOne
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
SqlStore.prototype._clearAndSetOne = function (relationModel, prop, theResource, keyName, ucKeyName, t, taskCallback) {
Function _clearAndSetMany
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
SqlStore.prototype._clearAndSetMany = function (relationModel, prop, theResource, keyName, ucKeyName, t, taskCallback) {
Avoid deeply nested control flow statements. Open
if (test.name === 'max' || test.name === 'length') {
this[attributeName].type = DataTypes.STRING(test.arg)
}
Avoid too many return
statements within this function. Open
return caseInsensitiveContainsExpression
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
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"