NodeBB/NodeBB

View on GitHub
src/controllers/write/users.js

Summary

Maintainability
C
1 day
Test Coverage

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

Users.updateSettings = async (req, res) => {
    const settings = await api.users.updateSettings(req, { ...req.body, uid: req.params.uid });
    helpers.formatApiResponse(200, res, settings);
};
Severity: Major
Found in src/controllers/write/users.js and 2 other locations - About 55 mins to fix
src/controllers/write/groups.js on lines 22..28
src/controllers/write/users.js on lines 39..42

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

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

Users.update = async (req, res) => {
    const userObj = await api.users.update(req, { ...req.body, uid: req.params.uid });
    helpers.formatApiResponse(200, res, userObj);
};
Severity: Major
Found in src/controllers/write/users.js and 2 other locations - About 55 mins to fix
src/controllers/write/groups.js on lines 22..28
src/controllers/write/users.js on lines 84..87

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

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

There are no issues that match your filters.

Category
Status