NodeBB/NodeBB

View on GitHub

Showing 490 of 506 total issues

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

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

module.exports = function (middleware) {
    async function authenticate(req, res) {
        const loginAsync = util.promisify(req.login).bind(req);

        if (req.loggedIn) {
Severity: Major
Found in src/middleware/user.js - About 4 hrs to fix

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

    module.exports = function (Categories) {
        Categories.getCategoryTopics = async function (data) {
            let results = await plugins.hooks.fire('filter:category.topics.prepare', data);
            const tids = await Categories.getTopicIds(results);
            let topicsData = await topics.getTopicsByTids(tids, data.uid);
    Severity: Major
    Found in src/categories/topics.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 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 exports has a Cognitive Complexity of 34 (exceeds 10 allowed). Consider refactoring.
      Open

      module.exports = function (Categories) {
          Categories.getRecentReplies = async function (cid, uid, count) {
              if (!parseInt(count, 10)) {
                  return [];
              }
      Severity: Minor
      Found in src/categories/recentreplies.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 155 lines of code (exceeds 75 allowed). Consider refactoring.
      Open

          CategoryAnalytics.init = function () {
              const hourlyCanvas = document.getElementById('pageviews:hourly');
              const    dailyCanvas = document.getElementById('pageviews:daily');
              const    topicsCanvas = document.getElementById('topics:daily');
              const    postsCanvas = document.getElementById('posts:daily');
      Severity: Major
      Found in public/src/admin/manage/category-analytics.js - About 4 hrs to fix

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

        module.exports = function (User) {
            User.create = async function (data) {
                data.username = data.username.trim();
                data.userslug = slugify(data.username);
                if (data.email !== undefined) {
        Severity: Major
        Found in src/user/create.js - About 4 hrs to fix

          Function exports has a Cognitive Complexity of 33 (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 parse has 152 lines of code (exceeds 75 allowed). Consider refactoring.
          Open

          Tags.parse = async (req, data, meta, link) => {
              // Meta tags
              const defaultTags = [{
                  name: 'viewport',
                  content: 'width=device-width, initial-scale=1.0',
          Severity: Major
          Found in src/meta/tags.js - About 4 hrs to fix

            Function exports has 152 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

              Consider simplifying this complex logical expression.
              Open

                          if (post) {
                              post.topicOwnerPost = parseInt(topicData.uid, 10) === parseInt(post.uid, 10);
                              post.display_edit_tools = topicPrivileges.isAdminOrMod || (post.selfPost && topicPrivileges['posts:edit']);
                              post.display_delete_tools = topicPrivileges.isAdminOrMod || (post.selfPost && topicPrivileges['posts:delete']);
                              post.display_moderator_tools = post.display_edit_tools || post.display_delete_tools;
              Severity: Critical
              Found in src/topics/posts.js - About 4 hrs to fix

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

                async function getUsers(req, res) {
                    const sortDirection = req.query.sortDirection || 'desc';
                    const reverse = sortDirection === 'desc';
                
                    const page = parseInt(req.query.page, 10) || 1;
                Severity: Minor
                Found in src/controllers/admin/users.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 32 (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 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 32 (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/mongo/list.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 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

                File sorted.js has 578 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 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

                  Severity
                  Category
                  Status
                  Source
                  Language