Showing 444 of 556 total issues
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 118 lines of code (exceeds 75 allowed). Consider refactoring. Open
module.exports = function (User) {
User.bans = {};
User.bans.ban = async function (uid, until, reason) {
// "until" (optional) is unix timestamp in milliseconds
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);
File install.js
has 528 lines of code (exceeds 500 allowed). Consider refactoring. Open
'use strict';
const fs = require('fs');
const url = require('url');
const path = require('path');
File sorted.js
has 526 lines of code (exceeds 500 allowed). Consider refactoring. Open
'use strict';
const _ = require('lodash');
const utils = require('../../utils');
Function init
has 115 lines of code (exceeds 75 allowed). Consider refactoring. Open
iconSelect.init = function (el, onModified) {
onModified = onModified || function () { };
let selected = cleanFAClass(el[0].classList);
$('#icons .selected').removeClass('selected');
if (selected.icon) {
Function init
has 114 lines of code (exceeds 75 allowed). Consider refactoring. Open
export function init() {
categorySelector.init($('[component="category-selector"]'), {
onSelect: function (selectedCategory) {
ajaxify.go('admin/manage/categories/' + selectedCategory.cid + '/analytics');
},
File helpers.js
has 522 lines of code (exceeds 500 allowed). Consider refactoring. Open
'use strict';
const nconf = require('nconf');
const validator = require('validator');
const querystring = require('querystring');
Function prepareWidgets
has 113 lines of code (exceeds 75 allowed). Consider refactoring. Open
function prepareWidgets() {
const draftContainer = $('[component="drafts-container"]');
$('[data-location="drafts"]').appendTo(draftContainer);
$('#widgets .available-widgets .widget-panel').draggable({
Function exports
has 112 lines of code (exceeds 75 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;
Function exports
has 111 lines of code (exceeds 75 allowed). Consider refactoring. Open
module.exports = function (Posts) {
Posts.urlRegex = {
regex: /href="([^"]+)"/g,
length: 6,
};
Function getUserDataByUserSlug
has a Cognitive Complexity of 23 (exceeds 10 allowed). Consider refactoring. Open
helpers.getUserDataByUserSlug = async function (userslug, callerUID, query = {}) {
const uid = await user.getUidByUserslug(userslug);
if (!uid) {
return null;
}
- 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 110 lines of code (exceeds 75 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;
Function search
has 110 lines of code (exceeds 75 allowed). Consider refactoring. Open
searchController.search = async function (req, res, next) {
if (!plugins.hooks.hasListeners('filter:search.query')) {
return next();
}
const page = Math.max(1, parseInt(req.query.page, 10)) || 1;
Function exports
has 108 lines of code (exceeds 75 allowed). Consider refactoring. Open
module.exports = function (Messaging) {
Messaging.sendMessage = async (data) => {
await Messaging.checkContent(data.content);
const inRoom = await Messaging.isUserInRoom(data.uid, data.roomId);
if (!inRoom) {
File dashboard.js
has 513 lines of code (exceeds 500 allowed). Consider refactoring. Open
import {
Chart,
LineController,
DoughnutController,
CategoryScale,
Function exports
has a Cognitive Complexity of 22 (exceeds 10 allowed). Consider refactoring. Open
module.exports = function (module) {
module.sortedSetUnionCard = async function (keys) {
if (!Array.isArray(keys) || !keys.length) {
return 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 detail
has a Cognitive Complexity of 22 (exceeds 10 allowed). Consider refactoring. Open
modsController.flags.detail = async function (req, res, next) {
const results = await utils.promiseParallel({
isAdminOrGlobalMod: user.isAdminOrGlobalMod(req.uid),
moderatedCids: user.getModeratedCids(req.uid),
flagData: flags.get(req.params.flagId),
- 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 22 (exceeds 10 allowed). Consider refactoring. Open
module.exports = function (User) {
User.auth = {};
User.auth.logAttempt = async function (uid, ip) {
if (!(parseInt(uid, 10) > 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 22 (exceeds 10 allowed). Consider refactoring. Open
module.exports = function (Posts) {
Posts.bookmark = async function (pid, uid) {
return await toggleBookmark('bookmark', pid, uid);
};
- 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"