Showing 161 of 430 total issues
Function calcResult
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
exports.calcResult = function calcResult (topic) {
return Vote.find({ topic: topic._id }).then((votes) => {
const options = topic.action.results.map((o) => o.value)
const votesPercentages = {}
Function render
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render () {
const { reply, user, forum } = this.props
const userAttrs = user.state.value || {}
const isOwner = userAttrs.id === reply.author.id
Function exports
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports = function () {
const callbackURL = utils.buildUrl(config, {
pathname: '/auth/facebook/callback'
})
Function switchOn
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
switchOn () {
this.bind('click', '.add-link', this.bound('onaddlinkclick'))
this.bind('click', '.forum-tag', this.bound('onaddforumtagclick'))
this.bind('click', '[data-remove-link]', this.bound('onremovelinkclick'))
this.bind('click', '.save', this.bound('onsaveclick'))
Function buildJs
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports = function buildJs (entries) {
return {
build: function () {
const log = newLog('js:build')
Function parseComment
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function parseComment (comment) {
return new Promise((resolve, reject) => {
if (!comment.text) return resolve(comment)
marked(comment.text, {
sanitize: true,
Function confirm
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function confirm (options = {}) {
if (typeof options === 'string') {
options = { text: options.toString() }
}
Function all
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
Open
exports.all = function all (options, fn) {
if (typeof options === 'function') {
fn = options
options = undefined
}
- 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 constructor
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
constructor (topic, forum, tags) {
const locals = {
form: { title: null, action: null, method: null, type: null },
topic: topic || { clauses: [] },
tags: tags,
Function all
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
exports.all = function all (options, fn) {
if (typeof options === 'function') {
fn = options
options = undefined
}
Function getCsv
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function getCsv (req, res, next) {
api.comments.populateTopics(req.topics)
.then((topicsComments) => {
const commentsData = [ titles ]
Function down
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
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)
Function removeReply
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
exports.removeReply = (function () {
function verifyPrivileges (forum, user, replyId, comment) {
if (privileges.canDeleteComments(forum, user)) return comment
const reply = comment.replies.id(replyId)
Function xssFilter
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
module.exports = function xssFilter (opts) {
var defaults = {
fontFace: false,
fontSize: true,
fontWidth: true,
- 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 onload
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
reader.onload = (event) => {
const content = event.target.result
fetch(`/api/v2/topics.csv?forum=${this.props.forum.id}`, {
method: 'POST',
credentials: 'same-origin',
Function signin
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function signin (req, res, next) {
var email = normalizeEmail(req.body.email)
auth(email, req.body.password, function (err, user, info) {
if (err) return res.status(200).json({ error: t(err.message) })
Function user
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
user: function user () {
return function (req, res, next) {
var qs = req.query ? req.query.access_token : ''
var encoded = req.cookies.token || qs || req.headers['x-access-token']
Function listen
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports = function listen (opts, callback) {
if (!callback) callback = () => {}
const servers = serverFactory(app, opts)
Function up
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
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)
Function create
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
exports.create = function create (tag, fn) {
log('Creating new tag %j', tag)
if (typeof tag === 'string') {
tag = { name: tag }