Showing 161 of 430 total issues
Function getMaxValues
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function getMaxValues (optionsWithMaxVotes, level, index, fieldsToExclude = [], fieldsTofind = []) {
Function revokePermission
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
exports.revokePermission = function revokePermission (forumId, user, role) {
log(`Revoking permissions to ${user} on forum ${forumId}.`)
return new Promise((resolve, reject) => {
Forum.findById(forumId, (findError, forum) => {
- 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 unvote
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
CommentSchema.methods.unvote = function (user, cb) {
var votes = this.votes
var c = user.get ? user.get('_id') : user
var voted = votes.filter(function (v) {
- 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 apiError
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
app.use(function apiError (err, req, res, next) {
const status = err.status || 500
const error = {
code: 'SERVER_ERROR',
- 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 grantPermission
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
exports.grantPermission = function grantPermission (forumId, user, role) {
log('Granting permissions as role %s to user %s of forum with id %s', role, user, forumId)
return new Promise((resolve, reject) => {
Forum.findById(forumId, (findError, forum) => {
if (findError) return reject(findError)
- 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 serial
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
module.exports.serial = function serial () {
var middlewares = Array.prototype.slice.call(arguments)
return function serialExec (req, res, next) {
;(function iterate (m) {
- 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 CommentFooter
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export default function CommentFooter (props) {
return (
<footer className='actions'>
<div className='votes'>
<span className='score'>
- 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 paragraphToHTML
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function paragraphToHTML (paragraph, options) {
if (!paragraph) return ''
var el = o(paragraph.markup)
// Set the ID
el.attr(DATA_ID_ATTR, paragraph.id)
- 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 down
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
exports.down = function down (done) {
dbReady()
.then(() => Topic.collection.find({}).toArray())
.then(mapPromises(function (topic) {
if (!topic.action || !Object.keys(topic.action).includes('box')) return Promise.resolve(0)
- 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 privilegesMiddlewareGenerator
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
exports.privileges = function privilegesMiddlewareGenerator (privilege) {
if (!privileges[privilege]) throw new Error('Wrong topi privilege name.')
return function privilegesMiddleware (req, res, next) {
var forum = req.forum
- 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 unflag
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
CommentSchema.methods.unflag = function (user, cb) {
var flags = this.flags
var c = user.get ? user.get('_id') : user
var flagged = flags.filter(function (v) {
- 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 authMongoose
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function authMongoose (schema, options) {
const digestAlgorithm = 'sha512'
schema.plugin(passportLocalMongoose, {
usernameField: 'email',
- 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 serial
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export function serial (...middlewares) {
return function serialExec (ctx, next) {
;(function iterate (m) {
if (!m.length) return next()
m[0](ctx, function (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
Avoid too many return
statements within this function. Open
return 2
Avoid too many return
statements within this function. Open
return next()
Avoid too many return
statements within this function. Open
if (forum.hasRole(user, 'author') && topic.draft) return true
Avoid too many return
statements within this function. Open
return 3
Avoid too many return
statements within this function. Open
if (isAdmin) return true
Avoid too many return
statements within this function. Open
return false
Avoid too many return
statements within this function. Open
return false