Showing 35 of 41 total issues
Function chkEmailInvalidOrDup
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
validate.chkEmailInvalidOrDup = (email, callback) => {
validate.chkEmailInvalid(email, (err, result) => {
if (err) {
return callback(err);
}
- 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 restrictTo
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
exports.restrictTo = role => (req, res, next) => {
const fail = () => {
req.flash('error', 'You are not authorized to access this resource.');
if (req.session.user) {
if (req.originalUrl === '/') {
- 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 exports
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
exports = module.exports = app => {
// AJAX
app.post('/password', mid.forceLogin,
- 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 exports
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports = module.exports = (err, req, res, next) => {
const trackId = uuid.v4();
log.error(`ID: ${trackId}`);
log.error(`Caught error: ${err.name}`);
log.error(err.message);
Function syncFormageUser
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function syncFormageUser(user, callback) {
return FormageUser.findOne({
username: user.username
}).exec()
Function unscrambleFields
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
unscrambleFields: function unscrambleFields(req, res, next) {
// Parse through the body and unscramble any fields.
// Fail the request if no spinner was passed
if (!req.body.spinner) {
Function enableUser
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.enableUser = (username, cb) => {
// find the user
const search = next => {
searchRaw(username, 'pwdAccountLockedTime', (err, user) => {
if (err) {
Function lockoutUser
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.lockoutUser = (username, cb) => {
// find the user
const search = next => {
searchRaw(username, 'pwdAccountLockedTime', (err, user) => {
if (err) {
Function checkBlacklist
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function checkBlacklist(isWhite, cb) {
if (isWhite) {
return next();
}
async.map(Object.keys(spams), (list, cb) => {
Function findAndSync
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
const findAndSync = (filter, callback) => {
const findMongo = cb => {
User.findOne(filter, (err, user) => {
if (err) {
- 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 exports
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
exports = module.exports = (err, req, res, next) => {
const trackId = uuid.v4();
log.error(`ID: ${trackId}`);
log.error(`Caught error: ${err.name}`);
log.error(err.message);
- 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 unscrambleFields
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
unscrambleFields: function unscrambleFields(req, res, next) {
// Parse through the body and unscramble any fields.
// Fail the request if no spinner was passed
if (!req.body.spinner) {
- 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 resetPassword
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
exports.resetPassword = (username, newPass, cb) => {
if (!userAttr.usernameRegex.test(username)) {
return cb(new Error('Illegal username specified'));
}
- 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 field.focus();
Avoid too many return
statements within this function. Open
return setTimeout(next, minimumTime - diff);