Function executeRoute
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
const executeRoute = (
method,
routePath,
req = {},
res = {},
- 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
Arrow function has too many parameters (7). Maximum allowed is 4. Open
) => {
- Read upRead up
- Exclude checks
title: max-params ruletype: suggestion relatedrules: - complexity - max-depth - max-len - max-lines - max-lines-per-function - max-nested-callbacks
- max-statements
Functions that take numerous parameters can be difficult to read and write because it requires the memorization of what each parameter is, its type, and the order they should appear in. As a result, many coders adhere to a convention that caps the number of parameters a function can take.
function foo (bar, baz, qux, qxx) { // four parameters, may be too many
doSomething();
}
Rule Details
This rule enforces a maximum number of parameters allowed in function definitions.
Options
This rule has a number or object option:
-
"max"
(default3
) enforces a maximum number of parameters in function definitions
Deprecated: The object property maximum
is deprecated; please use the object property max
instead.
max
Examples of incorrect code for this rule with the default { "max": 3 }
option:
:::incorrect
/*eslint max-params: ["error", 3]*/
/*eslint-env es6*/
function foo (bar, baz, qux, qxx) {
doSomething();
}
let foo = (bar, baz, qux, qxx) => {
doSomething();
};
:::
Examples of correct code for this rule with the default { "max": 3 }
option:
:::correct
/*eslint max-params: ["error", 3]*/
/*eslint-env es6*/
function foo (bar, baz, qux) {
doSomething();
}
let foo = (bar, baz, qux) => {
doSomething();
};
::: Source: http://eslint.org/docs/rules/
Prefer named exports. Open
export default (route, io) => {
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Definition for rule 'node/no-restricted-import' was not found. Open
/* eslint-disable max-statements */
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/