NodeBB/NodeBB

View on GitHub

Showing 441 of 550 total issues

Function exports has a Cognitive Complexity of 40 (exceeds 10 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: Minor
Found in src/groups/membership.js - About 5 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 40 (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/redis/sorted/add.js - About 5 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 40 (exceeds 10 allowed). Consider refactoring.
Open

module.exports = function (Posts) {
    const Diffs = {};
    Posts.diffs = Diffs;
    Diffs.exists = async function (pid) {
        if (meta.config.enablePostHistory !== 1) {
Severity: Minor
Found in src/posts/diffs.js - About 5 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 UserCommands has a Cognitive Complexity of 40 (exceeds 10 allowed). Consider refactoring.
Open

function UserCommands() {
    const { argParsers, getAdminUidOrFail, setupApp } = UserCmdHelpers();

    async function info({ uid, username, userslug }) {
        if (!uid && !username && !userslug) {
Severity: Minor
Found in src/cli/user.js - About 5 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 40 (exceeds 10 allowed). Consider refactoring.
Open

module.exports = function (User) {
    User.getAllowedProfileImageExtensions = function () {
        const exts = User.getAllowedImageTypes().map(type => mime.getExtension(type));
        if (exts.includes('jpeg')) {
            exts.push('jpg');
Severity: Minor
Found in src/user/picture.js - About 5 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 utils.common.js has 635 lines of code (exceeds 500 allowed). Consider refactoring.
Open

'use strict';


// add default escape function for escaping HTML entities
const escapeCharMap = Object.freeze({
Severity: Major
Found in public/src/utils.common.js - About 5 hrs to fix

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

    module.exports = function (User) {
        User.getAllowedProfileImageExtensions = function () {
            const exts = User.getAllowedImageTypes().map(type => mime.getExtension(type));
            if (exts.includes('jpeg')) {
                exts.push('jpg');
    Severity: Major
    Found in src/user/picture.js - About 5 hrs to fix

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

                  File users.js has 601 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
                    Severity
                    Category
                    Status
                    Source
                    Language