Showing 161 of 430 total issues
Function CommentsList
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function CommentsList (props) {
const comments = props.comments || []
return (
<div
Function doVote
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function doVote (user, value, topic) {
if (topic.status === 'closed') {
const err = new Error('Voting on this topic os closed.')
err.code = 'VOTING_CLOSED'
return Promise.reject(err)
Function create
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.create = function create (data, fn) {
log('Creating new whitelist %j', data)
if (data.type === 'email') {
var batch = new Batch()
Function componentWillMount
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
componentWillMount () {
if (!config.multiForum && !config.defaultForum) {
window.location = urlBuilder.for('forums.new')
}
Function commentReply
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.commentReply = function commentReply (req, res, next) {
api.user.get(req.comment.author.id, function (err, commentAuthor) {
if (err) return next(err)
const topic = {
Function canEdit
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
canEdit (forum, user, topic) {
if (!config.multiForum && user && user.staff) return true
const isAdmin =
forum.isOwner(user) ||
- 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 prepareState
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
prepareState (topic) {
let votes = {
positive: new Array(parseInt(topic.action.results.find((o) => o.value === 'positive').percentage * topic.action.count)) || [],
negative: new Array(parseInt(topic.action.results.find((o) => o.value === 'negative').percentage * topic.action.count)) || [],
neutral: new Array(parseInt(topic.action.results.find((o) => o.value === 'neutral').percentage * topic.action.count)) || []
Function CommentContent
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function CommentContent (props) {
let Content = (
<div
className='text'
dangerouslySetInnerHTML={{ __html: props.textHtml }} />
Function ReplyContent
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function ReplyContent (props) {
let Content = (
<div
className='text'
dangerouslySetInnerHTML={{ __html: props.textHtml }} />
Function topicsAttrs
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function topicsAttrs (ForumSchema) {
const AttrSchema = new Schema({
name: { type: String, maxlength: 32, minlength: 1, required: true },
title: { type: String, maxlength: 128, minlength: 1, required: true },
description: { type: String, maxlength: 256 },
Function createToken
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.createToken = function createToken (email, meta, callback) {
log('Password reset token creation requested for email "%s", checking user exists', email)
if (arguments.length === 2) {
callback = meta
Function render
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
render () {
return (
<div className='header-item'>
{
this.state.signup &&
Function postserialize
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
postserialize (data = {}) {
if (data['links[][text]']) {
data.links = data['links[][text]'].map((text, i) => ({
_id: data['links[][_id]'][i] || undefined,
url: data['links[][url]'][i],
Function validate
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function validate (schemas, options) {
var extensions = []
options = options || {}
Function sslRedirect
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function sslRedirect (app, options) {
var secure = options.protocol === 'https'
if (!secure) return
Function up
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.up = function (done) {
const clausesVersionsAcc = { 1: 0, 2: 0, 3: 0 }
dbReady()
.then(() => Topic.collection
Function constructor
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor (el, options = {}) {
// The original input or textarea element
let input = typeof el === 'string' ? dom(el) : el
// Settings merged with options provided by callee
Function render
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
render () {
const {
name,
title,
description,
Function parseUpdateableKeys
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
exports.parseUpdateableKeys = function parseUpdateableKeys (req, res, next) {
const custom = (req.forum.topicsAttrs || []).map((attr) => {
return `attrs.${attr.name}`
})
- 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 up
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
exports.up = function up (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"