NodeBB/NodeBB

View on GitHub

Showing 537 of 553 total issues

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

                {
                    label: translations[0],
                    fill: 'origin',
                    tension: tension,
                    backgroundColor: 'rgba(220,220,220,0.2)',
Severity: Major
Found in public/src/admin/dashboard.js and 4 other locations - About 1 hr to fix
public/src/admin/dashboard.js on lines 194..205
public/src/admin/dashboard.js on lines 206..217
public/src/admin/dashboard.js on lines 218..229
public/src/admin/dashboard.js on lines 230..241

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 81.

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 5 locations. Consider refactoring.
Open

                {
                    label: translations[4],
                    fill: 'origin',
                    tension: tension,
                    backgroundColor: 'rgba(151,187,205,0.2)',
Severity: Major
Found in public/src/admin/dashboard.js and 4 other locations - About 1 hr to fix
public/src/admin/dashboard.js on lines 182..193
public/src/admin/dashboard.js on lines 194..205
public/src/admin/dashboard.js on lines 206..217
public/src/admin/dashboard.js on lines 218..229

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 81.

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 5 locations. Consider refactoring.
Open

                {
                    label: translations[2],
                    fill: 'origin',
                    tension: tension,
                    backgroundColor: '#ba8baf33',
Severity: Major
Found in public/src/admin/dashboard.js and 4 other locations - About 1 hr to fix
public/src/admin/dashboard.js on lines 182..193
public/src/admin/dashboard.js on lines 194..205
public/src/admin/dashboard.js on lines 218..229
public/src/admin/dashboard.js on lines 230..241

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 81.

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 4 locations. Consider refactoring.
Open

privsAdmin.give = async function (privileges, groupName) {
    await helpers.giveOrRescind(groups.join, privileges, 0, groupName);
    plugins.hooks.fire('action:privileges.admin.give', {
        privileges: privileges,
        groupNames: Array.isArray(groupName) ? groupName : [groupName],
Severity: Major
Found in src/privileges/admin.js and 3 other locations - About 1 hr to fix
src/privileges/admin.js on lines 204..210
src/privileges/global.js on lines 128..134
src/privileges/global.js on lines 136..142

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 81.

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 xhr has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring.
Open

async function xhr(options) {
    // Normalize body based on type
    const { url } = options;
    delete options.url;

Severity: Minor
Found in public/src/modules/api.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 16 (exceeds 10 allowed). Consider refactoring.
Open

module.exports = function (Groups) {
    Groups.getPending = async function (groupName) {
        return await Groups.getUsersFromSet(`group:${groupName}:pending`, ['username', 'userslug', 'picture']);
    };

Severity: Minor
Found in src/groups/invite.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 16 (exceeds 10 allowed). Consider refactoring.
Open

module.exports = function (Groups) {
    const allowedTypes = ['image/png', 'image/jpeg', 'image/bmp'];
    Groups.updateCoverPosition = async function (groupName, position) {
        if (!groupName) {
            throw new Error('[[error:invalid-data]]');
Severity: Minor
Found in src/groups/cover.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 16 (exceeds 10 allowed). Consider refactoring.
Open

module.exports = function (User) {
    new cronJob('0 * * * *', (() => {
        User.autoApprove();
    }), null, true);

Severity: Minor
Found in src/user/approval.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 16 (exceeds 10 allowed). Consider refactoring.
Open

module.exports = function (User) {
    User.setCategoryWatchState = async function (uid, cids, state) {
        if (!(parseInt(uid, 10) > 0)) {
            return;
        }
Severity: Minor
Found in src/user/categories.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

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

Chats.rename = async (req, res) => {
    const roomObj = await api.chats.rename(req, {
        name: req.body.name,
        roomId: req.params.roomId,
    });
Severity: Major
Found in src/controllers/write/chats.js and 2 other locations - About 1 hr to fix
src/controllers/write/topics.js on lines 103..109
src/controllers/write/topics.js on lines 111..118

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 80.

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

            if (toggleVisibility) {
                el.find('.dropdown-toggle').css({ visibility: 'hidden' });
                searchEl.removeClass('hidden');
                searchEl.css({
                    'z-index': el.find('.dropdown-toggle').css('z-index') + 1,
Severity: Major
Found in public/src/modules/groupSearch.js and 2 other locations - About 1 hr to fix
public/src/modules/categorySearch.js on lines 28..34
public/src/modules/tagFilter.js on lines 34..40

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 80.

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

            if (toggleSearchVisibilty) {
                el.find('.dropdown-toggle').css({ visibility: 'hidden' });
                searchEl.removeClass('hidden');
                searchEl.css({
                    'z-index': el.find('.dropdown-toggle').css('z-index') + 1,
Severity: Major
Found in public/src/modules/tagFilter.js and 2 other locations - About 1 hr to fix
public/src/modules/categorySearch.js on lines 28..34
public/src/modules/groupSearch.js on lines 33..39

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 80.

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

            if (toggleVisibility) {
                el.find('.dropdown-toggle').css({ visibility: 'hidden' });
                searchEl.removeClass('hidden');
                searchEl.css({
                    'z-index': el.find('.dropdown-toggle').css('z-index') + 1,
Severity: Major
Found in public/src/modules/categorySearch.js and 2 other locations - About 1 hr to fix
public/src/modules/groupSearch.js on lines 33..39
public/src/modules/tagFilter.js on lines 34..40

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 80.

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

Topics.addTags = async (req, res) => {
    const payload = await api.topics.addTags(req, {
        tid: req.params.tid,
        tags: req.body.tags,
    });
Severity: Major
Found in src/controllers/write/topics.js and 2 other locations - About 1 hr to fix
src/controllers/write/chats.js on lines 72..79
src/controllers/write/topics.js on lines 103..109

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 80.

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

Topics.updateTags = async (req, res) => {
    const payload = await api.topics.updateTags(req, {
        tid: req.params.tid,
        tags: req.body.tags,
    });
Severity: Major
Found in src/controllers/write/topics.js and 2 other locations - About 1 hr to fix
src/controllers/write/chats.js on lines 72..79
src/controllers/write/topics.js on lines 111..118

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 80.

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 init has 81 lines of code (exceeds 75 allowed). Consider refactoring.
Open

    manage.init = function (roomId, buttonEl) {
        let modal;

        buttonEl.on('click', async function () {
            let groups = [];
Severity: Major
Found in public/src/client/chats/manage.js - About 1 hr to fix

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

        categoryFilter.init = function (el, options) {
            if (!el || !el.length) {
                return;
            }
            options = options || {};
    Severity: Major
    Found in public/src/modules/categoryFilter.js - About 1 hr to fix

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

      module.exports = function (Groups) {
          Groups.join = async function (groupNames, uid) {
              if (!groupNames) {
                  throw new Error('[[error:invalid-data]]');
              }
      Severity: Major
      Found in src/groups/join.js - About 1 hr to fix

        Function createAdmin has 81 lines of code (exceeds 75 allowed). Consider refactoring.
        Open

        async function createAdmin() {
            const User = require('./user');
            const Groups = require('./groups');
            let password;
        
        
        Severity: Major
        Found in src/install.js - About 1 hr to fix

          Function getTopicsByTids has 80 lines of code (exceeds 75 allowed). Consider refactoring.
          Open

          Topics.getTopicsByTids = async function (tids, options) {
              if (!Array.isArray(tids) || !tids.length) {
                  return [];
              }
              let uid = options;
          Severity: Major
          Found in src/topics/index.js - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language