Showing 37 of 45 total issues
Function _dive
has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring. Open
function _dive (skm, payload, opts, parentData) {
// On the odd chance we reach here with no `skm` model defined
if (!skm) return payload
// Placeholder for formatted data
- 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 _validate
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
function _validate (data, model, opts, parentData = {}) {
let errs = {}
// Validate scalars
// Used by `_sparse()` to check scalar vals -- pass parentObj if exists
- 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 checkValue
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function checkValue (val, model, data, opts = {}) {
let errs = []
if (!model) return []
// 1. Check null value status
- 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 _generate
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
function _generate (gen, runOnce, value, data) {
// Run immediately if `gen` is a function
if (is.function(gen)) return gen.call(data, value)
// Prepare the value to return
- 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 _makeValue
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
function _makeValue (data = {}, ss = {}, opts, val) {
// Set defaults
if (opts.defaults !== false) {
if (!is.undefined(ss.default)) val = setDefault(val, ss)
}
- 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 convertNumber
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
function convertNumber (val, convertor, radix) {
// Setup defaults
convertor || (convertor = radix !== undefined ? parseInt : Number)
radix || (radix = 10)
- 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 equal
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
equal: (a, b) => {
if (a === b) return true
let i = -1
if (is.array(a)) {
- 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
pgSQL
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
const pgSQL = {
ARRAY: (t, opts) => typeToSQL(t.type, opts) + ' ARRAY',
BOOLEAN: t => t.key,
BYTEA: t => t.key,
CHAR: t => 'CHAR' + (t.length ? `(${t.length})` : ''),
Function _dive
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _dive (skm, payload, opts, parentData) {
// On the odd chance we reach here with no `skm` model defined
if (!skm) return payload
// Placeholder for formatted data
Function _validate
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _validate (data, model, opts, parentData = {}) {
let errs = {}
// Validate scalars
// Used by `_sparse()` to check scalar vals -- pass parentObj if exists
Function checkValue
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function checkValue (val, model, data, opts = {}) {
let errs = []
if (!model) return []
// 1. Check null value status
Function createFrom
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function createFrom (model, nullValue) {
let o = {}
if (!model) return o
- 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 exports
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function (v, model) {
if (!model) return v
const def = function (v, s) {
// No default, return the value as is
- 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 toString
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function toString (val) {
if (val === null) return val
// Parse if value is not undefined
if (val !== undefined) {
- 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 _generate
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _generate (gen, runOnce, value, data) {
// Run immediately if `gen` is a function
if (is.function(gen)) return gen.call(data, value)
// Prepare the value to return
Function toDate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function toDate (val) {
if (val === undefined || val instanceof Array) {
throw new Error('Failed to cast to Date')
}
if (val === null || val === '') return null
- 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 fieldToString
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
const fieldToString = (name, model, table) => {
// Define the colun name
let str = [name]
if (!model.type) {
- 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 canCompute
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function canCompute (model, opts = {}, val) {
if (!model || !model.generate) return false
// Shorthand
const gen = model.generate
- 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
Avoid deeply nested control flow statements. Open
if (data[i] !== out) data[i] = out
Function typeToSQL
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const typeToSQL = (type, opts = {forceUnrecognised: false}) => {
if (!type) return ''
// Return immediately if no key set on data type
if (!type.key) {
- 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"