designcreateplay/NodeBB

View on GitHub

Showing 459 of 552 total issues

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

module.exports = function (module) {
    const helpers = require('./helpers');

    const cache = require('../cache').create('redis');

Severity: Major
Found in src/database/redis/hash.js - About 5 hrs to fix

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

    module.exports = function (Posts) {
        Posts.delete = async function (pid, uid) {
            return await deleteOrRestore('delete', pid, uid);
        };
    
    
    Severity: Major
    Found in src/posts/delete.js - About 5 hrs to fix

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

      module.exports = function (Groups) {
          Groups.create = async function (data) {
              const isSystem = isSystemGroup(data);
              const timestamp = data.timestamp || Date.now();
              let disableJoinRequests = parseInt(data.disableJoinRequests, 10) === 1 ? 1 : 0;
      Severity: Minor
      Found in src/groups/create.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 43 (exceeds 10 allowed). Consider refactoring.
      Open

      module.exports = function (Topics) {
          Topics.createTopicFromPosts = async function (uid, title, pids, fromTid, cid) {
              if (title) {
                  title = title.trim();
              }
      Severity: Minor
      Found in src/topics/fork.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 43 (exceeds 10 allowed). Consider refactoring.
      Open

      module.exports = function (Posts) {
          pubsub.on('post:edit', (pid) => {
              require('./cache').del(pid);
          });
      
      
      Severity: Minor
      Found in src/posts/edit.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 42 (exceeds 10 allowed). Consider refactoring.
      Open

      module.exports = function (Plugins) {
          if (nconf.get('isPrimary')) {
              pubsub.on('plugins:toggleInstall', (data) => {
                  if (data.hostname !== os.hostname()) {
                      toggleInstall(data.id, data.version);
      Severity: Minor
      Found in src/plugins/install.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 42 (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/mongo/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 189 lines of code (exceeds 75 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 5 hrs to fix

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

        module.exports = function (User) {
            const deletesInProgress = {};
        
            User.delete = async (callerUid, uid) => {
                await User.deleteContent(callerUid, uid);
        Severity: Major
        Found in src/user/delete.js - About 5 hrs to fix

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

          module.exports = function (Topics) {
              Topics.getTeasers = async function (topics, options) {
                  if (!Array.isArray(topics) || !topics.length) {
                      return [];
                  }
          Severity: Minor
          Found in src/topics/teaser.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 navigator.js has 642 lines of code (exceeds 500 allowed). Consider refactoring.
          Open

          'use strict';
          
          define('navigator', [
              'forum/pagination', 'components', 'hooks', 'alerts', 'translator', 'storage',
          ], function (pagination, components, hooks, alerts, translator, storage) {
          Severity: Major
          Found in public/src/modules/navigator.js - About 5 hrs to fix

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

            module.exports = function (module) {
                const helpers = require('./helpers');
            
                module.listPrepend = async function (key, value) {
                    if (!key) {
            Severity: Major
            Found in src/database/postgres/list.js - About 5 hrs to fix

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

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

              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
                  Severity
                  Category
                  Status
                  Source
                  Language