designcreateplay/NodeBB

View on GitHub

Showing 459 of 552 total issues

utils has 38 functions (exceeds 20 allowed). Consider refactoring.
Open

const utils = {
    // https://github.com/substack/node-ent/blob/master/index.js
    decodeHTMLEntities: function (html) {
        return String(html)
            .replace(/&#(\d+);?/g, function (_, code) {
Severity: Minor
Found in public/src/utils.common.js - About 5 hrs to fix

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

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

      Function exports has a Cognitive Complexity of 38 (exceeds 10 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: Minor
      Found in src/user/invite.js - About 4 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 170 lines of code (exceeds 75 allowed). Consider refactoring.
      Open

      module.exports = function (Posts) {
          Posts.uploads = {};
      
          const md5 = filename => crypto.createHash('md5').update(filename).digest('hex');
          const pathPrefix = path.join(nconf.get('upload_path'));
      Severity: Major
      Found in src/posts/uploads.js - About 4 hrs to fix

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

        module.exports = function (Posts) {
            Posts.uploads = {};
        
            const md5 = filename => crypto.createHash('md5').update(filename).digest('hex');
            const pathPrefix = path.join(nconf.get('upload_path'));
        Severity: Minor
        Found in src/posts/uploads.js - About 4 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 165 lines of code (exceeds 75 allowed). Consider refactoring.
        Open

        module.exports = function (Posts) {
            pubsub.on('post:edit', (pid) => {
                require('./cache').del(pid);
            });
        
        
        Severity: Major
        Found in src/posts/edit.js - About 4 hrs to fix

          Function exports has a Cognitive Complexity of 36 (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 4 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 36 (exceeds 10 allowed). Consider refactoring.
          Open

          module.exports = function (User) {
              User.isReadyToPost = async function (uid, cid) {
                  await isReady(uid, cid, 'lastposttime');
              };
          
          
          Severity: Minor
          Found in src/user/posts.js - About 4 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 36 (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 4 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

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

          'use strict';
          
          module.exports = function (module) {
              const helpers = require('./helpers');
              const util = require('util');
          Severity: Major
          Found in src/database/postgres/sorted.js - About 4 hrs to fix

            File users.js has 606 lines of code (exceeds 500 allowed). Consider refactoring.
            Open

            'use strict';
            
            const path = require('path');
            const fs = require('fs').promises;
            
            
            Severity: Major
            Found in src/api/users.js - About 4 hrs to fix

              File users.js has 602 lines of code (exceeds 500 allowed). Consider refactoring.
              Open

              'use strict';
              
              define('admin/manage/users', [
                  'translator', 'benchpress', 'autocomplete', 'api', 'slugify', 'bootbox', 'alerts', 'accounts/invite', 'helpers', 'admin/modules/change-email',
              ], function (translator, Benchpress, autocomplete, api, slugify, bootbox, alerts, AccountInvite, helpers, changeEmail) {
              Severity: Major
              Found in public/src/admin/manage/users.js - About 4 hrs to fix

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

                module.exports = function (Plugins) {
                    async function registerPluginAssets(pluginData, fields) {
                        function add(dest, arr) {
                            dest.push(...(arr || []));
                        }
                Severity: Minor
                Found in src/plugins/load.js - About 4 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 35 (exceeds 10 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: Minor
                Found in src/messaging/create.js - About 4 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 35 (exceeds 10 allowed). Consider refactoring.
                Open

                module.exports = function (User) {
                    const filterFnMap = {
                        online: user => user.status !== 'offline' && (Date.now() - user.lastonline < 300000),
                        flagged: user => parseInt(user.flags, 10) > 0,
                        verified: user => !!user['email:confirmed'],
                Severity: Minor
                Found in src/user/search.js - About 4 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 160 lines of code (exceeds 75 allowed). Consider refactoring.
                Open

                module.exports = function (Categories) {
                    Categories.getRecentReplies = async function (cid, uid, start, stop) {
                        // backwards compatibility, treat start as count
                        if (stop === undefined && start > 0) {
                            winston.warn('[Categories.getRecentReplies] 3 params deprecated please use Categories.getRecentReplies(cid, uid, start, stop)');
                Severity: Major
                Found in src/categories/recentreplies.js - About 4 hrs to fix

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

                  module.exports = function (SocketTopics) {
                      SocketTopics.isTagAllowed = async function (socket, data) {
                          if (!data || !utils.isNumber(data.cid) || !data.tag) {
                              throw new Error('[[error:invalid-data]]');
                          }
                  Severity: Minor
                  Found in src/socket.io/topics/tags.js - About 4 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 34 (exceeds 10 allowed). Consider refactoring.
                  Open

                  module.exports = function (module) {
                      const helpers = require('./helpers');
                      module.flushdb = async function () {
                          await module.client.dropDatabase();
                      };
                  Severity: Minor
                  Found in src/database/mongo/main.js - About 4 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 34 (exceeds 10 allowed). Consider refactoring.
                  Open

                  module.exports = function (Posts) {
                      Posts.urlRegex = {
                          regex: /href="([^"]+)"/g,
                          length: 6,
                      };
                  Severity: Minor
                  Found in src/posts/parse.js - About 4 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 154 lines of code (exceeds 75 allowed). Consider refactoring.
                  Open

                      tagFilter.init = function (el, options) {
                          if (!el || !el.length) {
                              return;
                          }
                          options = options || {};
                  Severity: Major
                  Found in public/src/modules/tagFilter.js - About 4 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language