NodeBB/NodeBB

View on GitHub

Showing 441 of 550 total issues

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

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

      module.exports = function (module) {
          const helpers = require('./helpers');
      
          module.flushdb = async function () {
              await module.pool.query(`DROP SCHEMA "public" CASCADE`);
      Severity: Minor
      Found in src/database/postgres/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 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 (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

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

            module.exports = function (User) {
                const spiderDefaultSettings = {
                    usePagination: 1,
                    topicPostSort: 'oldest_to_newest',
                    postsPerPage: 20,
            Severity: Major
            Found in src/user/settings.js - About 3 hrs to fix

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

              module.exports = function (Groups) {
                  Groups.join = async function (groupNames, uid) {
                      if (!groupNames) {
                          throw new Error('[[error:invalid-data]]');
                      }
              Severity: Minor
              Found in src/groups/join.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 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.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 getTopic has a Cognitive Complexity of 32 (exceeds 10 allowed). Consider refactoring.
              Open

              topicsController.get = async function getTopic(req, res, next) {
                  const tid = req.params.topic_id;
                  if (
                      (req.params.post_index && !utils.isNumber(req.params.post_index) && req.params.post_index !== 'unread') ||
                      !utils.isNumber(tid)
              Severity: Minor
              Found in src/controllers/topics.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) {
                  const spiderDefaultSettings = {
                      usePagination: 1,
                      topicPostSort: 'oldest_to_newest',
                      postsPerPage: 20,
              Severity: Minor
              Found in src/user/settings.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 (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: Minor
              Found in src/categories/recentreplies.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

              Severity
              Category
              Status
              Source
              Language