Showing 37 of 45 total issues
Avoid deeply nested control flow statements. Open
Open
if (!arsub.valid) {
if (!errs[key]) errs[key] = {}
errs[key][idx] = arsub.errors
}
Avoid deeply nested control flow statements. Open
Open
if (er.length) {
if (!errs[key]) errs[key] = {}
errs[key][idx] = er
}
Function _checkKeys
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
function _checkKeys (model, data) {
let ret = {
valid: true,
errors: {}
}
- 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 too many return
statements within this function. Open
Open
return true
Avoid too many return
statements within this function. Open
Open
return [`wrongType:${model.type}`]
Avoid too many return
statements within this function. Open
Open
if (req && !provided) return false
Avoid too many return
statements within this function. Open
Open
if (!isNaN(val) && typeof val === 'number') return val
Avoid too many return
statements within this function. Open
Open
return true
Avoid too many return
statements within this function. Open
Open
return setError(model, 'required', errs)
Avoid too many return
statements within this function. Open
Open
return !!val
Avoid too many return
statements within this function. Open
Open
if (!model.required && val === undefined) return []
Avoid too many return
statements within this function. Open
Open
return false
Avoid too many return
statements within this function. Open
Open
return true
Avoid too many return
statements within this function. Open
Open
if (aKeys.length !== bKeys.length) return false
Avoid too many return
statements within this function. Open
Open
if (!is.equal(a[aKeys[i]], b[aKeys[i]])) return false
Avoid too many return
statements within this function. Open
Open
if (provided && preserve) return false
Avoid too many return
statements within this function. Open
Open
return errs