NodeBB/NodeBB

View on GitHub

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');
    };

Severity: Major
Found in src/user/posts.js - About 2 hrs to fix

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

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

        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

          File sorted.js has 526 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 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

                    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 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 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 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 (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 (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

                                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

                                Severity
                                Category
                                Status
                                Source
                                Language