Showing 536 of 552 total issues
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');
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({
File sorted.js
has 521 lines of code (exceeds 500 allowed). Consider refactoring. Open
'use strict';
const _ = require('lodash');
const utils = require('../../utils');
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 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 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 exports
has 110 lines of code (exceeds 75 allowed). Consider refactoring. Open
module.exports = function (User) {
User.getLatestBanInfo = async function (uid) {
// Simply retrieves the last record of the user's ban, even if they've been unbanned since then.
const record = await db.getSortedSetRevRange(`uid:${uid}:bans:timestamp`, 0, 0);
if (!record.length) {
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 (SocketPosts) {
SocketPosts.getVoters = async function (socket, data) {
if (!data || !data.pid) {
throw new Error('[[error:invalid-data]]');
}
- 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 (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 (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"
Further reading
Function exports
has a Cognitive Complexity of 22 (exceeds 10 allowed). Consider refactoring. Open
module.exports = function (module) {
const helpers = require('./helpers');
module.flushdb = async function () {
await module.client.send_command('flushdb', []);
- 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"