NodeBB/NodeBB

View on GitHub

Showing 536 of 552 total issues

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

module.exports = function (User) {
    User.blocks = {
        _cache: cacheCreate({
            name: 'user:blocks',
            max: 100,
Severity: Minor
Found in src/user/blocks.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 147 lines of code (exceeds 75 allowed). Consider refactoring.
Open

module.exports = function (Messaging) {
    Messaging.newMessageCutoff = 1000 * 60 * 3;

    Messaging.getMessagesFields = async (mids, fields) => {
        if (!Array.isArray(mids) || !mids.length) {
Severity: Major
Found in src/messaging/data.js - About 3 hrs to fix

    Function exports has 144 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 a Cognitive Complexity of 31 (exceeds 10 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: Minor
      Found in src/topics/follow.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 31 (exceeds 10 allowed). Consider refactoring.
      Open

      module.exports = function (module) {
          const helpers = require('../helpers');
          const utils = require('../../../utils');
      
          module.sortedSetAdd = async function (key, score, value) {
      Severity: Minor
      Found in src/database/postgres/sorted/add.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 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 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 141 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 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 update has a Cognitive Complexity of 30 (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 30 (exceeds 10 allowed). Consider refactoring.
              Open

              module.exports = function (Messaging) {
                  Messaging.setUserNotificationSetting = async (uid, roomId, value) => {
                      if (parseInt(value, 10) === -1) {
                          // go back to default
                          return await db.deleteObjectField(`chat:room:${roomId}:notification:settings`, uid);
              Severity: Minor
              Found in src/messaging/notifications.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 init has 139 lines of code (exceeds 75 allowed). Consider refactoring.
              Open

                  ThreadTools.init = function (tid, topicContainer) {
                      renderMenu(topicContainer);
              
                      $('.topic-main-buttons [title]').tooltip({
                          container: '#content',
              Severity: Major
              Found in public/src/client/topic/threadTools.js - About 3 hrs to fix

                Function exports has 139 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 138 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 3 hrs to fix

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

                        Details.init = function () {
                            const detailsPage = components.get('groups/container');
                    
                            groupName = ajaxify.data.group.name;
                    
                    
                    Severity: Major
                    Found in public/src/client/groups/details.js - About 3 hrs to fix

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

                      module.exports = function (Posts) {
                          const Diffs = {};
                          Posts.diffs = Diffs;
                          Diffs.exists = async function (pid) {
                              if (meta.config.enablePostHistory !== 1) {
                      Severity: Major
                      Found in src/posts/diffs.js - About 3 hrs to fix

                        Function processSortedSet has a Cognitive Complexity of 28 (exceeds 10 allowed). Consider refactoring.
                        Open

                        exports.processSortedSet = async function (setKey, process, options) {
                            options = options || {};
                        
                            if (typeof process !== 'function') {
                                throw new Error('[[error:process-not-a-function]]');
                        Severity: Minor
                        Found in src/batch.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 28 (exceeds 10 allowed). Consider refactoring.
                        Open

                        module.exports = function (Posts) {
                            Posts.delete = async function (pid, uid) {
                                return await deleteOrRestore('delete', pid, uid);
                            };
                        
                        
                        Severity: Minor
                        Found in src/posts/delete.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 28 (exceeds 10 allowed). Consider refactoring.
                        Open

                        module.exports = function (Messaging) {
                            Messaging.newMessageCutoff = 1000 * 60 * 3;
                        
                            Messaging.getMessagesFields = async (mids, fields) => {
                                if (!Array.isArray(mids) || !mids.length) {
                        Severity: Minor
                        Found in src/messaging/data.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 handleScrollNav has 131 lines of code (exceeds 75 allowed). Consider refactoring.
                        Open

                            function handleScrollNav() {
                                if (!thumbs.length) {
                                    return;
                                }
                        
                        
                        Severity: Major
                        Found in public/src/modules/navigator.js - About 3 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language