Showing 536 of 552 total issues
Function exports
has 131 lines of code (exceeds 75 allowed). Consider refactoring. Open
module.exports = function (User) {
User.auth = {};
User.auth.logAttempt = async function (uid, ip) {
if (!(parseInt(uid, 10) > 0)) {
Function exports
has 131 lines of code (exceeds 75 allowed). Consider refactoring. Open
module.exports = function (User) {
const filterFnMap = {
online: user => user.status !== 'offline' && (Date.now() - user.lastonline < 300000),
flagged: user => parseInt(user.flags, 10) > 0,
verified: user => !!user['email:confirmed'],
Function exports
has 128 lines of code (exceeds 75 allowed). Consider refactoring. Open
module.exports = function (Topics) {
Topics.createTopicFromPosts = async function (uid, title, pids, fromTid, cid) {
if (title) {
title = title.trim();
}
File tags.js
has 546 lines of code (exceeds 500 allowed). Consider refactoring. Open
'use strict';
const async = require('async');
const validator = require('validator');
Function exports
has a Cognitive Complexity of 27 (exceeds 10 allowed). Consider refactoring. Open
module.exports = function (Categories) {
Categories.update = async function (modified) {
const cids = Object.keys(modified);
await Promise.all(cids.map(cid => updateCategory(cid, modified[cid])));
return cids;
- 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 127 lines of code (exceeds 75 allowed). Consider refactoring. Open
module.exports = function (Topics) {
Topics.delete = async function (tid, uid) {
const [cid, pids] = await Promise.all([
Topics.getTopicField(tid, 'cid'),
Topics.getPids(tid),
Function exports
has 126 lines of code (exceeds 75 allowed). Consider refactoring. Open
module.exports = function (grunt) {
const args = [];
if (!grunt.option('verbose')) {
args.push('--log-level=info');
Function exports
has 126 lines of code (exceeds 75 allowed). Consider refactoring. Open
module.exports = function (User) {
new cronJob('0 * * * *', (() => {
User.autoApprove();
}), null, true);
Function UserCommands
has 125 lines of code (exceeds 75 allowed). Consider refactoring. Open
function UserCommands() {
const { argParsers, getAdminUidOrFail, setupApp } = UserCmdHelpers();
async function info({ uid, username, userslug }) {
if (!uid && !username && !userslug) {
Function enableQuickSearch
has 124 lines of code (exceeds 75 allowed). Consider refactoring. Open
Search.enableQuickSearch = function (options) {
if (!config.searchEnabled || !app.user.privileges['search:content']) {
return;
}
Function handleErrors
has a Cognitive Complexity of 26 (exceeds 10 allowed). Consider refactoring. Open
exports.handleErrors = async function handleErrors(err, req, res, next) { // eslint-disable-line no-unused-vars
const cases = {
EBADCSRFTOKEN: function () {
winston.error(`${req.method} ${req.originalUrl}\n${err.message}`);
res.sendStatus(403);
- 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 get
has a Cognitive Complexity of 26 (exceeds 10 allowed). Consider refactoring. Open
categoryController.get = async function (req, res, next) {
const cid = req.params.category_id;
let currentPage = parseInt(req.query.page, 10) || 1;
let topicIndex = utils.isNumber(req.params.topic_index) ? parseInt(req.params.topic_index, 10) - 1 : 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 exports
has a Cognitive Complexity of 26 (exceeds 10 allowed). Consider refactoring. Open
module.exports = function (Groups) {
Groups.leave = async function (groupNames, uid) {
if (Array.isArray(groupNames) && !groupNames.length) {
return;
}
- 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 26 (exceeds 10 allowed). Consider refactoring. Open
module.exports = function (module) {
const helpers = require('../helpers');
module.sortedSetRemove = async function (key, value) {
if (!key) {
- 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 init
has 122 lines of code (exceeds 75 allowed). Consider refactoring. Open
Detail.init = function () {
// Update attributes
$('#state').val(ajaxify.data.state).removeAttr('disabled');
$('#assignee').val(ajaxify.data.assignee).removeAttr('disabled');
Function createModal
has 120 lines of code (exceeds 75 allowed). Consider refactoring. Open
module.createModal = function (data, callback) {
callback = callback || function () {};
require([
'scrollStop', 'forum/chats', 'forum/chats/messages', 'forum/chats/message-search',
], function (scrollStop, Chats, ChatsMessages, messageSearch) {
Function exports
has 120 lines of code (exceeds 75 allowed). Consider refactoring. Open
module.exports = function (opts) {
const { LRUCache } = require('lru-cache');
const pubsub = require('../pubsub');
// lru-cache@7 deprecations
Function exports
has 118 lines of code (exceeds 75 allowed). Consider refactoring. Open
module.exports = function (module) {
const helpers = require('../helpers');
const utils = require('../../../utils');
module.sortedSetAdd = async function (key, score, value) {
Function exports
has 118 lines of code (exceeds 75 allowed). Consider refactoring. Open
module.exports = function (User) {
User.isReadyToPost = async function (uid, cid) {
await isReady(uid, cid, 'lastposttime');
};
Function exports
has 117 lines of code (exceeds 75 allowed). Consider refactoring. Open
module.exports = function (Plugins) {
if (nconf.get('isPrimary')) {
pubsub.on('plugins:toggleInstall', (data) => {
if (data.hostname !== os.hostname()) {
toggleInstall(data.id, data.version);