NodeBB/NodeBB

View on GitHub

Showing 481 of 497 total issues

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

module.exports = function (Topics) {
    Topics.createTopicFromPosts = async function (uid, title, pids, fromTid) {
        if (title) {
            title = title.trim();
        }
Severity: Major
Found in src/topics/fork.js - About 2 hrs to fix

    Function exports has 121 lines of code (exceeds 75 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: Major
    Found in src/user/search.js - About 2 hrs to fix

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

      module.exports = function (SocketUser) {
          SocketUser.changeUsernameEmail = async function (socket, data) {
              sockets.warnDeprecated(socket, 'PUT /api/v3/users/:uid');
      
              if (!data || !data.uid || !socket.uid) {
      Severity: Major
      Found in src/socket.io/user/profile.js - About 2 hrs to fix

        Function exports has a Cognitive Complexity of 25 (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 2 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 fireStaticHook has a Cognitive Complexity of 25 (exceeds 10 allowed). Consider refactoring.
        Open

        async function fireStaticHook(hook, hookList, params) {
            if (!Array.isArray(hookList) || !hookList.length) {
                return;
            }
            // don't bubble errors from these hooks, so bad plugins don't stop startup
        Severity: Minor
        Found in src/plugins/hooks.js - About 2 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 25 (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 2 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 118 lines of code (exceeds 75 allowed). Consider refactoring.
        Open

        module.exports = function (module) {
            const helpers = require('../helpers');
            const utils = require('../../../utils');
        
            module.sortedSetAdd = async function (key, score, value) {
        Severity: Major
        Found in src/database/postgres/sorted/add.js - About 2 hrs to fix

          Function init has 115 lines of code (exceeds 75 allowed). Consider refactoring.
          Open

              AdminsMods.init = function () {
                  autocomplete.user($('#admin-search'), function (ev, ui) {
                      socket.emit('admin.user.makeAdmins', [ui.item.user.uid], function (err) {
                          if (err) {
                              return app.alertError(err.message);
          Severity: Major
          Found in public/src/admin/manage/admins-mods.js - About 2 hrs to fix

            Function enableTopicSearch has 115 lines of code (exceeds 75 allowed). Consider refactoring.
            Open

                app.enableTopicSearch = function (options) {
                    if (!config.searchEnabled || !app.user.privileges['search:content']) {
                        return;
                    }
                    /* eslint-disable-next-line */
            Severity: Major
            Found in public/src/app.js - About 2 hrs to fix

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

              module.exports = function (User) {
                  User.isReadyToPost = async function (uid, cid) {
                      await isReady(uid, cid, 'lastposttime');
                  };
              
              
              Severity: Minor
              Found in src/user/posts.js - About 2 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 24 (exceeds 10 allowed). Consider refactoring.
              Open

              module.exports = function (Messaging) {
                  Messaging.getRoomData = async (roomId) => {
                      const data = await db.getObject(`chat:room:${roomId}`);
                      if (!data) {
                          throw new Error('[[error:no-chat-room]]');
              Severity: Minor
              Found in src/messaging/rooms.js - About 2 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 24 (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 2 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 111 lines of code (exceeds 75 allowed). Consider refactoring.
              Open

              module.exports = function (Posts) {
                  Posts.urlRegex = {
                      regex: /href="([^"]+)"/g,
                      length: 6,
                  };
              Severity: Major
              Found in src/posts/parse.js - About 2 hrs to fix

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

                module.exports = function (SocketTopics) {
                    SocketTopics.loadMore = async function (socket, data) {
                        if (!data || !data.tid || !utils.isNumber(data.after) || parseInt(data.after, 10) < 0) {
                            throw new Error('[[error:invalid-data]]');
                        }
                Severity: Minor
                Found in src/socket.io/topics/infinitescroll.js - About 2 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 23 (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 2 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 getUserDataByUserSlug has a Cognitive Complexity of 23 (exceeds 10 allowed). Consider refactoring.
                Open

                helpers.getUserDataByUserSlug = async function (userslug, callerUID, query = {}) {
                    const uid = await user.getUidByUserslug(userslug);
                    if (!uid) {
                        return null;
                    }
                Severity: Minor
                Found in src/controllers/accounts/helpers.js - About 2 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 get has a Cognitive Complexity of 23 (exceeds 10 allowed). Consider refactoring.
                Open

                categoryController.get = async function (req, res, next) {
                    const cid = req.params.category_id;
                
                    let currentPage = parseInt(req.query.page, 10) || 1;
                    let topicIndex = utils.isNumber(req.params.topic_index) ? parseInt(req.params.topic_index, 10) - 1 : 0;
                Severity: Minor
                Found in src/controllers/category.js - About 2 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 23 (exceeds 10 allowed). Consider refactoring.
                Open

                module.exports = function (Categories) {
                    Categories.update = async function (modified) {
                        const cids = Object.keys(modified);
                        await Promise.all(cids.map(cid => updateCategory(cid, modified[cid])));
                        return cids;
                Severity: Minor
                Found in src/categories/update.js - About 2 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 23 (exceeds 10 allowed). Consider refactoring.
                Open

                module.exports = function (User) {
                    User.auth = {};
                
                    User.auth.logAttempt = async function (uid, ip) {
                        if (!(parseInt(uid, 10) > 0)) {
                Severity: Minor
                Found in src/user/auth.js - About 2 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 110 lines of code (exceeds 75 allowed). Consider refactoring.
                Open

                module.exports = function (Posts) {
                    const Diffs = {};
                    Posts.diffs = Diffs;
                    Diffs.exists = async function (pid) {
                        if (meta.config.enablePostHistory !== 1) {
                Severity: Major
                Found in src/posts/diffs.js - About 2 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language