lib/utils.js
Function createSpecificityComparator
has a Cognitive Complexity of 106 (exceeds 5 allowed). Consider refactoring. Open
Open
createSpecificityComparator: function(options) {
const self = this
options = options || {}
// Ascending order flag, defaults to false
let asc = false
- 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 createSpecificityComparator
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
createSpecificityComparator: function(options) {
const self = this
options = options || {}
// Ascending order flag, defaults to false
let asc = false
Function specificityComparator
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
return function specificityComparator(routeA, routeB) {
routeA = (routeA.path || '').toLowerCase()
routeB = (routeB.path || '').toLowerCase()
// If it's the default route, push it all the way
// over to one of the ends
Function createResponse
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
createResponse: function(req, res, next) {
const response = (data) => {
return new Promise((resolve, reject) => {
if (!data) {
Function createResponse
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
createResponse: function(req, res, next) {
const response = (data) => {
return new Promise((resolve, reject) => {
if (!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
Avoid deeply nested control flow statements. Open
Open
if (joinedA > joinedB) {
return asc ? 1 : -1
}
Avoid deeply nested control flow statements. Open
Open
if (joinedA < joinedB) {
return asc ? -1 : 1
}
Avoid too many return
statements within this function. Open
Open
return asc ? 1 : -1
Avoid too many return
statements within this function. Open
Open
return asc ? -1 : 1
Avoid too many return
statements within this function. Open
Open
return asc ? -1 : 1
Avoid too many return
statements within this function. Open
Open
return 0
Avoid too many return
statements within this function. Open
Open
return asc ? -1 : 1
Avoid too many return
statements within this function. Open
Open
return asc ? 1 : -1
Avoid too many return
statements within this function. Open
Open
return asc ? 1 : -1