NodeBB/NodeBB

View on GitHub

Showing 536 of 552 total issues

Function exports has 131 lines of code (exceeds 75 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 3 hrs to fix

    Function exports has 131 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 3 hrs to fix

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

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

        File tags.js has 546 lines of code (exceeds 500 allowed). Consider refactoring.
        Open

        
        'use strict';
        
        const async = require('async');
        const validator = require('validator');
        Severity: Major
        Found in src/topics/tags.js - About 3 hrs to fix

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

          module.exports = function (Topics) {
              Topics.delete = async function (tid, uid) {
                  const [cid, pids] = await Promise.all([
                      Topics.getTopicField(tid, 'cid'),
                      Topics.getPids(tid),
          Severity: Major
          Found in src/topics/delete.js - About 3 hrs to fix

            Function exports has 126 lines of code (exceeds 75 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 3 hrs to fix

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

              module.exports = function (User) {
                  new cronJob('0 * * * *', (() => {
                      User.autoApprove();
                  }), null, true);
              
              
              Severity: Major
              Found in src/user/approval.js - About 3 hrs to fix

                Function UserCommands has 125 lines of code (exceeds 75 allowed). Consider refactoring.
                Open

                function UserCommands() {
                    const { argParsers, getAdminUidOrFail, setupApp } = UserCmdHelpers();
                
                    async function info({ uid, username, userslug }) {
                        if (!uid && !username && !userslug) {
                Severity: Major
                Found in src/cli/user.js - About 3 hrs to fix

                  Function enableQuickSearch has 124 lines of code (exceeds 75 allowed). Consider refactoring.
                  Open

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

                    Function handleErrors has a Cognitive Complexity of 26 (exceeds 10 allowed). Consider refactoring.
                    Open

                    exports.handleErrors = async function handleErrors(err, req, res, next) { // eslint-disable-line no-unused-vars
                        const cases = {
                            EBADCSRFTOKEN: function () {
                                winston.error(`${req.method} ${req.originalUrl}\n${err.message}`);
                                res.sendStatus(403);
                    Severity: Minor
                    Found in src/controllers/errors.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 26 (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 26 (exceeds 10 allowed). Consider refactoring.
                    Open

                    module.exports = function (Groups) {
                        Groups.leave = async function (groupNames, uid) {
                            if (Array.isArray(groupNames) && !groupNames.length) {
                                return;
                            }
                    Severity: Minor
                    Found in src/groups/leave.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 26 (exceeds 10 allowed). Consider refactoring.
                    Open

                    module.exports = function (module) {
                        const helpers = require('../helpers');
                    
                        module.sortedSetRemove = async function (key, value) {
                            if (!key) {
                    Severity: Minor
                    Found in src/database/mongo/sorted/remove.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 init has 122 lines of code (exceeds 75 allowed). Consider refactoring.
                    Open

                        Detail.init = function () {
                            // Update attributes
                            $('#state').val(ajaxify.data.state).removeAttr('disabled');
                            $('#assignee').val(ajaxify.data.assignee).removeAttr('disabled');
                    
                    
                    Severity: Major
                    Found in public/src/client/flags/detail.js - About 2 hrs to fix

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

                          module.createModal = function (data, callback) {
                              callback = callback || function () {};
                              require([
                                  'scrollStop', 'forum/chats', 'forum/chats/messages', 'forum/chats/message-search',
                              ], function (scrollStop, Chats, ChatsMessages, messageSearch) {
                      Severity: Major
                      Found in public/src/modules/chat.js - About 2 hrs to fix

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

                        module.exports = function (opts) {
                            const { LRUCache } = require('lru-cache');
                            const pubsub = require('../pubsub');
                        
                            // lru-cache@7 deprecations
                        Severity: Major
                        Found in src/cache/lru.js - About 2 hrs to fix

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

                            module.exports = function (User) {
                                User.isReadyToPost = async function (uid, cid) {
                                    await isReady(uid, cid, 'lastposttime');
                                };
                            
                            
                            Severity: Major
                            Found in src/user/posts.js - About 2 hrs to fix

                              Function exports has 117 lines of code (exceeds 75 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: Major
                              Found in src/plugins/install.js - About 2 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language