lib/routes/objects.js
Function checkJWT
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
var checkJWT = function(action) {
return wrap(function*(req, res, next) {
let user = req.params.user;
let repo = req.params.repo;
let oid = req.params.oid;
- 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
This generator function does not have 'yield'. Open
Open
return wrap(function*(req, res, next) {
- Read upRead up
- Exclude checks
Disallow generator functions that do not have yield
(require-yield)
Rule Details
This rule generates warnings for generator functions that do not have the yield
keyword.
Examples
Examples of incorrect code for this rule:
/*eslint require-yield: "error"*/
/*eslint-env es6*/
function* foo() {
return 10;
}
Examples of correct code for this rule:
/*eslint require-yield: "error"*/
/*eslint-env es6*/
function* foo() {
yield 5;
return 10;
}
function foo() {
return 10;
}
// This rule does not warn on empty generator functions.
function* foo() { }
When Not To Use It
If you don't want to notify generator functions that have no yield
expression, then it's safe to disable this rule.
Related Rules
- [require-await](require-await.md) Source: http://eslint.org/docs/rules/