telepat-io/telepat-api

View on GitHub
controllers/user.js

Summary

Maintainability
F
1 wk
Test Coverage

File user.js has 787 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var express = require('express');
var router = express.Router();
var FB = require('facebook-node');
var Twitter = require('twitter');
var async = require('async');
Severity: Major
Found in controllers/user.js - About 1 day to fix

    Function sendEmail has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function sendEmail(provider, from, to, subject, content) {
        var emailService = Object.keys(provider)[0];
        var apiKey = provider[emailService];
    
        if (emailService == 'mandrill') {
    Severity: Minor
    Found in controllers/user.js - About 1 hr to fix

      Function unless has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      var unless = function(paths, middleware) {
          return function(req, res, next) {
              var excluded = false;
              for (var i=0; i<paths.length; i++) {
                  if (paths[i] === req.path) {
      Severity: Minor
      Found in controllers/user.js - About 45 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 sendEmail has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function sendEmail(provider, from, to, subject, content) {
      Severity: Minor
      Found in controllers/user.js - About 35 mins to fix

        Avoid too many return statements within this function.
        Open

                return next(new Models.TelepatError(Models.TelepatError.errors.InvalidLoginProvider, ['facebook, twitter, username']));
        Severity: Major
        Found in controllers/user.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return next(new Models.TelepatError(Models.TelepatError.errors.ServerNotConfigured,
                          ['twitter login provider']));
          Severity: Major
          Found in controllers/user.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return next(new Models.TelepatError(Models.TelepatError.errors.InvalidLoginProvider, ['facebook, twitter']));
            Severity: Major
            Found in controllers/user.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return next(new Models.TelepatError(Models.TelepatError.errors.MissingRequiredField, ['password']));
              Severity: Major
              Found in controllers/user.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return next(new Models.TelepatError(Models.TelepatError.errors.MissingRequiredField, ['oauth_token_secret']));
                Severity: Major
                Found in controllers/user.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return next(new Models.TelepatError(Models.TelepatError.errors.InvalidAuthorization, ['header invalid']));
                  Severity: Major
                  Found in controllers/user.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return next(new Models.TelepatError(Models.TelepatError.errors.ServerNotConfigured,
                                    ['twitter login provider']));
                    Severity: Major
                    Found in controllers/user.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return next(new Models.TelepatError(Models.TelepatError.errors.MissingRequiredField, ['email']));
                      Severity: Major
                      Found in controllers/user.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return next(new Models.TelepatError(Models.TelepatError.errors.MissingRequiredField, ['oauth_token_secret']));
                        Severity: Major
                        Found in controllers/user.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return next(new Models.TelepatError(Models.TelepatError.errors.MissingRequiredField, ['username']));
                          Severity: Major
                          Found in controllers/user.js - About 30 mins to fix

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

                            router.get('/get', function(req, res, next) {
                                Models.User({id: req.body.user_id}, req._telepat.applicationId, function(err, result) {
                                    if (err && err.status == 404) {
                                        return next(new Models.TelepatError(Models.TelepatError.errors.UserNotFound));
                                    }
                            Severity: Major
                            Found in controllers/user.js and 1 other location - About 6 hrs to fix
                            controllers/user.js on lines 759..770

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

                            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

                            Identical blocks of code found in 2 locations. Consider refactoring.
                            Open

                                if (Object.getOwnPropertyNames(req.body).length === 0) {
                                    return next(new Models.TelepatError(Models.TelepatError.errors.RequestBodyEmpty));
                                } else if (!Array.isArray(req.body.patches)) {
                                    return next(new Models.TelepatError(Models.TelepatError.errors.InvalidFieldValue,
                                        ['"patches" is not an array']));
                            Severity: Major
                            Found in controllers/user.js and 1 other location - About 6 hrs to fix
                            controllers/admin/user.js on lines 163..171

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

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

                            router.get('/me', function(req, res, next) {
                                Models.User({id: req.user.id}, req._telepat.applicationId, function(err, result) {
                                    if (err && err.status == 404) {
                                        return next(new Models.TelepatError(Models.TelepatError.errors.UserNotFound));
                                    }
                            Severity: Major
                            Found in controllers/user.js and 1 other location - About 6 hrs to fix
                            controllers/user.js on lines 801..812

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

                            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

                            Identical blocks of code found in 2 locations. Consider refactoring.
                            Open

                                } else if (loginProvider == 'twitter') {
                                    if (!req.body.oauth_token)
                                        return next(new Models.TelepatError(Models.TelepatError.errors.MissingRequiredField, ['oauth_token']));
                                    if (!req.body.oauth_token_secret)
                                        return next(new Models.TelepatError(Models.TelepatError.errors.MissingRequiredField, ['oauth_token_secret']));
                            Severity: Major
                            Found in controllers/user.js and 1 other location - About 6 hrs to fix
                            controllers/user.js on lines 446..461

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

                            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

                            Identical blocks of code found in 2 locations. Consider refactoring.
                            Open

                                } else if (loginProvider == 'twitter') {
                                    if (!req.body.oauth_token)
                                        return next(new Models.TelepatError(Models.TelepatError.errors.MissingRequiredField, ['oauth_token']));
                                    if (!req.body.oauth_token_secret)
                                        return next(new Models.TelepatError(Models.TelepatError.errors.MissingRequiredField, ['oauth_token_secret']));
                            Severity: Major
                            Found in controllers/user.js and 1 other location - About 6 hrs to fix
                            controllers/user.js on lines 220..230

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

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

                                if (loginProvider == 'facebook') {
                                    if (!req.body.access_token)
                                        return next(new Models.TelepatError(Models.TelepatError.errors.MissingRequiredField, ['access_token']));
                                    if (!app.telepatConfig.config.login_providers || !app.telepatConfig.config.login_providers.facebook)
                                        return next(new Models.TelepatError(Models.TelepatError.errors.ServerNotConfigured,
                            Severity: Major
                            Found in controllers/user.js and 1 other location - About 5 hrs to fix
                            controllers/user.js on lines 212..230

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

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

                                if (loginProvider == 'facebook') {
                                    if (!req.body.access_token)
                                        return next(new Models.TelepatError(Models.TelepatError.errors.MissingRequiredField, ['access_token']));
                                    if (!app.telepatConfig.config.login_providers || !app.telepatConfig.config.login_providers.facebook)
                                        return next(new Models.TelepatError(Models.TelepatError.errors.ServerNotConfigured,
                            Severity: Major
                            Found in controllers/user.js and 1 other location - About 5 hrs to fix
                            controllers/user.js on lines 438..461

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

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

                                        if (Models.Application.loadedAppModels[appId].email_templates &&
                                            Models.Application.loadedAppModels[appId].email_templates.reset_password) {
                                            messageContent = Models.Application.loadedAppModels[appId].email_templates.reset_password.
                                                replace(/\{CONFIRM_LINK}/g, redirectUrl);
                                        } else {
                            Severity: Major
                            Found in controllers/user.js and 1 other location - About 4 hrs to fix
                            controllers/user.js on lines 615..623

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

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

                                                if (Models.Application.loadedAppModels[appId].email_templates &&
                                                    Models.Application.loadedAppModels[appId].email_templates.confirm_account) {
                            
                                                    messageContent = Models.Application.loadedAppModels[appId].email_templates.confirm_account.
                                                        replace(/\{CONFIRM_LINK}/g, url);
                            Severity: Major
                            Found in controllers/user.js and 1 other location - About 4 hrs to fix
                            controllers/user.js on lines 1107..1114

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

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

                                    function(callback) {
                                        security.encryptPassword(req.body.password, function(err, hash) {
                                            if (err)
                                                return callback(err);
                            
                            
                            Severity: Major
                            Found in controllers/user.js and 1 other location - About 1 hr to fix
                            controllers/admin/context.js on lines 329..335

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

                            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

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

                                if (Object.getOwnPropertyNames(req.body).length === 0) {
                                    return next(new Models.TelepatError(Models.TelepatError.errors.RequestBodyEmpty));
                                }
                            Severity: Major
                            Found in controllers/user.js and 2 other locations - About 55 mins to fix
                            controllers/device.js on lines 79..81
                            controllers/device.js on lines 134..136

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

                            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

                            Identical blocks of code found in 2 locations. Consider refactoring.
                            Open

                                if (Object.getOwnPropertyNames(req.body).length === 0)
                                    return next(new Models.TelepatError(Models.TelepatError.errors.RequestBodyEmpty));
                            Severity: Minor
                            Found in controllers/user.js and 1 other location - About 50 mins to fix
                            controllers/admin/context.js on lines 169..170

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

                            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

                                            if (userProfile.name != socialProfile.name)
                                                patches.push(Models.Delta.formPatch(userProfile, 'replace', {name: socialProfile.name}));
                            Severity: Major
                            Found in controllers/user.js and 3 other locations - About 50 mins to fix
                            controllers/user.js on lines 348..349
                            controllers/user.js on lines 350..351
                            controllers/user.js on lines 357..358

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

                            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

                                            if (userProfile.name != socialProfile.name)
                                                patches.push(Models.Delta.formPatch(userProfile, 'replace', {name: socialProfile.name}));
                            Severity: Major
                            Found in controllers/user.js and 3 other locations - About 50 mins to fix
                            controllers/user.js on lines 350..351
                            controllers/user.js on lines 355..356
                            controllers/user.js on lines 357..358

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

                            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

                                            if (userProfile.picture != socialProfile.profile_image_url_https)
                                                patches.push(Models.Delta.formPatch(userProfile, 'replace', {picture: socialProfile.picture}));
                            Severity: Major
                            Found in controllers/user.js and 3 other locations - About 50 mins to fix
                            controllers/user.js on lines 348..349
                            controllers/user.js on lines 350..351
                            controllers/user.js on lines 355..356

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

                            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

                                            if (userProfile.gender != socialProfile.gender)
                                                patches.push(Models.Delta.formPatch(userProfile, 'replace', {gender: socialProfile.gender}));
                            Severity: Major
                            Found in controllers/user.js and 3 other locations - About 50 mins to fix
                            controllers/user.js on lines 348..349
                            controllers/user.js on lines 355..356
                            controllers/user.js on lines 357..358

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

                            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

                                Models.User.getMetadata(userId, function(err, result) {
                                    if (err) return next(err);
                            
                                    res.status(200).json({status: 200, content: result});
                                });
                            Severity: Major
                            Found in controllers/user.js and 2 other locations - About 40 mins to fix
                            controllers/object.js on lines 672..676
                            controllers/til.js on lines 99..104

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

                            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

                                        })], 'aggregation', function(err) {
                                            if (err)
                                                return next(err);
                                                
                                            res.status(202).json({status: 202, content: "User updated"});
                            Severity: Major
                            Found in controllers/user.js and 8 other locations - About 40 mins to fix
                            controllers/admin/admin.js on lines 279..283
                            controllers/admin/user.js on lines 212..216
                            controllers/object.js on lines 609..613
                            controllers/til.js on lines 46..51
                            controllers/user.js on lines 857..861
                            controllers/user.js on lines 1034..1038
                            controllers/user.js on lines 1130..1134
                            controllers/user.js on lines 1301..1305

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

                            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

                                ], function(err) {
                                    if (err) return next(err);
                            
                                    res.status(200).json({status: 200, content: "Logged out of device"});
                                });
                            Severity: Major
                            Found in controllers/user.js and 8 other locations - About 40 mins to fix
                            controllers/admin/admin.js on lines 279..283
                            controllers/admin/user.js on lines 212..216
                            controllers/object.js on lines 609..613
                            controllers/til.js on lines 46..51
                            controllers/user.js on lines 994..999
                            controllers/user.js on lines 1034..1038
                            controllers/user.js on lines 1130..1134
                            controllers/user.js on lines 1301..1305

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

                            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

                                ], function(err) {
                                    if (err)
                                        return next(err);
                                    res.status(200).json({status: 200, content: "Password reset email sent"});
                                });
                            Severity: Major
                            Found in controllers/user.js and 8 other locations - About 40 mins to fix
                            controllers/admin/admin.js on lines 279..283
                            controllers/admin/user.js on lines 212..216
                            controllers/object.js on lines 609..613
                            controllers/til.js on lines 46..51
                            controllers/user.js on lines 857..861
                            controllers/user.js on lines 994..999
                            controllers/user.js on lines 1034..1038
                            controllers/user.js on lines 1301..1305

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

                            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

                                Models.User.updateMetadata(userId, patches, function(err) {
                                    if (err) return next(err);
                            
                                    res.status(200).json({status: 200, content: "Metadata updated successfully"});
                                });
                            Severity: Major
                            Found in controllers/user.js and 8 other locations - About 40 mins to fix
                            controllers/admin/admin.js on lines 279..283
                            controllers/admin/user.js on lines 212..216
                            controllers/object.js on lines 609..613
                            controllers/til.js on lines 46..51
                            controllers/user.js on lines 857..861
                            controllers/user.js on lines 994..999
                            controllers/user.js on lines 1034..1038
                            controllers/user.js on lines 1130..1134

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

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

                                ], function(err) {
                                    if (err)
                                        return next(err);
                            
                                    res.status(200).json({status: 200, content: newPassword});
                            Severity: Minor
                            Found in controllers/user.js and 1 other location - About 40 mins to fix
                            controllers/object.js on lines 228..233

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

                            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

                                })], 'aggregation', function(err) {
                                    if (err) return next(err);
                            
                                    res.status(202).json({status: 202, content: "User deleted"});
                                });
                            Severity: Major
                            Found in controllers/user.js and 8 other locations - About 40 mins to fix
                            controllers/admin/admin.js on lines 279..283
                            controllers/admin/user.js on lines 212..216
                            controllers/object.js on lines 609..613
                            controllers/til.js on lines 46..51
                            controllers/user.js on lines 857..861
                            controllers/user.js on lines 994..999
                            controllers/user.js on lines 1130..1134
                            controllers/user.js on lines 1301..1305

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

                            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