NodeBB/NodeBB

View on GitHub

Showing 536 of 552 total issues

Function edit has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

postsAPI.edit = async function (caller, data) {
    if (!data || !data.pid || (meta.config.minimumPostLength !== 0 && !data.content)) {
        throw new Error('[[error:invalid-data]]');
    }
    if (!caller.uid) {
Severity: Minor
Found in src/api/posts.js - About 55 mins 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 checkCIFlag has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

function checkCIFlag() {
    let ciVals;
    try {
        ciVals = JSON.parse(nconf.get('ci'));
    } catch (e) {
Severity: Minor
Found in src/install.js - About 55 mins 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 14 (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/redis/sorted/remove.js - About 55 mins 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 14 (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.7.4/global_upload_privilege.js - About 55 mins 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 getDatabaseConfig has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

async function getDatabaseConfig(config) {
    if (!config) {
        throw new Error('invalid config, aborted');
    }

Severity: Minor
Found in install/databases.js - About 55 mins 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

Similar blocks of code found in 3 locations. Consider refactoring.
Open

                    alerts.alert({
                        alert_id: 'admin:theme',
                        type: 'info',
                        title: '[[admin/appearance/themes:theme-changed]]',
                        message: '[[admin/appearance/themes:restart-to-activate]]',
Severity: Major
Found in public/src/admin/appearance/themes.js and 2 other locations - About 55 mins to fix
public/src/admin/extend/plugins.js on lines 245..256
public/src/admin/extend/plugins.js on lines 284..295

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 73.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

                alerts.alert({
                    alert_id: 'plugin_reordered',
                    title: '[[admin/extend/plugins:alert.reorder]]',
                    message: '[[admin/extend/plugins:alert.reorder-success]]',
                    type: 'success',
Severity: Major
Found in public/src/admin/extend/plugins.js and 2 other locations - About 55 mins to fix
public/src/admin/appearance/themes.js on lines 32..43
public/src/admin/extend/plugins.js on lines 284..295

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 73.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

                alerts.alert({
                    alert_id: 'plugin_upgraded',
                    title: '[[admin/extend/plugins:alert.upgraded]]',
                    message: '[[admin/extend/plugins:alert.upgrade-success]]',
                    type: 'warning',
Severity: Major
Found in public/src/admin/extend/plugins.js and 2 other locations - About 55 mins to fix
public/src/admin/appearance/themes.js on lines 32..43
public/src/admin/extend/plugins.js on lines 245..256

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 73.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function addObjectPropertyElement has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    function addObjectPropertyElement(field, key, attributes, prop, value, separator, insertCb) {
Severity: Major
Found in public/src/modules/settings/object.js - About 50 mins to fix

    Function sortedSetRangeByScore has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        async function sortedSetRangeByScore(method, key, start, count, min, max, withScores) {
    Severity: Major
    Found in src/database/redis/sorted.js - About 50 mins to fix

      Function getSortedSetRangeByScore has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          async function getSortedSetRangeByScore(key, start, count, min, max, sort, withScores) {
      Severity: Major
      Found in src/database/postgres/sorted.js - About 50 mins to fix

        Function getSortedSetRange has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            async function getSortedSetRange(key, start, stop, min, max, sort, withScores) {
        Severity: Major
        Found in src/database/mongo/sorted.js - About 50 mins to fix

          Function genParams has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              function genParams(method, key, start, stop, min, max, withScores) {
          Severity: Major
          Found in src/database/redis/sorted.js - About 50 mins to fix

            Function getSortedSetRangeByScore has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                async function getSortedSetRangeByScore(key, start, count, min, max, sort, withScores) {
            Severity: Major
            Found in src/database/mongo/sorted.js - About 50 mins to fix

              Function sortedSetRange has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  async function sortedSetRange(method, key, start, stop, min, max, withScores) {
              Severity: Major
              Found in src/database/redis/sorted.js - About 50 mins to fix

                Function sortedSetLex has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    async function sortedSetLex(method, reverse, key, min, max, start, count) {
                Severity: Major
                Found in src/database/redis/sorted.js - About 50 mins to fix

                  Similar blocks of code found in 3 locations. Consider refactoring.
                  Open

                          await module.transaction(async (client) => {
                              await helpers.ensureLegacyObjectsType(client, keys, 'zset');
                              await client.query({
                                  name: 'sortedSetAddBulk2',
                                  text: `
                  Severity: Major
                  Found in src/database/postgres/sorted/add.js and 2 other locations - About 50 mins to fix
                  src/database/postgres/sorted/add.js on lines 21..32
                  src/database/postgres/sorted/add.js on lines 52..64

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 72.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 3 locations. Consider refactoring.
                  Open

                          await module.transaction(async (client) => {
                              await helpers.ensureLegacyObjectType(client, key, 'zset');
                              await client.query({
                                  name: 'sortedSetAddBulk',
                                  text: `
                  Severity: Major
                  Found in src/database/postgres/sorted/add.js and 2 other locations - About 50 mins to fix
                  src/database/postgres/sorted/add.js on lines 21..32
                  src/database/postgres/sorted/add.js on lines 119..131

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 72.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 3 locations. Consider refactoring.
                  Open

                      longestOptionTermLength(cmd, helper) {
                          return helper.visibleOptions(cmd).reduce((max, option) => Math.max(
                              max,
                              helper.optionTerm(option).length - getControlCharacterSpaces(helper.optionTerm(option))
                          ), 0);
                  Severity: Major
                  Found in src/cli/colors.js and 2 other locations - About 50 mins to fix
                  src/cli/colors.js on lines 91..96
                  src/cli/colors.js on lines 97..102

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 72.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 3 locations. Consider refactoring.
                  Open

                      longestArgumentTermLength(cmd, helper) {
                          return helper.visibleArguments(cmd).reduce((max, argument) => Math.max(
                              max,
                              helper.argumentTerm(argument).length - getControlCharacterSpaces(helper.argumentTerm(argument))
                          ), 0);
                  Severity: Major
                  Found in src/cli/colors.js and 2 other locations - About 50 mins to fix
                  src/cli/colors.js on lines 85..90
                  src/cli/colors.js on lines 91..96

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 72.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Severity
                  Category
                  Status
                  Source
                  Language