NodeBB/NodeBB

View on GitHub

Showing 485 of 600 total issues

Function init has 186 lines of code (exceeds 50 allowed). Consider refactoring.
Open

    Category.init = function () {
        $('#category-settings select').each(function () {
            var $this = $(this);
            $this.val($this.attr('data-value'));
        });
Severity: Major
Found in public/src/admin/manage/category.js - About 6 hrs to fix

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

    module.exports = function (User) {
        const deletesInProgress = {};
    
        User.delete = async (callerUid, uid) => {
            await User.deleteContent(callerUid, uid);
    Severity: Major
    Found in src/user/delete.js - About 6 hrs to fix

      File utils.js has 677 lines of code (exceeds 500 allowed). Consider refactoring.
      Open

      'use strict';
      
      (function (factory) {
          if (typeof module === 'object' && module.exports) {
              var winston = require('winston');
      Severity: Major
      Found in public/src/utils.js - About 6 hrs to fix

        Function exports has 178 lines of code (exceeds 50 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 6 hrs to fix

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

          module.exports = function (module) {
              const helpers = require('./helpers');
          
              module.listPrepend = async function (key, value) {
                  if (!key) {
          Severity: Major
          Found in src/database/postgres/list.js - About 6 hrs to fix

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

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

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

              module.exports = function (Groups) {
                  Groups.create = async function (data) {
                      const isSystem = isSystemGroup(data);
                      const timestamp = data.timestamp || Date.now();
                      let disableJoinRequests = parseInt(data.disableJoinRequests, 10) === 1 ? 1 : 0;
              Severity: Minor
              Found in src/groups/create.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

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

              module.exports = function (Categories) {
                  Categories.getRecentReplies = async function (cid, uid, count) {
                      if (!parseInt(count, 10)) {
                          return [];
                      }
              Severity: Major
              Found in src/categories/recentreplies.js - About 5 hrs to fix

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

                module.exports = function (module) {
                    const helpers = require('../helpers');
                    const utils = require('../../../utils');
                
                    module.sortedSetAdd = async function (key, score, value) {
                Severity: Minor
                Found in src/database/mongo/sorted/add.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

                Function exports has a Cognitive Complexity of 42 (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 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

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

                module.exports = function (Topics) {
                    Topics.getTeasers = async function (topics, options) {
                        if (!Array.isArray(topics) || !topics.length) {
                            return [];
                        }
                Severity: Minor
                Found in src/topics/teaser.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

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

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

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

                    module.exports = function (middleware) {
                        middleware.processRender = function processRender(req, res, next) {
                            // res.render post-processing, modified from here: https://gist.github.com/mrlannigan/5051687
                            const { render } = res;
                            res.render = async function renderOverride(template, options, fn) {
                    Severity: Minor
                    Found in src/middleware/render.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

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

                    module.exports = function (User) {
                        User.getAllowedProfileImageExtensions = function () {
                            const exts = User.getAllowedImageTypes().map(type => mime.getExtension(type));
                            if (exts.includes('jpeg')) {
                                exts.push('jpg');
                    Severity: Minor
                    Found in src/user/picture.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

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

                    module.exports = function (module) {
                        const helpers = require('../helpers');
                        const utils = require('../../../utils');
                    
                        module.sortedSetAdd = async function (key, score, value) {
                    Severity: Minor
                    Found in src/database/redis/sorted/add.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

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

                    module.exports = function (User) {
                        User.getAllowedProfileImageExtensions = function () {
                            const exts = User.getAllowedImageTypes().map(type => mime.getExtension(type));
                            if (exts.includes('jpeg')) {
                                exts.push('jpg');
                    Severity: Major
                    Found in src/user/picture.js - About 5 hrs to fix

                      Function init has 155 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                          CategoryAnalytics.init = function () {
                              var hourlyCanvas = document.getElementById('pageviews:hourly');
                              var    dailyCanvas = document.getElementById('pageviews:daily');
                              var    topicsCanvas = document.getElementById('topics:daily');
                              var    postsCanvas = document.getElementById('posts:daily');
                      Severity: Major
                      Found in public/src/admin/manage/category-analytics.js - About 5 hrs to fix

                        Function exports has a Cognitive Complexity of 39 (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

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

                        module.exports = function (User) {
                            User.bans = {};
                        
                            User.bans.ban = async function (uid, until, reason) {
                                // "until" (optional) is unix timestamp in milliseconds
                        Severity: Minor
                        Found in src/user/bans.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