NodeBB/NodeBB

View on GitHub

Showing 483 of 499 total issues

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 (Categories) {
    Categories.create = async function (data) {
        const parentCid = data.parentCid ? data.parentCid : 0;
        const [cid, firstChild] = await Promise.all([
            db.incrObjectField('global', 'nextCid'),
Severity: Minor
Found in src/categories/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 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 a Cognitive Complexity of 42 (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 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 init has 186 lines of code (exceeds 75 allowed). Consider refactoring.
    Open

        Category.init = function () {
            $('#category-settings select').each(function () {
                var $this = $(this);
                $this.val($this.attr('data-value'));
            });
    Severity: Major
    Found in public/src/admin/manage/category.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

      Function exports has 182 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 182 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 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 181 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

            Function exports has 179 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 178 lines of code (exceeds 75 allowed). Consider refactoring.
              Open

              module.exports = function (Topics) {
                  Topics.getSortedTopics = async function (params) {
                      const data = {
                          nextStart: 0,
                          topicCount: 0,
              Severity: Major
              Found in src/topics/sorted.js - About 5 hrs to fix

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

                module.exports = function (middleware) {
                    middleware.addHeaders = helpers.try((req, res, next) => {
                        const headers = {
                            'X-Powered-By': encodeURI(meta.config['powered-by'] || 'NodeBB'),
                            'Access-Control-Allow-Methods': encodeURI(meta.config['access-control-allow-methods'] || ''),
                Severity: Minor
                Found in src/middleware/headers.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 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 a Cognitive Complexity of 38 (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 38 (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 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 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 email has a Cognitive Complexity of 37 (exceeds 10 allowed). Consider refactoring.
                Open

                Interstitials.email = async (data) => {
                    if (!data.userData) {
                        throw new Error('[[error:invalid-data]]');
                    }
                    if (!data.userData.updateEmail) {
                Severity: Minor
                Found in src/user/interstitials.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 168 lines of code (exceeds 75 allowed). Consider refactoring.
                Open

                module.exports = function (Categories) {
                    Categories.getRecentReplies = async function (cid, uid, count) {
                        if (!parseInt(count, 10)) {
                            return [];
                        }
                Severity: Major
                Found in src/categories/recentreplies.js - About 4 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language