NodeBB/NodeBB

View on GitHub

Showing 589 of 606 total issues

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

module.exports = function (User) {
    User.updateProfile = async function (uid, data, extraFields) {
        let fields = [
            'username', 'email', 'fullname', 'website', 'location',
            'groupTitle', 'birthday', 'signature', 'aboutme',
Severity: Minor
Found in src/user/profile.js - About 2 days 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 434 lines of code (exceeds 50 allowed). Consider refactoring.
Open

module.exports = function (Topics) {
    Topics.createTags = async function (tags, tid, timestamp) {
        if (!Array.isArray(tags) || !tags.length) {
            return;
        }
Severity: Major
Found in src/topics/tags.js - About 2 days to fix

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

    module.exports = function (module) {
        const utils = require('../../utils');
        const helpers = require('./helpers');
        const dbHelpers = require('../helpers');
    
    
    Severity: Minor
    Found in src/database/redis/sorted.js - About 1 day 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 361 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

        Users.init = function () {
            $('#results-per-page').val(ajaxify.data.resultsPerPage).on('change', function () {
                var query = utils.params();
                query.resultsPerPage = $('#results-per-page').val();
                var qs = buildSearchQuery(query);
    Severity: Major
    Found in public/src/admin/manage/users.js - About 1 day to fix

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

      module.exports = function (Posts) {
          const votesInProgress = {};
      
          Posts.upvote = async function (pid, uid) {
              if (meta.config['reputation:disabled']) {
      Severity: Minor
      Found in src/posts/votes.js - About 1 day 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 83 (exceeds 10 allowed). Consider refactoring.
      Open

      module.exports = function (middleware) {
          async function authenticate(req, res) {
              const loginAsync = util.promisify(req.login).bind(req);
      
              if (req.loggedIn) {
      Severity: Minor
      Found in src/middleware/user.js - About 1 day 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 80 (exceeds 10 allowed). Consider refactoring.
      Open

      module.exports = function (Topics) {
          Topics.createTags = async function (tags, tid, timestamp) {
              if (!Array.isArray(tags) || !tags.length) {
                  return;
              }
      Severity: Minor
      Found in src/topics/tags.js - About 1 day 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 Translator has 312 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

          var Translator = (function () {
              /**
               * Construct a new Translator object
               * @param {string} language - Language code for this translator instance
               * @exports translator.Translator
      Severity: Major
      Found in public/src/modules/translator.js - About 1 day to fix

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

        module.exports = function (User) {
            const fieldWhitelist = [
                'uid', 'username', 'userslug', 'email', 'email:confirmed', 'joindate',
                'lastonline', 'picture', 'icon:bgColor', 'fullname', 'location', 'birthday', 'website',
                'aboutme', 'signature', 'uploadedpicture', 'profileviews', 'reputation',
        Severity: Minor
        Found in src/user/data.js - About 1 day 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 298 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        module.exports = function (Posts) {
            Posts.getQueuedPosts = async (filter = {}, options = {}) => {
                options = { metadata: true, ...options };    // defaults
                let postData = _.cloneDeep(cache.get('post-queue'));
                if (!postData) {
        Severity: Major
        Found in src/posts/queue.js - About 1 day to fix

          Function exports has a Cognitive Complexity of 74 (exceeds 10 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: Minor
          Found in src/groups/update.js - About 1 day 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 74 (exceeds 10 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: Minor
          Found in src/categories/topics.js - About 1 day 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 290 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          module.exports = function (module) {
              const helpers = require('./helpers');
          
              module.setObject = async function (key, data) {
                  if (!key || !data) {
          Severity: Major
          Found in src/database/postgres/hash.js - About 1 day to fix

            Function exports has a Cognitive Complexity of 72 (exceeds 10 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: Minor
            Found in src/topics/create.js - About 1 day 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 70 (exceeds 10 allowed). Consider refactoring.
            Open

            module.exports = function (Topics) {
                const topicTools = {};
                Topics.tools = topicTools;
            
                topicTools.delete = async function (tid, uid) {
            Severity: Minor
            Found in src/topics/tools.js - About 1 day 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 280 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            module.exports = function (User) {
                User.updateProfile = async function (uid, data, extraFields) {
                    let fields = [
                        'username', 'email', 'fullname', 'website', 'location',
                        'groupTitle', 'birthday', 'signature', 'aboutme',
            Severity: Major
            Found in src/user/profile.js - About 1 day to fix

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

              module.exports = function (Posts) {
                  Posts.getQueuedPosts = async (filter = {}, options = {}) => {
                      options = { metadata: true, ...options };    // defaults
                      let postData = _.cloneDeep(cache.get('post-queue'));
                      if (!postData) {
              Severity: Minor
              Found in src/posts/queue.js - About 1 day 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 265 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              module.exports = function (User) {
                  const fieldWhitelist = [
                      'uid', 'username', 'userslug', 'email', 'email:confirmed', 'joindate',
                      'lastonline', 'picture', 'icon:bgColor', 'fullname', 'location', 'birthday', 'website',
                      'aboutme', 'signature', 'uploadedpicture', 'profileviews', 'reputation',
              Severity: Major
              Found in src/user/data.js - About 1 day to fix

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

                module.exports = function (module) {
                    const utils = require('../../utils');
                    const helpers = require('./helpers');
                    const dbHelpers = require('../helpers');
                
                
                Severity: Major
                Found in src/database/redis/sorted.js - About 1 day to fix

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

                  module.exports = function (module) {
                      const helpers = require('./helpers');
                  
                      const cache = require('../cache').create('redis');
                  
                  
                  Severity: Minor
                  Found in src/database/redis/hash.js - About 1 day 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