Function match
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
match (path, keyValues = {}) {
if (path.length === 0) {
if (this.middleware.length > 0) {
return new RouteTreeResult(keyValues, this.middleware, this.composedMiddleware);
} else {
- 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 containsFunctionalDuplicate
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
containsFunctionalDuplicate (pathComponents, catchAll = false) {
if (pathComponents.length === 0) {
// if there's no path components to begin with, then this is only a
// duplicate if we've stored middleware at the "root" path (/)
// if we reached here via recursion, the same test works.
- 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 match
has 38 lines of code (exceeds 30 allowed). Consider refactoring. Open
match (path, keyValues = {}) {
if (path.length === 0) {
if (this.middleware.length > 0) {
return new RouteTreeResult(keyValues, this.middleware, this.composedMiddleware);
} else {
Function compare
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
static compare (lNode, rNode) {
// catch-all routes have the lowest priority
if (!lNode.catchAll && rNode.catchAll) {
return -1;
} else if (lNode.catchAll && !rNode.catchAll) {
- 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
return -1;
Avoid too many return
statements within this function. Open
return null;
Avoid too many return
statements within this function. Open
return new RouteTreeResult(keyValues, child.middleware, child.composedMiddleware);
Avoid too many return
statements within this function. Open
return 0;
Avoid too many return
statements within this function. Open
return 1;
Avoid too many return
statements within this function. Open
return 1;
Avoid too many return
statements within this function. Open
return 0;
Avoid too many return
statements within this function. Open
return -1;
Avoid too many return
statements within this function. Open
return new RouteTreeResult(keyValues, this.middleware, this.composedMiddleware);
Function allowedMethods
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
allowedMethods () {
const methods = [];
if (!this[Methods.HEAD].isEmpty) methods.push('HEAD');
if (!this[Methods.GET].isEmpty) methods.push('GET');
if (!this[Methods.PATCH].isEmpty) methods.push('PATCH');
- 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 addRoute
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
addRoute (pattern, pathComponents, middleware, catchAll = false) {
// check if we're done
if (pathComponents.length === 0) {
_middleware.set(this, middleware);
_composedMiddleware.set(this, compose(middleware));
- 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"