NodeBB/NodeBB

View on GitHub

Showing 93 of 552 total issues

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

        await module.transaction(async (client) => {
            await helpers.ensureLegacyObjectType(client, key, 'set');
            await client.query({
                name: 'setAdd',
                text: `
Severity: Major
Found in src/database/postgres/sets.js and 2 other locations - About 50 mins to fix
src/database/postgres/main.js on lines 152..163
src/database/postgres/sets.js on lines 41..54

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

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.ensureLegacyObjectsType(client, keys, 'set');
            await client.query({
                name: 'setsAdd',
                text: `
Severity: Major
Found in src/database/postgres/sets.js and 2 other locations - About 50 mins to fix
src/database/postgres/main.js on lines 152..163
src/database/postgres/sets.js on lines 15..27

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

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, 'string');
            await client.query({
                name: 'set',
                text: `
Severity: Major
Found in src/database/postgres/main.js and 2 other locations - About 50 mins to fix
src/database/postgres/sets.js on lines 15..27
src/database/postgres/sets.js on lines 41..54

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

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

Users.deleteContent = async (req, res) => {
    await api.users.deleteContent(req, { ...req.params, password: req.body.password });
    helpers.formatApiResponse(200, res);
};
Severity: Major
Found in src/controllers/write/users.js and 8 other locations - About 40 mins to fix
src/controllers/write/users.js on lines 44..47
src/controllers/write/users.js on lines 54..57
src/controllers/write/users.js on lines 64..67
src/controllers/write/users.js on lines 89..92
src/controllers/write/users.js on lines 104..107
src/controllers/write/users.js on lines 109..112
src/controllers/write/users.js on lines 114..117
src/controllers/write/users.js on lines 119..122

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

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

Users.changePicture = async (req, res) => {
    await api.users.changePicture(req, { ...req.body, uid: req.params.uid });
    helpers.formatApiResponse(200, res);
};
Severity: Major
Found in src/controllers/write/users.js and 8 other locations - About 40 mins to fix
src/controllers/write/users.js on lines 44..47
src/controllers/write/users.js on lines 49..52
src/controllers/write/users.js on lines 54..57
src/controllers/write/users.js on lines 89..92
src/controllers/write/users.js on lines 104..107
src/controllers/write/users.js on lines 109..112
src/controllers/write/users.js on lines 114..117
src/controllers/write/users.js on lines 119..122

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

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

Users.unban = async (req, res) => {
    await api.users.unban(req, { ...req.body, uid: req.params.uid });
    helpers.formatApiResponse(200, res);
};
Severity: Major
Found in src/controllers/write/users.js and 8 other locations - About 40 mins to fix
src/controllers/write/users.js on lines 44..47
src/controllers/write/users.js on lines 49..52
src/controllers/write/users.js on lines 54..57
src/controllers/write/users.js on lines 64..67
src/controllers/write/users.js on lines 89..92
src/controllers/write/users.js on lines 104..107
src/controllers/write/users.js on lines 114..117
src/controllers/write/users.js on lines 119..122

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

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

                } else if (numMinutes) {
                    if (numSeconds) {
                        msg = '[[error:' + languageKey + '-minutes-seconds, ' + numMinutes + ', ' + numSeconds + ']]';
                    } else {
                        msg = '[[error:' + languageKey + '-minutes, ' + numMinutes + ']]';
Severity: Major
Found in public/src/client/topic/postTools.js and 2 other locations - About 40 mins to fix
public/src/client/topic/postTools.js on lines 205..223
public/src/client/topic/postTools.js on lines 211..223

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

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

        try {
            await bulk.execute();
        } catch (err) {
            if (err && err.message.includes('E11000 duplicate key error')) {
                console.log(new Error('e11000').stack, keys, value);
Severity: Major
Found in src/database/mongo/sets.js and 2 other locations - About 40 mins to fix
src/database/mongo/hash.js on lines 20..34
src/database/mongo/sets.js on lines 16..34

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

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

Users.ban = async (req, res) => {
    await api.users.ban(req, { ...req.body, uid: req.params.uid });
    helpers.formatApiResponse(200, res);
};
Severity: Major
Found in src/controllers/write/users.js and 8 other locations - About 40 mins to fix
src/controllers/write/users.js on lines 44..47
src/controllers/write/users.js on lines 49..52
src/controllers/write/users.js on lines 54..57
src/controllers/write/users.js on lines 64..67
src/controllers/write/users.js on lines 89..92
src/controllers/write/users.js on lines 109..112
src/controllers/write/users.js on lines 114..117
src/controllers/write/users.js on lines 119..122

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

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 (numDays) {
                    if (numHours) {
                        msg = '[[error:' + languageKey + '-days-hours, ' + numDays + ', ' + numHours + ']]';
                    } else {
                        msg = '[[error:' + languageKey + '-days, ' + numDays + ']]';
Severity: Major
Found in public/src/client/topic/postTools.js and 2 other locations - About 40 mins to fix
public/src/client/topic/postTools.js on lines 211..223
public/src/client/topic/postTools.js on lines 217..223

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

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

Users.deleteAccount = async (req, res) => {
    await api.users.deleteAccount(req, { ...req.params, password: req.body.password });
    helpers.formatApiResponse(200, res);
};
Severity: Major
Found in src/controllers/write/users.js and 8 other locations - About 40 mins to fix
src/controllers/write/users.js on lines 44..47
src/controllers/write/users.js on lines 49..52
src/controllers/write/users.js on lines 64..67
src/controllers/write/users.js on lines 89..92
src/controllers/write/users.js on lines 104..107
src/controllers/write/users.js on lines 109..112
src/controllers/write/users.js on lines 114..117
src/controllers/write/users.js on lines 119..122

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

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

Users.mute = async (req, res) => {
    await api.users.mute(req, { ...req.body, uid: req.params.uid });
    helpers.formatApiResponse(200, res);
};
Severity: Major
Found in src/controllers/write/users.js and 8 other locations - About 40 mins to fix
src/controllers/write/users.js on lines 44..47
src/controllers/write/users.js on lines 49..52
src/controllers/write/users.js on lines 54..57
src/controllers/write/users.js on lines 64..67
src/controllers/write/users.js on lines 89..92
src/controllers/write/users.js on lines 104..107
src/controllers/write/users.js on lines 109..112
src/controllers/write/users.js on lines 119..122

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

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

        try {
            await module.client.collection('objects').updateOne({
                _key: key,
            }, {
                $addToSet: {
Severity: Major
Found in src/database/mongo/sets.js and 2 other locations - About 40 mins to fix
src/database/mongo/hash.js on lines 20..34
src/database/mongo/sets.js on lines 59..67

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

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

        try {
            if (isArray) {
                const bulk = module.client.collection('objects').initializeUnorderedBulkOp();
                key.forEach(key => bulk.find({ _key: key }).upsert().updateOne({ $set: writeData }));
                await bulk.execute();
Severity: Major
Found in src/database/mongo/hash.js and 2 other locations - About 40 mins to fix
src/database/mongo/sets.js on lines 16..34
src/database/mongo/sets.js on lines 59..67

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

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

Users.changePassword = async (req, res) => {
    await api.users.changePassword(req, { ...req.body, uid: req.params.uid });
    helpers.formatApiResponse(200, res);
};
Severity: Major
Found in src/controllers/write/users.js and 8 other locations - About 40 mins to fix
src/controllers/write/users.js on lines 44..47
src/controllers/write/users.js on lines 49..52
src/controllers/write/users.js on lines 54..57
src/controllers/write/users.js on lines 64..67
src/controllers/write/users.js on lines 104..107
src/controllers/write/users.js on lines 109..112
src/controllers/write/users.js on lines 114..117
src/controllers/write/users.js on lines 119..122

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

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

Users.delete = async (req, res) => {
    await api.users.delete(req, { ...req.params, password: req.body.password });
    helpers.formatApiResponse(200, res);
};
Severity: Major
Found in src/controllers/write/users.js and 8 other locations - About 40 mins to fix
src/controllers/write/users.js on lines 49..52
src/controllers/write/users.js on lines 54..57
src/controllers/write/users.js on lines 64..67
src/controllers/write/users.js on lines 89..92
src/controllers/write/users.js on lines 104..107
src/controllers/write/users.js on lines 109..112
src/controllers/write/users.js on lines 114..117
src/controllers/write/users.js on lines 119..122

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

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

Users.unmute = async (req, res) => {
    await api.users.unmute(req, { ...req.body, uid: req.params.uid });
    helpers.formatApiResponse(200, res);
};
Severity: Major
Found in src/controllers/write/users.js and 8 other locations - About 40 mins to fix
src/controllers/write/users.js on lines 44..47
src/controllers/write/users.js on lines 49..52
src/controllers/write/users.js on lines 54..57
src/controllers/write/users.js on lines 64..67
src/controllers/write/users.js on lines 89..92
src/controllers/write/users.js on lines 104..107
src/controllers/write/users.js on lines 109..112
src/controllers/write/users.js on lines 114..117

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

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

                } else if (numHours) {
                    if (numMinutes) {
                        msg = '[[error:' + languageKey + '-hours-minutes, ' + numHours + ', ' + numMinutes + ']]';
                    } else {
                        msg = '[[error:' + languageKey + '-hours, ' + numHours + ']]';
Severity: Major
Found in public/src/client/topic/postTools.js and 2 other locations - About 40 mins to fix
public/src/client/topic/postTools.js on lines 205..223
public/src/client/topic/postTools.js on lines 217..223

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

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

        categoryData.sort((c1, c2) => {
            if (c1.parentCid !== c2.parentCid) {
                return c1.parentCid - c2.parentCid;
            }
            return c1.order - c2.order;
Severity: Minor
Found in src/categories/search.js and 2 other locations - About 35 mins to fix
src/categories/index.js on lines 338..343
src/categories/index.js on lines 389..394

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

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

    rootCategories.sort((a, b) => {
        if (a.order !== b.order) {
            return a.order - b.order;
        }
        return a.cid - b.cid;
Severity: Minor
Found in src/categories/index.js and 2 other locations - About 35 mins to fix
src/categories/index.js on lines 338..343
src/categories/search.js on lines 54..59

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

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