designcreateplay/NodeBB

View on GitHub

Showing 459 of 552 total issues

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

module.exports = function (Topics) {
    Topics.create = async function (data) {
        // This is an internal method, consider using Topics.post instead
        const timestamp = data.timestamp || Date.now();

Severity: Major
Found in src/topics/create.js - About 7 hrs to fix

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

    module.exports = function (Posts) {
        const votesInProgress = {};
    
        Posts.upvote = async function (pid, uid) {
            if (meta.config['reputation:disabled']) {
    Severity: Major
    Found in src/posts/votes.js - About 7 hrs to fix

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

      module.exports = function (module) {
          const _ = require('lodash');
          const helpers = require('./helpers');
      
          module.setAdd = async function (key, value) {
      Severity: Minor
      Found in src/database/mongo/sets.js - About 7 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 243 lines of code (exceeds 75 allowed). Consider refactoring.
      Open

      module.exports = function (Groups) {
          Groups.update = async function (groupName, values) {
              const exists = await db.exists(`group:${groupName}`);
              if (!exists) {
                  throw new Error('[[error:no-group]]');
      Severity: Major
      Found in src/groups/update.js - About 7 hrs to fix

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

        module.exports = function (module) {
            const helpers = require('./helpers');
        
            const cache = require('../cache').create('mongo');
        
        
        Severity: Major
        Found in src/database/mongo/hash.js - About 7 hrs to fix

          Function setupGraphs has 239 lines of code (exceeds 75 allowed). Consider refactoring.
          Open

          function setupGraphs(callback) {
              callback = callback || function () {};
              const trafficCanvas = document.getElementById('analytics-traffic');
              const registeredCanvas = document.getElementById('analytics-registered');
              const presenceCanvas = document.getElementById('analytics-presence');
          Severity: Major
          Found in public/src/admin/dashboard.js - About 7 hrs to fix

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

            module.exports = function (Topics) {
                const topicTools = {};
                Topics.tools = topicTools;
            
                topicTools.delete = async function (tid, uid) {
            Severity: Major
            Found in src/topics/tools.js - About 7 hrs to fix

              Function checkUpgrade has 237 lines of code (exceeds 75 allowed). Consider refactoring.
              Open

              async function checkUpgrade(client) {
                  const res = await client.query(`
              SELECT EXISTS(SELECT *
                              FROM "information_schema"."columns"
                             WHERE "table_schema" = 'public'
              Severity: Major
              Found in src/database/postgres.js - About 7 hrs to fix

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

                module.exports = function (Topics) {
                    Topics.getSortedTopics = async function (params) {
                        const data = {
                            nextStart: 0,
                            topicCount: 0,
                Severity: Major
                Found in src/topics/sorted.js - About 7 hrs to fix

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

                  module.exports = function (Posts) {
                      Posts.getUserInfoForPosts = async function (uids, uid) {
                          const [userData, userSettings, signatureUids] = await Promise.all([
                              getUserData(uids, uid),
                              user.getMultipleUserSettings(uids),
                  Severity: Major
                  Found in src/posts/user.js - About 7 hrs to fix

                    File chats.js has 723 lines of code (exceeds 500 allowed). Consider refactoring.
                    Open

                    'use strict';
                    
                    
                    define('forum/chats', [
                        'components',
                    Severity: Major
                    Found in public/src/client/chats.js - About 7 hrs to fix

                      Function exports has 230 lines of code (exceeds 75 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: Major
                      Found in src/database/postgres/main.js - About 7 hrs to fix

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

                        module.exports = function (middleware) {
                            async function authenticate(req, res) {
                                async function finishLogin(req, user) {
                                    const loginAsync = util.promisify(req.login).bind(req);
                                    await loginAsync(user, { keepSessionInfo: true });
                        Severity: Major
                        Found in src/middleware/user.js - About 6 hrs to fix

                          Function exports has 222 lines of code (exceeds 75 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/postgres/sets.js - About 6 hrs to fix

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

                                Plugins.init = function () {
                                    const pluginsList = $('.plugins');
                                    const numPlugins = pluginsList[0].querySelectorAll('li').length;
                                    let pluginID;
                            
                            
                            Severity: Major
                            Found in public/src/admin/extend/plugins.js - About 6 hrs to fix

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

                              module.exports = function (Categories) {
                                  Categories.create = async function (data) {
                                      const parentCid = data.parentCid ? data.parentCid : 0;
                                      const [cid, firstChild] = await Promise.all([
                                          db.incrObjectField('global', 'nextCid'),
                              Severity: Minor
                              Found in src/categories/create.js - About 6 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 212 lines of code (exceeds 75 allowed). Consider refactoring.
                              Open

                              module.exports = function (Categories) {
                                  Categories.create = async function (data) {
                                      const parentCid = data.parentCid ? data.parentCid : 0;
                                      const [cid, firstChild] = await Promise.all([
                                          db.incrObjectField('global', 'nextCid'),
                              Severity: Major
                              Found in src/categories/create.js - About 6 hrs to fix

                                Function exports has 207 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 6 hrs to fix

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

                                      Category.init = function () {
                                          const categorySettings = $('#category-settings');
                                          const previewEl = $('[component="category/preview"]');
                                          categorySettings.find('select').each(function () {
                                              const $this = $(this);
                                  Severity: Major
                                  Found in public/src/admin/manage/category.js - About 5 hrs to fix

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

                                    module.exports = function (middleware) {
                                        middleware.addHeaders = helpers.try((req, res, next) => {
                                            const headers = {
                                                'X-Powered-By': encodeURI(meta.config['powered-by'] || 'NodeBB'),
                                                'Access-Control-Allow-Methods': encodeURI(meta.config['access-control-allow-methods'] || ''),
                                    Severity: Minor
                                    Found in src/middleware/headers.js - About 5 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