NodeBB/NodeBB

View on GitHub

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');
Severity: Major
Found in src/install.js - About 2 hrs to fix

    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) {
    Severity: Major
    Found in public/src/modules/iconSelect.js - About 2 hrs to fix

      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');
              },
      Severity: Major
      Found in public/src/admin/manage/category-analytics.js - About 2 hrs to fix

        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');
        Severity: Major
        Found in src/controllers/helpers.js - About 2 hrs to fix

          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({
          Severity: Major
          Found in public/src/admin/extend/widgets.js - About 2 hrs to fix

            File sorted.js has 521 lines of code (exceeds 500 allowed). Consider refactoring.
            Open

            'use strict';
            
            const _ = require('lodash');
            const utils = require('../../utils');
            
            
            Severity: Major
            Found in src/database/mongo/sorted.js - About 2 hrs to fix

              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;
              Severity: Major
              Found in src/categories/update.js - About 2 hrs to fix

                Function exports has 111 lines of code (exceeds 75 allowed). Consider refactoring.
                Open

                module.exports = function (Posts) {
                    Posts.urlRegex = {
                        regex: /href="([^"]+)"/g,
                        length: 6,
                    };
                Severity: Major
                Found in src/posts/parse.js - About 2 hrs to fix

                  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;
                      }
                  Severity: Minor
                  Found in src/controllers/accounts/helpers.js - About 2 hrs to fix

                  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;
                  Severity: Major
                  Found in src/controllers/search.js - About 2 hrs to fix

                    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;
                    Severity: Major
                    Found in src/controllers/category.js - About 2 hrs to fix

                      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) {
                      Severity: Major
                      Found in src/user/info.js - About 2 hrs to fix

                        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) {
                        Severity: Major
                        Found in src/messaging/create.js - About 2 hrs to fix

                          File dashboard.js has 513 lines of code (exceeds 500 allowed). Consider refactoring.
                          Open

                          import {
                              Chart,
                              LineController,
                              DoughnutController,
                              CategoryScale,
                          Severity: Major
                          Found in public/src/admin/dashboard.js - About 2 hrs to fix

                            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]]');
                                    }
                            Severity: Minor
                            Found in src/socket.io/posts/votes.js - About 2 hrs to fix

                            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;
                                    }
                            Severity: Minor
                            Found in src/database/mongo/sorted/union.js - About 2 hrs to fix

                            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),
                            Severity: Minor
                            Found in src/controllers/mods.js - About 2 hrs to fix

                            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);
                                };
                            
                            
                            Severity: Minor
                            Found in src/posts/bookmarks.js - About 2 hrs to fix

                            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', []);
                            Severity: Minor
                            Found in src/database/redis/main.js - About 2 hrs to fix

                            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)) {
                            Severity: Minor
                            Found in src/user/auth.js - About 2 hrs to fix

                            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

                            Severity
                            Category
                            Status
                            Source
                            Language