NodeBB/NodeBB

View on GitHub

Showing 583 of 600 total issues

Function exports has a Cognitive Complexity of 64 (exceeds 10 allowed). Consider refactoring.
Open

module.exports = function (Posts) {
    Posts.getQueuedPosts = async (filter = {}, options = {}) => {
        options = { metadata: true, ...options };    // defaults
        let postData = _.cloneDeep(cache.get('post-queue'));
        if (!postData) {
Severity: Minor
Found in src/posts/queue.js - About 1 day 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 248 lines of code (exceeds 50 allowed). Consider refactoring.
Open

module.exports = function (User) {
    const fieldWhitelist = [
        'uid', 'username', 'userslug', 'email', 'email:confirmed', 'joindate',
        'lastonline', 'picture', 'icon:bgColor', 'fullname', 'location', 'birthday', 'website',
        'aboutme', 'signature', 'uploadedpicture', 'profileviews', 'reputation',
Severity: Major
Found in src/user/data.js - About 1 day to fix

    Function setupGraphs has 244 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

        function setupGraphs(callback) {
            callback = callback || function () {};
            var trafficCanvas = document.getElementById('analytics-traffic');
            var registeredCanvas = document.getElementById('analytics-registered');
            var presenceCanvas = document.getElementById('analytics-presence');
    Severity: Major
    Found in public/src/admin/dashboard.js - About 1 day to fix

      Function exports has a Cognitive Complexity of 60 (exceeds 10 allowed). Consider refactoring.
      Open

      module.exports = function (User) {
          User.create = async function (data) {
              data.username = data.username.trim();
              data.userslug = slugify(data.username);
              if (data.email !== undefined) {
      Severity: Minor
      Found in src/user/create.js - About 1 day 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 232 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      module.exports = function (Posts) {
          const votesInProgress = {};
      
          Posts.upvote = async function (pid, uid) {
              if (meta.config['reputation:disabled']) {
      Severity: Major
      Found in src/posts/votes.js - About 1 day to fix

        Function exports has 228 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        module.exports = function (Topics) {
            Topics.create = async function (data) {
                // This is an internal method, consider using Topics.post instead
                const timestamp = data.timestamp || Date.now();
        
        
        Severity: Major
        Found in src/topics/create.js - About 1 day to fix

          Function exports has 223 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          module.exports = function (Topics) {
              const topicTools = {};
              Topics.tools = topicTools;
          
              topicTools.delete = async function (tid, uid) {
          Severity: Major
          Found in src/topics/tools.js - About 7 hrs to fix

            Function exports has 220 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            module.exports = function (Groups) {
                Groups.update = async function (groupName, values) {
                    const exists = await db.exists(`group:${groupName}`);
                    if (!exists) {
                        throw new Error('[[error:no-group]]');
            Severity: Major
            Found in src/groups/update.js - About 7 hrs to fix

              Function checkUpgrade has 219 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              async function checkUpgrade(client) {
                  const res = await client.query(`
              SELECT EXISTS(SELECT *
                              FROM "information_schema"."columns"
                             WHERE "table_schema" = 'public'
              Severity: Major
              Found in src/database/postgres.js - About 7 hrs to fix

                Function exports has a Cognitive Complexity of 55 (exceeds 10 allowed). Consider refactoring.
                Open

                module.exports = function (Topics) {
                    Topics.getSortedTopics = async function (params) {
                        const data = {
                            nextStart: 0,
                            topicCount: 0,
                Severity: Minor
                Found in src/topics/sorted.js - About 7 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 213 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                module.exports = function (Posts) {
                    Posts.getUserInfoForPosts = async function (uids, uid) {
                        const [userData, userSettings, signatureUids] = await Promise.all([
                            getUserData(uids, uid),
                            user.getMultipleUserSettings(uids),
                Severity: Major
                Found in src/posts/user.js - About 7 hrs to fix

                  File app.js has 720 lines of code (exceeds 500 allowed). Consider refactoring.
                  Open

                  'use strict';
                  
                  
                  app = window.app || {};
                  
                  
                  Severity: Major
                  Found in public/src/app.js - About 7 hrs to fix

                    Function exports has 200 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    module.exports = function (Messaging) {
                        Messaging.getRoomData = async (roomId) => {
                            const data = await db.getObject(`chat:room:${roomId}`);
                            if (!data) {
                                throw new Error('[[error:no-chat-room]]');
                    Severity: Major
                    Found in src/messaging/rooms.js - About 7 hrs to fix

                      Function exports has 199 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      module.exports = function (module) {
                          const helpers = require('./helpers');
                      
                          module.flushdb = async function () {
                              await module.pool.query(`DROP SCHEMA "public" CASCADE`);
                      Severity: Major
                      Found in src/database/postgres/main.js - About 6 hrs to fix

                        Function exports has 199 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        module.exports = function (Categories) {
                            Categories.create = async function (data) {
                                const parentCid = data.parentCid ? data.parentCid : 0;
                                const [cid, firstChild] = await Promise.all([
                                    db.incrObjectField('global', 'nextCid'),
                        Severity: Major
                        Found in src/categories/create.js - About 6 hrs to fix

                          Function exports has a Cognitive Complexity of 50 (exceeds 10 allowed). Consider refactoring.
                          Open

                          module.exports = function (module) {
                              const helpers = require('./helpers');
                          
                              module.setAdd = async function (key, value) {
                                  if (!Array.isArray(value)) {
                          Severity: Minor
                          Found in src/database/mongo/sets.js - About 6 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 197 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          module.exports = function (middleware) {
                              async function authenticate(req, res) {
                                  const loginAsync = util.promisify(req.login).bind(req);
                          
                                  if (req.loggedIn) {
                          Severity: Major
                          Found in src/middleware/user.js - About 6 hrs to fix

                            File flags.js has 702 lines of code (exceeds 500 allowed). Consider refactoring.
                            Open

                            'use strict';
                            
                            const _ = require('lodash');
                            const winston = require('winston');
                            const validator = require('validator');
                            Severity: Major
                            Found in src/flags.js - About 6 hrs to fix

                              Function init has 193 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

                                  Plugins.init = function () {
                                      var pluginsList = $('.plugins');
                                      var numPlugins = pluginsList[0].querySelectorAll('li').length;
                                      var pluginID;
                              
                              
                              Severity: Major
                              Found in public/src/admin/extend/plugins.js - About 6 hrs to fix

                                Function exports has 189 lines of code (exceeds 50 allowed). Consider refactoring.
                                Open

                                module.exports = function (module) {
                                    module.sortedSetIntersectCard = async function (keys) {
                                        if (!Array.isArray(keys) || !keys.length) {
                                            return 0;
                                        }
                                Severity: Major
                                Found in src/database/mongo/sorted/intersect.js - About 6 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language