NodeBB/NodeBB

View on GitHub

Showing 490 of 506 total issues

Function addPostHandlers has 143 lines of code (exceeds 75 allowed). Consider refactoring.
Open

    function addPostHandlers(tid) {
        const postContainer = components.get('topic');

        handleSelectionTooltip();

Severity: Major
Found in public/src/client/topic/postTools.js - About 3 hrs to fix

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

    module.exports = function (User) {
        User.getSettings = async function (uid) {
            if (parseInt(uid, 10) <= 0) {
                return await onSettingsLoaded(0, {});
            }
    Severity: Major
    Found in src/user/settings.js - About 3 hrs to fix

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

      module.exports = function (User) {
          User.getInvites = async function (uid) {
              const emails = await db.getSetMembers(`invitation:uid:${uid}`);
              return emails.map(email => validator.escape(String(email)));
          };
      Severity: Major
      Found in src/user/invite.js - About 3 hrs to fix

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

        module.exports = function (Topics) {
            Topics.toggleFollow = async function (tid, uid) {
                const exists = await Topics.exists(tid);
                if (!exists) {
                    throw new Error('[[error:no-topic]]');
        Severity: Major
        Found in src/topics/follow.js - About 3 hrs to fix

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

          module.exports = function (Plugins) {
              async function registerPluginAssets(pluginData, fields) {
                  function add(dest, arr) {
                      dest.push(...(arr || []));
                  }
          Severity: Major
          Found in src/plugins/load.js - About 3 hrs to fix

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

            module.exports = function (SocketUser) {
                SocketUser.changeUsernameEmail = async function (socket, data) {
                    sockets.warnDeprecated(socket, 'PUT /api/v3/users/:uid');
            
                    if (!data || !data.uid || !socket.uid) {
            Severity: Minor
            Found in src/socket.io/user/profile.js - About 3 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 30 (exceeds 10 allowed). Consider refactoring.
            Open

            module.exports = function (module) {
                const helpers = require('./helpers');
            
                module.listPrepend = async function (key, value) {
                    if (!key) {
            Severity: Minor
            Found in src/database/postgres/list.js - About 3 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 137 lines of code (exceeds 75 allowed). Consider refactoring.
            Open

            module.exports = function (grunt) {
                const args = [];
            
                if (!grunt.option('verbose')) {
                    args.push('--log-level=info');
            Severity: Major
            Found in Gruntfile.js - About 3 hrs to fix

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

              module.exports = function (Groups) {
                  Groups.getMembers = async function (groupName, start, stop) {
                      return await db.getSortedSetRevRange(`group:${groupName}:members`, start, stop);
                  };
              
              
              Severity: Major
              Found in src/groups/membership.js - About 3 hrs to fix

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

                module.exports = function (Topics) {
                    Topics.getTeasers = async function (topics, options) {
                        if (!Array.isArray(topics) || !topics.length) {
                            return [];
                        }
                Severity: Major
                Found in src/topics/teaser.js - About 3 hrs to fix

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

                  module.exports = function (User) {
                      User.getSettings = async function (uid) {
                          if (parseInt(uid, 10) <= 0) {
                              return await onSettingsLoaded(0, {});
                          }
                  Severity: Minor
                  Found in src/user/settings.js - About 3 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 134 lines of code (exceeds 75 allowed). Consider refactoring.
                  Open

                  module.exports = function (User) {
                      User.auth = {};
                  
                      User.auth.logAttempt = async function (uid, ip) {
                          if (!(parseInt(uid, 10) > 0)) {
                  Severity: Major
                  Found in src/user/auth.js - About 3 hrs to fix

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

                    module.exports = function (module) {
                        const helpers = require('./helpers');
                    
                        module.setAdd = async function (key, value) {
                            if (!Array.isArray(value)) {
                    Severity: Major
                    Found in src/database/mongo/sets.js - About 3 hrs to fix

                      Function init has 130 lines of code (exceeds 75 allowed). Consider refactoring.
                      Open

                          ThreadTools.init = function (tid, topicContainer) {
                              renderMenu(topicContainer);
                      
                              // function topicCommand(method, path, command, onComplete) {
                              topicContainer.on('click', '[component="topic/delete"]', function () {
                      Severity: Major
                      Found in public/src/client/topic/threadTools.js - About 3 hrs to fix

                        Function update has a Cognitive Complexity of 27 (exceeds 10 allowed). Consider refactoring.
                        Open

                        Flags.update = async function (flagId, uid, changeset) {
                            const current = await db.getObjectFields(`flag:${flagId}`, ['uid', 'state', 'assignee', 'type', 'targetId']);
                            if (!current.type) {
                                return;
                            }
                        Severity: Minor
                        Found in src/flags.js - About 3 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 27 (exceeds 10 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: Minor
                        Found in src/posts/user.js - About 3 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 126 lines of code (exceeds 75 allowed). Consider refactoring.
                        Open

                        module.exports = function (Topics) {
                            Topics.delete = async function (tid, uid) {
                                await Promise.all([
                                    Topics.setTopicFields(tid, {
                                        deleted: 1,
                        Severity: Major
                        Found in src/topics/delete.js - About 3 hrs to fix

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

                          module.exports = function (User) {
                              new cronJob('0 * * * *', (() => {
                                  User.autoApprove();
                              }), null, true);
                          
                          
                          Severity: Major
                          Found in src/user/approval.js - About 3 hrs to fix

                            Function UserCommands has 124 lines of code (exceeds 75 allowed). Consider refactoring.
                            Open

                            function UserCommands() {
                                const { argParsers, getAdminUidOrFail, setupApp } = UserCmdHelpers();
                            
                                async function info({ uid, username, userslug }) {
                                    if (!uid && !username && !userslug) {
                            Severity: Major
                            Found in src/cli/user.js - About 2 hrs to fix

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

                              module.exports = function (module) {
                                  const helpers = require('./helpers');
                                  module.flushdb = async function () {
                                      await module.client.dropDatabase();
                                  };
                              Severity: Major
                              Found in src/database/mongo/main.js - About 2 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language