NodeBB/NodeBB

View on GitHub

Showing 589 of 606 total issues

Function parse has 151 lines of code (exceeds 50 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 5 hrs to fix

    Function exports has 150 lines of code (exceeds 50 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 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 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 addPostHandlers has 142 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

          function addPostHandlers(tid) {
              var postContainer = components.get('topic');
      
              postContainer.on('click', '[component="post/quote"]', function () {
                  onQuoteClicked($(this), tid);
      Severity: Major
      Found in public/src/client/topic/postTools.js - About 4 hrs to fix

        Function exports has 142 lines of code (exceeds 50 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: Major
        Found in src/user/invite.js - About 4 hrs to fix

          Function exports has 142 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          module.exports = function (User) {
              User.getSettings = async function (uid) {
                  if (parseInt(uid, 10) <= 0) {
                      return await onSettingsLoaded(0, {});
                  }
          Severity: Major
          Found in src/user/settings.js - About 4 hrs to fix

            Function exports has 141 lines of code (exceeds 50 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: Major
            Found in src/topics/follow.js - About 4 hrs to fix

              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 (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 (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 139 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              module.exports = function (Plugins) {
                  async function registerPluginAssets(pluginData, fields) {
                      function add(dest, arr) {
                          dest.push(...(arr || []));
                      }
              Severity: Major
              Found in src/plugins/load.js - About 4 hrs to fix

                Function exports has 137 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                module.exports = function (Topics) {
                    Topics.getTeasers = async function (topics, options) {
                        if (!Array.isArray(topics) || !topics.length) {
                            return [];
                        }
                Severity: Major
                Found in src/topics/teaser.js - About 4 hrs to fix

                  Function exports has 137 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  module.exports = function (grunt) {
                      const args = [];
                  
                      if (!grunt.option('verbose')) {
                          args.push('--log-level=info');
                  Severity: Major
                  Found in Gruntfile.js - About 4 hrs to fix

                    Function exports has 137 lines of code (exceeds 50 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: Major
                    Found in src/groups/membership.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 134 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      module.exports = function (User) {
                          User.auth = {};
                      
                          User.auth.logAttempt = async function (uid, ip) {
                              if (!(parseInt(uid, 10) > 0)) {
                      Severity: Major
                      Found in src/user/auth.js - About 4 hrs to fix

                        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 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 131 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        module.exports = function (module) {
                            const helpers = require('./helpers');
                        
                            module.setAdd = async function (key, value) {
                                if (!Array.isArray(value)) {
                        Severity: Major
                        Found in src/database/mongo/sets.js - About 4 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language