NodeBB/NodeBB

View on GitHub

Showing 444 of 553 total issues

Function checkPrivileges has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring.
Open

middleware.checkPrivileges = helpers.try(async (req, res, next) => {
    // Kick out guests, obviously
    if (req.uid <= 0) {
        return controllers.helpers.notAllowed(req, res);
    }
Severity: Minor
Found in src/middleware/admin.js - About 1 hr 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 registerComplete has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring.
Open

authenticationController.registerComplete = async function (req, res) {
    try {
        // For the interstitials that respond, execute the callback with the form body
        const data = await user.interstitials.get(req, req.session.registration);
        const callbacks = data.interstitials.reduce((memo, cur) => {
Severity: Minor
Found in src/controllers/authentication.js - About 1 hr 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 19 (exceeds 10 allowed). Consider refactoring.
Open

module.exports = function (module) {
    const helpers = require('../helpers');
    module.sortedSetIntersectCard = async function (keys) {
        if (!Array.isArray(keys) || !keys.length) {
            return 0;
Severity: Minor
Found in src/database/redis/sorted/intersect.js - About 1 hr 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 19 (exceeds 10 allowed). Consider refactoring.
Open

module.exports = function (Posts) {
    Posts.create = async function (data) {
        // This is an internal method, consider using Topics.reply instead
        const { uid } = data;
        const { tid } = data;
Severity: Minor
Found in src/posts/create.js - About 1 hr 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 19 (exceeds 10 allowed). Consider refactoring.
Open

module.exports = function (opts) {
    const TTLCache = require('@isaacs/ttlcache');
    const pubsub = require('../pubsub');

    const ttlCache = new TTLCache(opts);
Severity: Minor
Found in src/cache/ttl.js - About 1 hr 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 createAdmin has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring.
Open

async function createAdmin() {
    const User = require('./user');
    const Groups = require('./groups');
    let password;

Severity: Minor
Found in src/install.js - About 1 hr 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 19 (exceeds 10 allowed). Consider refactoring.
Open

module.exports = function (opts) {
    const { LRUCache } = require('lru-cache');
    const pubsub = require('../pubsub');

    // lru-cache@7 deprecations
Severity: Minor
Found in src/cache/lru.js - About 1 hr 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 loadClientHeaderFooterData has 92 lines of code (exceeds 75 allowed). Consider refactoring.
Open

    async function loadClientHeaderFooterData(req, res, options) {
        const registrationType = meta.config.registrationType || 'normal';
        res.locals.config = res.locals.config || {};
        const templateValues = {
            title: meta.config.title || '',
Severity: Major
Found in src/middleware/render.js - About 1 hr to fix

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

    module.exports = function (Groups) {
        Groups.leave = async function (groupNames, uid) {
            if (Array.isArray(groupNames) && !groupNames.length) {
                return;
            }
    Severity: Major
    Found in src/groups/leave.js - About 1 hr to fix

      Function loadRoom has 92 lines of code (exceeds 75 allowed). Consider refactoring.
      Open

          Messaging.loadRoom = async (uid, data) => {
              const { roomId } = data;
              const [room, inRoom, canChat, isAdmin, isGlobalMod] = await Promise.all([
                  Messaging.getRoomData(roomId),
                  Messaging.isUserInRoom(uid, roomId),
      Severity: Major
      Found in src/messaging/rooms.js - About 1 hr to fix

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

            categorySearch.init = function (el, options) {
                let categoriesList = null;
                options = options || {};
                options.privilege = options.privilege || 'topics:read';
                options.states = options.states || ['watching', 'tracking', 'notwatching', 'ignoring'];
        Severity: Major
        Found in public/src/modules/categorySearch.js - About 1 hr to fix

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

          module.exports = function (Groups) {
              Groups.getPending = async function (groupName) {
                  return await Groups.getUsersFromSet(`group:${groupName}:pending`, ['username', 'userslug', 'picture']);
              };
          
          
          Severity: Major
          Found in src/groups/invite.js - About 1 hr to fix

            Function onMessage has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring.
            Open

            async function onMessage(socket, payload) {
                const { event, params, callback } = payload;
                try {
                    if (!event) {
                        return winston.warn('[socket.io] Empty method name');
            Severity: Minor
            Found in src/socket.io/index.js - About 1 hr 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 set has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring.
            Open

            Themes.set = async (data) => {
                switch (data.type) {
                    case 'local': {
                        const current = await Meta.configs.get('theme:id');
                        const score = await db.sortedSetScore('plugins:active', current);
            Severity: Minor
            Found in src/meta/themes.js - About 1 hr 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 modifyGroup has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring.
            Open

            function modifyGroup(group, fields) {
                if (group) {
                    db.parseIntFields(group, intFields, fields);
            
                    escapeGroupData(group);
            Severity: Minor
            Found in src/groups/data.js - About 1 hr 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 18 (exceeds 10 allowed). Consider refactoring.
            Open

            module.exports = function (Groups) {
                Groups.search = async function (query, options) {
                    if (!query) {
                        return [];
                    }
            Severity: Minor
            Found in src/groups/search.js - About 1 hr 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 formatApiResponse has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring.
            Open

            helpers.formatApiResponse = async (statusCode, res, payload) => {
                if (res.req.method === 'HEAD') {
                    return res.sendStatus(statusCode);
                }
            
            
            Severity: Minor
            Found in src/controllers/helpers.js - About 1 hr 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 method has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring.
            Open

                method: function (callback) {
                    db.getSortedSetRange('categories:cid', 0, -1, (err, cids) => {
                        if (err) {
                            return callback(err);
                        }
            Severity: Minor
            Found in src/upgrades/1.8.0/give_spiders_privileges.js - About 1 hr 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 18 (exceeds 10 allowed). Consider refactoring.
            Open

            module.exports = function (User) {
                User.startJobs = function () {
                    winston.verbose('[user/jobs] (Re-)starting jobs...');
            
                    let { digestHour } = meta.config;
            Severity: Minor
            Found in src/user/jobs.js - About 1 hr 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 89 lines of code (exceeds 75 allowed). Consider refactoring.
            Open

                Groups.init = function () {
                    const groupIcon = $('#group-icon');
                    const changeGroupUserTitle = $('#change-group-user-title');
                    const changeGroupLabelColor = $('#change-group-label-color');
                    const changeGroupTextColor = $('#change-group-text-color');
            Severity: Major
            Found in public/src/admin/manage/group.js - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language