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')
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
- 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 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor (resourceName, joiSchema) {
this.id = {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
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 _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 = {
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 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 _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
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 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 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 },
Function _clearAndSetMany
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
SqlStore.prototype._clearAndSetMany = function (relationModel, prop, theResource, keyName, ucKeyName, t, taskCallback) {
Function _clearAndSetOne
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
SqlStore.prototype._clearAndSetOne = function (relationModel, prop, theResource, keyName, ucKeyName, t, taskCallback) {
Avoid too many return
statements within this function. Open
return caseInsensitiveContainsExpression
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) {
- 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 _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"